Adam D. Ruppe's "D Cookbook" now available!
Szymon Gatner via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Thu May 29 06:01:49 PDT 2014
On Wednesday, 28 May 2014 at 18:14:28 UTC, Walter Bright wrote:
> http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book
>
> http://www.amazon.com/D-Cookbook-Adam-D-Ruppe/dp/1783287217
>
> http://www.reddit.com/r/programming/comments/26pn00/d_cookbook_officially_published_consists_of_d/
>
> After watching Adam's most excellent presentation at Dconf, I'm
> sure the book will be great! My copy gets here on Friday.
A question(s) regarding Chapter 5: Making a reference-counted
object:
(btw do we need separate thread for content-related questions?)
- point 5 (of How to do it...) says: "... and free the object if
necessary", but then in code:
~this() {
if(data is null) return;
data.refcount--;
writeln("Released. Refcount = ", data.refcount);
if(data.refcount == 0)
writeln("Destroyed.");
}
is actual freeing missing? Or am I missing something?
Later in same chapter: "... or being collected by the garbage
collector—its destructor is called, if present."
Is that really true? My understanding (and unfortunate test) is
that it is never guaranteed that d-tor of GD allocated object is
ever called. If that is the case then: is that true that dynamic
array of RefCountedObject does not guarantee any of d-tors
called? That would also mean that if any of objects in object
graph is GC-allocated then NONE of its child nodes have any
guarantees about destruction?
More information about the Digitalmars-d-announce
mailing list