DMD 2.100, bring ont he attribute soup
Nick Treleaven
nick at geany.org
Fri May 27 14:36:25 UTC 2022
On Friday, 27 May 2022 at 09:43:02 UTC, Nick Treleaven wrote:
> On Thursday, 26 May 2022 at 22:54:22 UTC, deadalnix wrote:
>>
>> If immutable instead meant immutable in most places, you you
>> can mutate it with this weird construct, then it is
>> effectively useless as a language construct, because it
>> restrict my expressiveness on one axis without granting me
>> greater expressiveness on another.
>
> scope actually does allow that. Any local heap allocation only
> passed to scope parameters can be allocated on the stack
> instead of the heap.
>
> void f(scope T);
>
> T v = new T; // can be stack allocated
> f(v);
To finish my point, scope allows using `new` in @nogc functions.
And it enables allocation optimizations, so scope can't just be
for a static analyzer.
More information about the Digitalmars-d
mailing list