Want reasonable reference counting? Disable automatic sharing of immutable

rikki cattermole rikki at cattermole.co.nz
Mon Nov 15 22:00:51 UTC 2021


On 16/11/2021 10:38 AM, Ola Fosheim Grøstad wrote:
> On Monday, 15 November 2021 at 21:30:29 UTC, rikki cattermole wrote:
>> const and immutables are compiler guarantees, and we shouldn't be 
>> wanting the compiler to lie to us in our misunderstandings.
> 
> Hm, ```immutable```, ```const```, and ```pure``` are arbitrary symbols 
> that means nothing more than what an updated language spec claim. Of 
> course, one might argue that it is bad usability!
> 
> Also, you have to be in ```@trusted``` to change the setting of memory 
> pages, and in ```@trusted``` you basically take upon yourself to uphold 
> the spec (which involves a strong element of *hubris* given that few 
> programmers know the full language semantics).
> 
> So that is basically the key issue. For ```@trusted``` to make sense, 
> the type system has to be simple and intuitive.
> 
> So, I disagree, but I agree. :)

Oh yeah, all these guarantees go out the window for @system and @trusted 
code!

But at least you have to cast and do something naughty to do it, which 
is a good thing if it involves a potential crash.

What matters is that const/immutable won't let you do something naughty, 
without you actually proving that you want to do it.

So at least then @safe is still @safe ;)


More information about the Digitalmars-d mailing list