FPC New Features Trunk

From Lazarus wiki
Revision as of 18:17, 23 December 2010 by Jonas (talk | contribs) (→‎Language changes: Constref parameter modifier)
Jump to navigationJump to search

About this page

Below you can find a list of new features introduced since the previous release, along with some background information and examples.

All systems

Language changes

Better support for Delphi-compatible classes

  • Overview: Support has been added for nested types (including other classes), class variables and class-local constants.
  • Notes: Delphi-compatible.
  • More information: class_extensions_examples lists several examples that make use of these features.

Scoped enumerations

Custom deprecated messages

  • Overview: Deprecated can now be applied to virtually any syntactic element (including constants and units), and it is also possible to specify a custom deprecation message.
  • Notes: Delphi-compatible
  • More information:

<delphi> Todo: write example </delphi>

Support for Objective-Pascal dialect

  • Overview: On Mac OS X, most system frameworks are written in Objective-C. While it is possible to interface them via a procedural API, this is not very convenient. For this reason, we have created a new dialect called Objective-Pascal that enables seamless interacting with Objective-C code.
  • Notes: This new dialect is currently only supported on Darwin-based platforms (including iOS) using the Apple Objective-C runtime. Patches to add support for the GNUStep runtime are welcome.
  • More information:
    • FPC_PasCocoa explains the basic language definitions.
    • FPC_PasCocoa/Differences explains some of the differences between Objective-Pascal and on the one hand Object Pascal, and on the other hand Objective-C.

Constref parameter modifier

  • Overview: Apart from the existing var, const and out parameter modifiers, a new modifier called constref has been added. This modifier means that the compiler can assume that the parameter is constant, and that it must be passed by reference. Its most obvious usage is to translate "const *" parameters from C headers.
  • Notes: The main reason it was introduced was to enable writing a cross-platform interface for XPCOM, as explained on the User_Changes_Trunk page.
  • More information:

<delphi> procedure test(constref l: longint); begin

 writeln('This parameter has been passed by reference, although the Pascal code does not really care about that: ',l);

end;

begin

 test(5);

end. </delphi>