classes by value

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Dec 15 12:56:41 UTC 2017


On Friday, December 15, 2017 11:10:42 Dgame via Digitalmars-d wrote:
> On Friday, 15 December 2017 at 09:18:23 UTC, Seb wrote:
> > On Thursday, 14 December 2017 at 16:40:33 UTC, Petar Kirov
> >
> > [ZombineDev] wrote:
> >> ```
> >> scope foo = new Foo();
> >> ```
> >
> > That's about to be deprecated in favor of scoped!Foo:
> >
> > https://dlang.org/deprecate.html#scope%20for%20allocating%20classes%20on
> > %20the%20stack
> Since scope was revived with DIP-1000 we will see about that. I
> doubt that the deprecation will stay.

DIP 1000 is half killing it. DIP 1000 is using scope for something very
different, and it has nothing to do with putting classes on the stack.
However, as an optimization, it may put a class on the stack if it
determines that the the class object is unique. Anyone who wants to
guarantee it should be using std.typecons.scoped.

- Jonathan M Davis



More information about the Digitalmars-d mailing list