The googlecode SVN [1] version of DWS introduces delegates capability:
- Function pointers are now supported in DWS, the syntax is similar to Delphi, though no distinction is made between standalone functions and methods, ie. as long as the parameter(s) and return types match, the following will work:
type TMyFunc = function (i : Integer) : String; var f : TMyFunc; f := IntToStr; f := SomeObject.SomeMatchingFunc; f := TSomeClass.SomeMatchingClassFunc;
- Support for direct method implementation from within the class declaration has been added, ie. the following code (which will likely be controversial ;-)) is now accepted:
type TMyClass = class Field : Integer; procedure Add(v : Integer); begin Field += v; end; function ToString : String; virtual; begin Result:=IntToStr(Field); end; end;
It is intended for short implementations, and only class members which have been declared before the implementation point are accepted (which follows the usual scoping rules).
- Initial methods for enumerating/browsing the compiled expression tree have been added (GetSubExpr, GetSubExprCount).
- UTCDateTime has been added to the standard time functions.
- fixed a bug that affected class functions invoking class functions when invoked from an object instance.
- misc. fixes, code cleanups and coverage improvements.