[fpc-pascal] What happens when assigning interfaces?

Sven Barth pascaldragon at googlemail.com
Fri Jul 10 14:17:54 CEST 2020


Ryan Joseph via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Fr., 10. Juli 2020, 12:04:

>
>
> > On Jul 10, 2020, at 12:31 PM, Sven Barth <pascaldragon at googlemail.com>
> wrote:
> >
> > A lookup is only necessary if you use e.g. "SomeClass as SomeIntf".
>
> so if I do:
>
> DoSomething(c as IFoo);
>
> then Supports() is called at runtime to return the IFoo interface? That's
> the kind of thing I was really curious about, when are runtime checks
> performed vs compile time checks.
>

If you use the "as" or "is" operators it will be runtime checks, otherwise
it will be compile time checks.

Also to be pedantic: the operators use the lower level API
GetInterfaceByStr not Supports (which uses another low level API).

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200710/9804d064/attachment.htm>


More information about the fpc-pascal mailing list