Delphi language features missing from the Free Pascal Compiler
From Free Pascal wiki
Revision as of 17:29, 8 November 2009 by Paul Ishenin (talk | contribs) (→AS and IS extended for interfaces)
New since Delphi 2007
Operator Overloading Syntax for records and classes
Info: http://docwiki.embarcadero.com/RADStudio/en/Operator_Overloading http://wiert.wordpress.com/2009/10/19/delphi-operator-overloading-table-of-operators-names-and-some-notes-on-usage-and-glitches/
Class Helpers
Records with Methods
Class Variables, Types and Consts, Class Properties, Static Class Methods
<delphi> program ClassTest;
{$APPTYPE CONSOLE}
type
TSomeClass = class private type TSomeType = type integer; // an internal type class var FSomeClassVar: TSomeType; // class variable belongs to class, not an instance var FSomeIntanceVar: TSomeType; // instance variable belongs to instance. it is a usual field class procedure SetSomeClassVar(const AValue: TSomeType); static; public class property SomeProperty: TSomeType read FSomeClassVar write SetSomeClassVar; // class property - belongs to class property SomeInstanceProp: TSomeType read FSomeIntanceVar; end;
{ TSomeClass }
class procedure TSomeClass.SetSomeClassVar(const AValue: TSomeType); begin
FSomeClassVar := AValue;
end;
var
SomeClass: TSomeClass;
begin
SomeClass.SomeProperty := 1; WriteLn(SomeClass.SomeProperty);
end. </delphi>
New since Delphi 2009
Generics Syntax
Unicode string support
Anonymouse Methods
New since Delphi 2010
Custom Attributes
Enhanced RTTI
Class constructors and destructors
http://blogs.embarcadero.com/abauer/2009/09/03/38898
Delayed directive
Info is here: http://docwiki.embarcadero.com/RADStudio/en/Libraries_and_Packages#Delayed_Loading Some info about internals:
- http://blogs.embarcadero.com/abauer/2009/08/25/38894
- http://blogs.embarcadero.com/abauer/2009/08/29/38896
- http://blogs.embarcadero.com/chrishesik/2009/11/02/35056
fpc wiki about that topic: http://wiki.freepascal.org/Dynamically_loading_headers
AS and IS extended for interfaces
Info is here:
- http://docwiki.embarcadero.com/RADStudio/en/Interface_References#Casting_Interface_References_to_Objects
- http://blogs.embarcadero.com/abauer/2009/08/21/38893
Misc:
- {$SCOPEDENUMS ON} directive which allows to use enumeration name before the item. Example:
<delphi> type
TColor = (red, green, blue);
begin
WriteLn(ord(TColor.red));
end; </delphi>
- {$pointermath ON} directive which turns on pointer arithmetic.