> On Sep 17, 2022, at 10:57 PM, Sven Barth <pascaldra...@googlemail.com> wrote: > > === code begin === > > type > TProc = reference to procedure; > TMyClass = class > procedure DoThis; > end; > > TCapturer = class(TInterfacedObject, TProc) > m: procedure of object; > procedure Anonymous1; > > procedure TProc.Invoke = Anonymous1; > end; > > var > p: TProc; > c: TMyClass; > capturer: TCapturer; > capturer_keepalive: IUnknown; > begin > capturer := TCapturer.Create; > capturer_keepalive := capturer; > c := TMyClass.Create; > capturer.m := @c.DoThis; > p := capturer as TProc; > end. > > === code end ===
Well if p is effectively TCapturer then you COULD get back TMethod from m (procedure of object) but the compiler doesn’t have a method generated for this. I read your announcement email again last night and saw that TProc could actually be subclassed which opens up the possibility to read the field (if it’s not intentionally hidden) or use the RTTI perhaps even. Is that possible? If the field “m" is hidden I would say that should be exposed for the purposes of subclassing . Regards, Ryan Joseph _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal