Legacy Create Constructors

From The Oxygene Language Wiki

Jump to:navigation, search

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



Delphi Prism supports constructors with the Create syntax, as used in other Pascal dialects when the legacy Create option is enabled, in the Project Options. The reason for this is that .NET doesn't have a name for constructors, instead they're all called ".ctor" and can only overload by parameter, not by name. When this option is enabled, the Create keyword is ignored by the compiler and will be treated as nameless. It's also possible to call a constructor through Create, when this option is enabled.

type
  MyClass = class
  public
    constructor Create;
  end;

...

constructor MyClass.Create;
begin
  ... // instance initialization goes here.
end;

begin
  var lMyClass := MyClass.Create;

Notes

When this option is enabled Create is treated as a keyword even after a dot; to call a class with a member called Create you can use &Create, for example like: WebRequest.&Create


See Also


Oxygene-48.png

Area: Oxygene Language
Compiler version: Oxygene 5

Language GlossaryKeywordsTypesFAQHow To

Navigation
Areas
More
Toolbox