Re: Object destruction versus finalization

2013-11-14 Thread Florian
Michael, thank you for these links. Regards, Florian.

Re: Object destruction versus finalization

2013-11-13 Thread Michael
Additional discussions http://forum.dlang.org/thread/jpl93e$1mns$1...@digitalmars.com and http://forum.dlang.org/thread/l3dj7b$2tvc$1...@digitalmars.com

Re: Object destruction versus finalization

2013-11-13 Thread Florian
Jonathan, Dicebot, thank you very much for your response. So you are confirming my conclusion, that finalizers/destructors in D work pretty much like in C++ and there is no way to do Java/C#/Managed C++-like finalization. For the records, since Dicebot asked: I am using DMD32 v2.063.2 on De

Re: Object destruction versus finalization

2013-11-12 Thread Dicebot
On Tuesday, 12 November 2013 at 22:40:26 UTC, Florian wrote: The example below prints the following output: ~Connection ~Session segmentation fault Same example prints this for me (no segfault): ~Session shutdown ~Connection 2.064.2 @ linux-64 What is your system / compiler? Outp

Re: Object destruction versus finalization

2013-11-12 Thread Dicebot
On Tuesday, 12 November 2013 at 23:18:11 UTC, Jonathan M Davis wrote: You can't do that in finalizer, because the GC can choose to free it before the finalizer even runs (this avoids issues with circular references). Ah, damn, have forgotten about it. Disregard previous post.

Re: Object destruction versus finalization

2013-11-12 Thread Jonathan M Davis
On Wednesday, November 13, 2013 00:07:12 Florian wrote: > I understood very well, that the garbage collector is not > guaranteed to run. However, it does not explain the segmentation > fault in my example, does it? You're getting a segfault, because you're using something which is on the GC heap

Re: Object destruction versus finalization

2013-11-12 Thread Florian
I understood very well, that the garbage collector is not guaranteed to run. However, it does not explain the segmentation fault in my example, does it?

Re: Object destruction versus finalization

2013-11-12 Thread Jonathan M Davis
On Tuesday, November 12, 2013 23:40:24 Florian wrote: > it would be possible to move the shutdown() sequence into the > destructor of the "Connection" class. Classes in D do not have destructors. Only structs to. ~this is a destructor in a struct, but it's a finalizer in a class. Finalizers are n

Re: Object destruction versus finalization

2013-11-12 Thread Florian
On Tuesday, 12 November 2013 at 20:29:13 UTC, Dicebot wrote: On Tuesday, 12 November 2013 at 20:15:02 UTC, Florian wrote: I played around a little and figured out, that destructors in D work quite similarily to destructors in C++. They are invoked, after the members of the instance being destru

Re: Object destruction versus finalization

2013-11-12 Thread Dicebot
On Tuesday, 12 November 2013 at 20:15:02 UTC, Florian wrote: I played around a little and figured out, that destructors in D work quite similarily to destructors in C++. They are invoked, after the members of the instance being destructed have been destroyed themselfes (or at least have been br

Object destruction versus finalization

2013-11-12 Thread Florian
I played around a little and figured out, that destructors in D work quite similarily to destructors in C++. They are invoked, after the members of the instance being destructed have been destroyed themselfes (or at least have been brought into an invalid state). Therefore, these members cannot