I.T. Discussion Community!
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesDelphi  Print This     

Partial Class (Delphi and Delphi Prism Cross Reference Guide)

By Mike Prestwood

Delphi versus Delphi Prism: A side by side comparison between Delphi and Delphi Prism.

 
OOP Details
 

More object oriented (OO) stuff.

Partial Class

[Other Languages] 

A partial class, or partial type, is a class that can be split into two or more source code files and/or two or more locations within the same source file. Each partial class is known as a class part or just a part. Logically, partial classes do not make any difference to the compiler. The compiler puts the class together at compile time and treats the final class or type as a single entity exactly the same as if all the source code was in a single location.

Languages Focus

For languages that have implemented partial classes, you need to know usage details and restrictions. Can you split a class into two or more files? Can you split a class within a source code file into two or more locations? What are the details of inheritance? Does it apply to interfaces as well?

Delphi:  "Partial Classes" Not Supported

As of Delphi 2009, partial classes are not supported. The main reason given in the thread below was that the Delphi compiler is a single pass compiler. Here is a link to a discussion thread on the subject:

Delphi Prism:  "Partial Classes" partial

Prism supports both partial classes and partial methods using the keyword partial. A partial method is an empty method defined in a partial class.

Syntax Example:
//Organize a large class in multiple files.
T800 = partial class(Cyborg, IHuman);
end;
  
T800 = partial class(ITalk);
end;
  
//Partial methods too:�
T800 = public partial class
private
method Walk; partial; empty;
method Run; partial; empty;
end;













Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech