There has been two major additions to Delphi Script in the SVN.
Interfaces
You can now declare, implement and use pure-interfaces in DWScript.
- Same syntax as Delphi, minus the GUID
- All classes from TObject can directly implement interfaces (no need to implement IUnknown or derive from TInterfacedObject)
- interface properties are supported
- “is” can be used to test if an interface is another interface or can be cast to a class
- “as” can be used to cast between classes and interfaces (in all directions)
- “implements” can be used to determine if a class implements a particular interface
The “implements” operator was introduced for OO purity, since “obj is interface” is somewhat of an heresy from an OO point of view, so you’re encouraged to lobby for “obj implements interface” 😉
Finally, you can also acquire a function pointer/delegate from an interface method (something that Delphi doesn’t support, as of XE).
Build system
The “unit” support which was previously mentioned as experimental can now be considered operational.
DWScript supports classic Pascal units, with “unit”, an “interface” and “implementation” section, and when compiling a unit it enforces the usual restrictions, so you also have “type” blocks, as disambiguating type declarations is not necessary within a unit.
To feed unit’s code to the compiler, you can either use the “virtual file system” approach, or just handle the new OnNeedUnit event. In that event you have a choice of providing either raw source code or “ready-made” unit in the form of an IdwsUnit.
Other changes
- the combined try..except..finally statement (ala Oxygen) is now supported
- fixes + new tests for RTTI-based exposition
- records, classes & interface symbols have been unified as TStructuredSymbol, TRecordSymbol got its TMemberSymbol replaced by TFieldSymbol
- a variety of minor fixes and enhancements