Delphi Compatibility Settings
Aside from the vast amount of new features that Oxygene brings to Object Pascal, it also provides some to make the language more consistent and a better citizen on the (semi-)managed platforms.
We believe that these changes, as small and as trivial as some of them seem to be, are an important factor of what makes the Oxygene language clean and consistent, and we encourage developers to embrace them, rather than resists change and disable them — but we also realize that there is a need for developers to share some code between Oxygene and Delphi and maintain it for both compilers.
And so we have provided a compiler option to enable enhanced Delphi compatibility — at the expense of making the language a bit more cluttered and inconsistent when this option is enabled.
There are two ways to enable this mode:
Delphi language compatibility can be enabled on a file-by-file basis
(or even for a sub-portion of a file) using the
$DELPHICOMPATIBILITYCompiler Directive. Possible values are
DEFAULT, with the latter reverting to the project-wide setting.
- It can also be enabled for the entire project in the Compatibility section of Project Settings.
Effects of the Delphi Language Compatibility option
Turning on Delphi language compatibility effects the following changes in the Oxygene compiler:
- Allow the use of the = operator instead of := in parameter defaults, variable initialization and attributes.
Allow Delphi-style GUIDs in interface declaration on
.NET to add the
- Ignore the following Delphi keywords: reference to, stdcall, cdecl, pascal, register, safecall, overload, library, static, platform.
- Allow the dynamic keyword and treat it as identical to
Allow the deprecated keyword and map it to the appropriate
Allow the use of strict to prefix
protectedvisibility sections. The two keywords will merely be ignored, since Oxygene's
protectedvisibility already behave properly to start with.
Other Relevant Project Options
In addition to the "big" Delphi Language Compatibility switch, there are three more compatibility options (available on the same Project properties tab) that might be relevant to Delphi developers:
Allow legacy 'with' — Restores Delphi's unsafe
withsyntax that does not require an explicit variable declaration, like Oxygene's keyword does. We highly discourage enabling this option, and recommend revising the Delphi code in question instead, if you must share code between Delphi and Oxygene.
out' in method calls — Allows the passing of by-reference parameters without prefixing them with the
Allow legacy 'Create' constructors — Allows the use of the
Createname both for declaring and calling Constructors and instantiating new objects. By default, Oxygene uses nameless constructors (and, on Cocoa, optionally constructors with Cocoa's
Use Delphi-compatible division operators — Changes the
/operators to behave as they do on Delphi, with
divalways producing an integer result, and
/always producing a float result, regardless of input.
Read more about the language differences between Oxygene and Delphi: