DelphiTools – Delphi 2010 added support for the “as” to cast an interface reference to its implementation class. Cast interface as class type IFoo = interface ... end; TFoo = class (TInterfacedObject, IFoo) ... end; ... var intf : IFoo; var foo : TFoo; ... intf := TFoo.Create; ... foo := intf as TFoo; // get back the implementation class However, if “as” can be convenient in certain scenarios, it’s alas not implemented very efficiently: the compiler and RTL go through several hoops to perform it (cf. this article by Arnaud Bouchez). One of those hoops f.i. gets slower the ...
Visits by Source
Users who voted for this posting
Jørn E. Angeltveit