Persistent list

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 16 07:04:25 PST 2015


On Monday, 16 November 2015 at 14:45:35 UTC, Andrei Alexandrescu 
wrote:
> On 11/16/2015 08:51 AM, Marc Schütz wrote:
>> On Monday, 16 November 2015 at 02:26:29 UTC, Andrei 
>> Alexandrescu wrote:
>>> Yah, I agree with that argument. Probably @mutable is a more
>>> principled way to go about things.
>>
>> Glad to here that. I think the current transitive const system 
>> is really
>> good and shouldn't be watered down beyond necessity. And a 
>> @mutable
>> keyword, too, shouldn't just mean "immutability or const-ness 
>> end here",
>> thus allowing any kind of mutation. What we actually need for
>> immutable/const refcounting etc. is _non-observable mutation_, 
>> i.e.
>> physical mutability, but without observable effects outside of 
>> the
>> type's implementation (better yet, restricted to very short 
>> parts of it,
>> just like @trusted).
>
> The challenge is proving that a mutation is not observable. Got 
> an attack on that? -- Andrei

That would be a neat trick. As I recall, previous discussions on 
logical const concluded that there was no way to implement it in 
a way that guaranteed that it was actually logical const as 
opposed to just being mutated in spite of being const. But it 
would be _very_ cool if someone figured out how to do it.

Still, even without that guarantee, using something like @mutable 
rather than casting would be far safer - especially if the type 
system can guarantee that such an object can't be immutable.

- Jonathan M Davis


More information about the Digitalmars-d mailing list