div0 wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lars T. Kyllingstad wrote:
In D2, what is the effect (if any) of 'scope' in the following situations?
scope int a;
Nothing
http://www.digitalmars.com/d/2.0/attribute.html#scope
"This means that the destructor for an object is automatically called
when the reference to it goes out of scope."
So there are two ways to interpret this:
- primitive types don't have destructors, so it shouldn't compile
- the destructor of a primitive type is nop, so the reason it has no
effect at the moment is
http://d.puremagic.com/issues/show_bug.cgi?id=2483
struct B { ... }
scope B b;
Nothing, B's destructor will be called even without scope.
scope int[] c;
c gets deleted when the scope ends. this applies to classes as well.
<snip>
What gets deleted - the array or the individual objects?
Stewart.