DMD 2.100, bring ont he attribute soup

deadalnix deadalnix at gmail.com
Fri May 27 21:09:49 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);

I don't think this is a valid optimization, because DIP1000 
cannot track indirections. Therefore, I could have an objects 
within the subgraph reachable from `v` which escape and which 
itself can reaches back to `v`.

In the case it is possible to optimize, LDC can already do it.

DIP1000 is of no help here.


More information about the Digitalmars-d mailing list