Please fix `.init` property

Hipreme msnmancini at hotmail.com
Fri Jan 12 15:02:42 UTC 2024


On Friday, 12 January 2024 at 09:57:25 UTC, Iain Buclaw wrote:
> On Tuesday, 9 January 2024 at 06:16:42 UTC, FeepingCreature 
> wrote:
>>
>> Yes, the point of making it forced `immutable` is exactly to 
>> make the problematic cases illegal. Don't even think about 
>> deepcopy vs array vs object etc., just let the const system 
>> handle it.
>
> I might be misinterpreting, but it seems like you're suggesting
> ```
> S s;
> s.arr[0] = "imm"; // compile-time error?
> s.arr = ["new"];
> s.arr[0] = "mut"; // ok
> ```
> I'm not seeing how that would fly.
>
> I can imagine it being easier done at runtime - with a bit of 
> extra overhead - using mprotect or tagged pointers.


I see no problem in having runtime overhead for the sake of 
having default initialized arrays in that case :)

I also would not complain if we had a way to choose between the 
extra overhead vs an error message by using an UDA.


More information about the Digitalmars-d mailing list