delphi-coll-xe icon indicating copy to clipboard operation
delphi-coll-xe copied to clipboard

In Collections.Dynamic, Member.TSelector<T, K> implementation relies on a hack that may no longer work

Open delphidabbler opened this issue 3 years ago • 2 comments

https://github.com/delphidabbler/delphi-coll-xe/blob/a59ccc3b6b935878ba7682ce0ace78eb60f72373/src/Library/Collections.Dynamic.pas#L57

The use of TFunc<P,R> in the interface list of TSelector<T,K> above uses a hack that relies on Delphi implementating TFunc<> as an interfaced object that defines a single Invoke method. This method is referenced later in

https://github.com/delphidabbler/delphi-coll-xe/blob/f072f729a3d18b1ae8cfc7aca9ea1887a1b6e9f1/src/Library/Collections.Dynamic.pas#L64

And

https://github.com/delphidabbler/delphi-coll-xe/blob/f072f729a3d18b1ae8cfc7aca9ea1887a1b6e9f1/src/Library/Collections.Dynamic.pas#L65

While this may work in Delphi XE I've read that later compilers prevent the use of TFunc<>.Invoke. So an alternative method of achieving the same result may be required.

delphidabbler avatar Jun 13 '22 11:06 delphidabbler