digitalmars.D.learn - "scope attribute" vs "scope keyword" vs "scope storage class"
- Mike (10/10) Feb 05 2014 This article (http://dlang.org/memory.html#raii) mentions a
- Stanislav Blinov (4/6) Feb 05 2014 "scope keyword" and "scope storage class" stay:
- Cooler (4/14) Feb 05 2014 Did you read "Rational" paragraph?
- Dicebot (11/21) Feb 05 2014 D documentation has rather incosistent naming for attribute
- Kagamin (3/4) Feb 06 2014 It's the same meaning as for scope classes though. And the same
- Brad Anderson (5/12) Feb 06 2014 Couldn't "scope" allocating a class on the stack just be
- Dicebot (5/21) Feb 06 2014 I think so. Scope classes were unsafe because of leaking
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (8/16) Feb 07 2014 If you declare something as scope, it is expected to have its
This article (http://dlang.org/memory.html#raii) mentions a "scope attribute". The following section (http://dlang.org/memory.html#stackclass) mentions a "scope storage class". This deprecated list (http://dlang.org/deprecate.html#scope%20for%20allocating%20classes 20on%20the%20stack) states that the "scope keyword" has been deprecated. Are all these terms ("scope attribute", "scope keyword", and "scope storage class") referring to the same thing? Mike
Feb 05 2014
On Wednesday, 5 February 2014 at 11:01:00 UTC, Mike wrote:Are all these terms ("scope attribute", "scope keyword", and "scope storage class") referring to the same thing?"scope keyword" and "scope storage class" stay: http://dlang.org/function.html#parameters Although AFAIK it's not yet implemented.
Feb 05 2014
On Wednesday, 5 February 2014 at 11:01:00 UTC, Mike wrote:This article (http://dlang.org/memory.html#raii) mentions a "scope attribute". The following section (http://dlang.org/memory.html#stackclass) mentions a "scope storage class". This deprecated list (http://dlang.org/deprecate.html#scope%20for%20allocating%20classes 20on%20the%20stack) states that the "scope keyword" has been deprecated. Are all these terms ("scope attribute", "scope keyword", and "scope storage class") referring to the same thing? MikeDid you read "Rational" paragraph? "Note that scope for other usages (e.g. scoped variables) is unrelated to this feature and will not be deprecated."
Feb 05 2014
On Wednesday, 5 February 2014 at 11:01:00 UTC, Mike wrote:This article (http://dlang.org/memory.html#raii) mentions a "scope attribute". The following section (http://dlang.org/memory.html#stackclass) mentions a "scope storage class". This deprecated list (http://dlang.org/deprecate.html#scope%20for%20allocating%20classes 20on%20the%20stack) states that the "scope keyword" has been deprecated. Are all these terms ("scope attribute", "scope keyword", and "scope storage class") referring to the same thing? MikeD documentation has rather incosistent naming for attribute groups. - scope classes are deprecated, but usage of scope as storage class is still legal (it is expected to be a no-op for now) - scope storage class for function parameters is also accepted as no-op. For delegates it actually has a meaning. No deprecation. - scope statement as in scope(exit) was never suggested to be deprecated. - scope attribute most likely refers to declaration of scope classes and this is deprecated with them
Feb 05 2014
On Wednesday, 5 February 2014 at 15:43:45 UTC, Dicebot wrote:For delegates it actually has a meaning. No deprecation.It's the same meaning as for scope classes though. And the same unsafety.
Feb 06 2014
On Wednesday, 5 February 2014 at 15:43:45 UTC, Dicebot wrote:D documentation has rather incosistent naming for attribute groups. - scope classes are deprecated, but usage of scope as storage class is still legal (it is expected to be a no-op for now)Couldn't "scope" allocating a class on the stack just be considered an optimization that can be applied if the scope storage class become fully implemented?- scope storage class for function parameters is also accepted as no-op. For delegates it actually has a meaning. No deprecation.No-op just because it hasn't been implemented yet, right?
Feb 06 2014
On Thursday, 6 February 2014 at 19:01:52 UTC, Brad Anderson wrote:On Wednesday, 5 February 2014 at 15:43:45 UTC, Dicebot wrote:I think so. Scope classes were unsafe because of leaking references but if `scope` is actually implemented to assure safety it becomes perfectly valid thing to do.D documentation has rather incosistent naming for attribute groups. - scope classes are deprecated, but usage of scope as storage class is still legal (it is expected to be a no-op for now)Couldn't "scope" allocating a class on the stack just be considered an optimization that can be applied if the scope storage class become fully implemented?Yes. And there is no clear definition either.- scope storage class for function parameters is also accepted as no-op. For delegates it actually has a meaning. No deprecation.No-op just because it hasn't been implemented yet, right?
Feb 06 2014
On Thursday, 6 February 2014 at 22:16:30 UTC, Dicebot wrote:On Thursday, 6 February 2014 at 19:01:52 UTC, Brad Anderson wrote:If you declare something as scope, it is expected to have its destructor called at the end of the scope. Therefore, this behavior needs to be guaranteed. Theoretically of course, the memory could still be allocated on the heap and freed after destruction (or even just marked as destroyed and letting the GC clean it up), but this will probably not have advantages over stack allocation, except maybe for large objects.Couldn't "scope" allocating a class on the stack just be considered an optimization that can be applied if the scope storage class become fully implemented?I think so. Scope classes were unsafe because of leaking references but if `scope` is actually implemented to assure safety it becomes perfectly valid thing to do.
Feb 07 2014