Purity (D2 standard libraries / object.d)
Walter Bright
newshound1 at digitalmars.com
Sat Jan 10 15:39:03 PST 2009
dsimcha wrote:
> In this case, foo.myInvariantArray goes out of scope when foo() returns. When
> bar() allocates an array, it's entirely possible that the GC will give bar.myArray
> the same memory address as foo.myArray had. In this case, if you're only using
> stack bits to handle memoization, you're screwed.
That's the beauty of a garbage collector <g>. The bits will include a
reference to the immutable data, which the gc will see, and so the gc
will not reclaim that data.
More information about the Digitalmars-d
mailing list