[Issue 2070] DMD should allow easy creation of stack-allocated classes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 13 06:14:19 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2070
------- Comment #4 from schveiguy at yahoo.com 2008-08-13 08:14 -------
(In reply to comment #2)
> and from the spec, scope attribute is only for RAII
> http://www.digitalmars.com/d/1.0/attribute.html#scope
>
> "The scope attribute is used for local variables and for class declarations.
> For class declarations, the scope attribute creates a scope class. For local
> declarations, scope implements the RAII (Resource Acquisition Is
> Initialization) protocol. This means that the destructor for an object is
> automatically called when the reference to it goes out of scope. The destructor
> is called even if the scope is exited via a thrown exception, thus scope is
> used to guarantee cleanup."
>
> but from a quick test, it's on the stack! why the spec didn't mention this?
It's in the spec. Go to http://www.digitalmars.com/d/2.0/expression.html and
search for scope.
(In reply to comment #3)
> I think he was making a proposal. The same one, in fact, the only difference is
> "delete" keyword used instead of "scope".
>
> But foo(scope new Bar()) is far more intuitive than foo(delete new Bar()) to
> me.
Me too.
-Steve
--
More information about the Digitalmars-d-bugs
mailing list