We are pleased to announce the 3rd release of Duck Duck Delphi. This udpate provides significant changes and enhancements, adding both flexability and power to the framework.

The biggest enhancement is in respect to Interfaces. Now you can ask if your objects can impersonate an interface, even if it does not implement one. An object that can impersonate an interface is one that implements all of the interface's methods and properties with compatible signatures.

For example,

IMath = interface(IInterface)

function Add(A,B) : integer;

function Subtract(A, B) : integer;

end;

TMyObject = class(TObject) // does not implement IMath

function Add(A,B) : integer;

function Subtract(A, B) : integer;

end;

......

var

obj : TMyObject;

bOkToAdd : boolean;

begin

obj := TMyObject.Create;

bOKToAdd := obj.impersonates<IMath>;

end;

Also new to the framework is simplified access to those interface methods:

if obj.impersonates<IMath> then

Result := obj.asA<IMath>.add(1,5);

(For those of you who complained that Duck Duck Delphi was less about Duck Typing and more about reflection, perhaps this will help to sway some of those concerns.)

Most of the other changes and fixes have been detailed in our changelog below:

+ Added asA<I> to return a custom variant wrapper around the object allowing it to be called as though it were the interface supplied without using the duck interface methods. allowing you to see if the object has all of the methods and properties required of the interface even if it doesn't implement the interface.

+ Added impersonates<I> check to the object class helper allowing you to see if the object has all of the methods and properties required of the interface even if it doesn't implement the interface.

+ Added new duck functions to return selectors including: this (the same object via selector), related (all related objects, note that this is the same as "all" used to be), props (all object properties of the object), go (executes a method and returns a selector of the result.

* Altered duck.all to return all related objects as well as any properties of type TObject.