On 27.09.2014 21:22, Hans-Peter Diettrich wrote:
Marco van de Voort schrieb:
In our previous episode, Sven Barth said:
It looks to me like inside methods Self doesn't deserve refcounting,
because a method can be invoked only with an existing instance, which
will stay alive at least until the call returns.
That's the thing I'm not yet entirely sure about. Though disabling it
for Self would definitely simplyfy things. I'll simply give it a try
and then my constructor problems should hopefully be solved as well...
Methods might return SELF as function result?
[snip]
Suggestion:
The constructor inits the refcount to 1, and decrements it on exit -
*not* using _Release! This will prevent destruction by refcounting
during construction.
This is precisely what is already done for TInterfacedObject which faces
the same problem if it's Self value is passed around as an interface.
Another one - weak references:
When the compiler only handles immediate assignments to weak references,
such a variable cannot be passed as VAR, because the called code cannot
know about that special handling.
Would be interesting to see what the Delphi NextGen compiler is doing
there. Maybe such var-parameters need to be marked with WeakRef as well...
Regards,
Sven
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel