[fpc-devel] Interface scope incompatibility with Delphi
florian at freepascal.org
Wed Nov 10 10:42:22 CET 2010
Am 10.11.2010 10:42, schrieb Graeme Geldenhuys:
> Op 2010-11-10 11:30, Michael Van Canneyt het geskryf:
>> It depends. You're not supposed to make assumptions on when an interface
>> goes out of scope.
> I'll search the mailing list archives for those explanations, thanks. I
> don't immediately understand why this is a problem, because the RTL is not
> a "managed code" environment with garbage collection. So I guess most
> developers would expect common "out of scope" rules apply. When a local
> variable is defined and you leave that method/procedure, it's out of scope.
Indeed, that's what happens in this code and what FPC does. What the
code makes working is how delphi handles temporary interfaces. The
LogMethod call generates a temp. interface variable for the result. FPC
finalizes this temp. interface immediatly after the call because the
result is not used. Delphi does this apparently delayed.
More information about the fpc-devel