Scope statement

Michel Fortin michel.fortin at michelf.com
Tue Feb 5 19:11:39 PST 2008


On 2008-02-05 20:00:38 -0500, Lars V <nospamplease at nospam.com> said:

> Only one more question;
> the deterministic destruction of the object -using scope or delete- 
> will force the GC to collect it? or it'll only call the destructor?

It'll call the destructor and free the memory, but I wouldn't say it's 
the garbage collector that does it in this case.

Note that when you use scope, the compiler may optimise things and 
allocate the object directly on the stack. In this case, the destructor 
is (implicitly) called but there is no memory that needs to be freed 
after the function call.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d-learn mailing list