Re: [fpc-devel] Proof of Concept ARC implementation
Am 26.10.2014 02:10 schrieb Kostas Michalopoulos badsectorac...@gmail.com : My only comment will be about the placement of weak... wouldn't make more sense to put it in front of the type (ie weak TTest instead of TTest weak), similar to how other stuff like const, var, specialize, etc work? It looks a bit out of place there (and IMO some Thing reads better than Thing some :-P). Definitely not. We are in Pascal and there such directives are placed afterwards. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proof of Concept ARC implementation
Sven Barth schrieb: Am 25.10.2014 03:17 schrieb Hans-Peter Diettrich drdiettri...@aol.com mailto:drdiettri...@aol.com: - a class instance is destroyed once the reference count reaches zero (and Free does not work for them) Shouldn't Free be usable as a finalizer, clearing all references to other objects within this instance? One could do that (for now I've chosen the simple way). One would however need to check how this would be implemented best (e.g. it should be marked somehow so that the destructor later on does not try to work with already finalized fields; also all fields (Strings, arrays, interfaces, records, etc.) should be finalized so that it is consistent). A finalizer must clear all managed fields, otherwise memory management were corrupted. Doing so may destroy other managed objects, so that possible consequences must be considered. I wonder whether the sequence of clearing fields may cause trouble? Also it needs to be observed how other reference holders might react to that zombie instance. Right, this should be considered by the developer. A further problem might be legacy code which gets passed a reference counted instance (on which ARCIncRef was called to keep it alive) and which then calls Free. Might not be the intended result by neither code... This might be the reason of Embarcadero to implement Free as a no-op and add a new DisposeOf which does what you suggested. Then Delphi compatibility has to be maintained. Is DisposeOf fully automatic, or can it be overridden or otherwise influenced (field sequence...)? DoDi ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proof of Concept ARC implementation
On 26.10.2014 10:44, Hans-Peter Diettrich wrote: A further problem might be legacy code which gets passed a reference counted instance (on which ARCIncRef was called to keep it alive) and which then calls Free. Might not be the intended result by neither code... This might be the reason of Embarcadero to implement Free as a no-op and add a new DisposeOf which does what you suggested. Then Delphi compatibility has to be maintained. Is DisposeOf fully automatic, or can it be overridden or otherwise influenced (field sequence...)? The current implementation isn't Delphi compatible anyway, because in Delphi TObject is itself reference counted. DisposeOf merely calls the destructor and marks the object as disposed of (either by using a Boolean field that is part of TObject or by misusing the topmost bit of the reference count, I don't know). This way the destructor isn't called a second time once the reference count really reaches 0. Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proof of Concept ARC implementation
On Sun, Oct 26, 2014 at 8:32 AM, Sven Barth pascaldra...@googlemail.com wrote: Definitely not. We are in Pascal and there such directives are placed afterwards. But there are tons of left-sided keywords, like specialize, const, pointer, array, file, var, out, etc. And as i said, weak Foo reads better than Foo weak which sounds like Yodaspeak :-P ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Proof of Concept ARC implementation
On 26.10.2014 12:17, Kostas Michalopoulos wrote: On Sun, Oct 26, 2014 at 8:32 AM, Sven Barth pascaldra...@googlemail.com mailto:pascaldra...@googlemail.com wrote: Definitely not. We are in Pascal and there such directives are placed afterwards. But there are tons of left-sided keywords, like specialize, const, pointer, array, file, var, out, etc. And as i said, weak Foo reads better than Foo weak which sounds like Yodaspeak :-P - specialize: ok, that is a prefix - const, var, out: all three introduce sections where multiple elements can be const, var or out - file, array: they are typenames which have the specific types (of XYZ) as a suffix - pointer: not a keyword Regards, Sven ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel