Partial Methods

From RemObjects Software

Jump to: navigation, search

This is a Oxygene Language Feature topic
Feel free to add your notes to this topic below.



A partial method is an empty method defined in a partial class and marked with the partial keyword.

If a partial method isn't filled, with the non-empty counter part, all calls to it will be eliminated.

This feature is used for code generators to create events handling without the overhead of the delegate checking and invoking, and where most events won't be filled.

A partial method looks like:

Generated side:

type
  MyClass = public partial class
  private
    method OnBeforeProcess; partial; empty;
    method OnAfterProcess; partial; empty;
  public
    method Process;
  end;

method MyClass.Process;
begin
  OnBeforeProcess;
  { do something }
  OnAfterProcess;
end;


Implementation side:

type
  MyClass = public partial class
  private
    method OnBeforeProcess; partial;
  end;

method MyClass.OnBeforeProcess;
begin
 ...
end;

In the above sample the call to OnAfterProcess is never done, and the method itself is eliminated, the OnBeforeProcess method is implemented and the call to it is emitted.


See Also


Product: RemObjects Oxygene (formerly known as Chrome)
Current version: 3.0 Previous Versions: 'Joyride' (2.0), 'Floorshow' (1.5), 'Adrenochrome' (1.0)

GlossaryKeywordsLanguage FeaturesPlatform FeaturesSamplesArticlesHow ToIssues

Personal tools