Thread overview
[Issue 14492] Deprecate scope for allocating classes on the stack
Apr 24, 2015
Jonathan M Davis
Apr 24, 2015
yebblies
Apr 24, 2015
Jonathan M Davis
Apr 24, 2015
Andrej Mitrovic
Apr 24, 2015
yebblies
Feb 10, 2018
Iain Buclaw
Feb 10, 2018
Jonathan M Davis
Feb 15, 2022
RazvanN
April 24, 2015
https://issues.dlang.org/show_bug.cgi?id=14492

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc

--- Comment #1 from bearophile_hugs@eml.cc ---
Is this feature not used in Phobos?

--
April 24, 2015
https://issues.dlang.org/show_bug.cgi?id=14492

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #2 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
(In reply to bearophile_hugs from comment #1)
> Is this feature not used in Phobos?

The only place that I see it in Phobos is in a bit of code in std.datetime that Kenji refactored a while back. No idea what it's used there. Something to do with the windows registry. There might be a couple of other places, but it's quite rare. Part of that though is the fact that classes are quite rare in Phobos.

The only official place that I'm aware of where scope is used much at all is in ddmd. I expect that it will be trivial to remove it entirely from Phobos, but I don't know what it'll take to remove it from ddmd.

--
April 24, 2015
https://issues.dlang.org/show_bug.cgi?id=14492

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com

--- Comment #3 from yebblies <yebblies@gmail.com> ---
As Jonathan said, it's used in DDMD.  What we really need is a way to make it @safe, not deprecating it.

--
April 24, 2015
https://issues.dlang.org/show_bug.cgi?id=14492

--- Comment #4 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
(In reply to yebblies from comment #3)
> As Jonathan said, it's used in DDMD.  What we really need is a way to make it @safe, not deprecating it.

Why aren't you using std.typecons.scoped? In theory, at least, that's supposed to replace all uses of scope classes. But regardless, I don't see how you could possibly make it @safe without somehow guaranteeing that no reference to the object escapes, and I'd be surprised if you could talk Andrei into thinking that scope should stay. I'm not sure what Walter's take on it would be though. But it _was_ decided some time ago that scope classes were being gotten rid of, so it's not like this is new.

--
April 24, 2015
https://issues.dlang.org/show_bug.cgi?id=14492

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com

--- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
(In reply to Jonathan M Davis from comment #4)
> (In reply to yebblies from comment #3)
> > As Jonathan said, it's used in DDMD.  What we really need is a way to make it @safe, not deprecating it.
> 
> Why aren't you using std.typecons.scoped? In theory, at least, that's supposed to replace all uses of scope classes. But regardless, I don't see how you could possibly make it @safe without somehow guaranteeing that no reference to the object escapes, and I'd be surprised if you could talk Andrei into thinking that scope should stay. I'm not sure what Walter's take on it would be though. But it _was_ decided some time ago that scope classes were being gotten rid of, so it's not like this is new.

Let's fix scoped!() first. See Issue #10921

--
April 24, 2015
https://issues.dlang.org/show_bug.cgi?id=14492

--- Comment #6 from yebblies <yebblies@gmail.com> ---
(In reply to Jonathan M Davis from comment #4)
> (In reply to yebblies from comment #3)
> > As Jonathan said, it's used in DDMD.  What we really need is a way to make it @safe, not deprecating it.
> 
> Why aren't you using std.typecons.scoped? In theory, at least, that's supposed to replace all uses of scope classes. But regardless, I don't see how you could possibly make it @safe without somehow guaranteeing that no reference to the object escapes, and I'd be surprised if you could talk Andrei into thinking that scope should stay. I'm not sure what Walter's take on it would be though. But it _was_ decided some time ago that scope classes were being gotten rid of, so it's not like this is new.

To avoid depending on phobos, for now.  If we get some form of 'scope' in the language eventually we will hopefully be able to use it safely again.

--
February 10, 2018
https://issues.dlang.org/show_bug.cgi?id=14492

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@gdcproject.org

--- Comment #7 from Iain Buclaw <ibuclaw@gdcproject.org> ---
DDMD still depends on this heavily.  For now scope class is going nowhere, if the idea of deprecating it hasn't already been completely reversed.

--
February 10, 2018
https://issues.dlang.org/show_bug.cgi?id=14492

--- Comment #8 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
(In reply to Iain Buclaw from comment #7)
> DDMD still depends on this heavily.  For now scope class is going nowhere, if the idea of deprecating it hasn't already been completely reversed.

If I understand DIP 1000 correctly, I think that the original meaning of scope on class reference is basically becoming an optimization done with scope rather than the direct purpose of the feature, and the work with DIP 1000 should in theory make it @safe. So, if DIP 1000 is accepted (and I assume it will be once it's ready, since it's Walter who's doing it, and he's spent a lot of time on it), then scope on class references is here to stay.

--
February 15, 2022
https://issues.dlang.org/show_bug.cgi?id=14492

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WONTFIX

--- Comment #9 from RazvanN <razvan.nitu1305@gmail.com> ---
Yes, scope on class references is here to stay since there is no other way to express that a reference to a class should not escape the current scope.

--