On Friday, 19 May 2017 at 19:46:07 UTC, nkm1 wrote:
I like this proposal... But it looks like people are concerned about 'new' becoming contextual keyword (that in some contexts it allocates with GC and in others it does something else)

It *already* does that. `new` can be overloaded and modified with `scope`.

http://dlang.org/spec/expression.html

"NewExpressions are used to allocate memory on the garbage collected heap (default) or using a class or struct specific allocator. "

"If a NewExpression is used as an initializer for a function local variable with scope storage class, and the ArgumentList to new is empty, then the instance is allocated on the stack rather than the heap or using the class specific allocator. "


I also believe the compiler *should* be free to optimize it to a different allocation scheme if it proves it safely can.

Reply via email to