Rebooting the __metada/__mutable discussion

IGotD- nise at nise.com
Wed Apr 6 11:43:58 UTC 2022


On Wednesday, 6 April 2022 at 09:41:52 UTC, RazvanN wrote:
>
> We need this to be able to implement generic reference 
> counting. So our main
> problem is how do we reference count immutable/const objects. 
> Timon's original
> proposal tried to implement __metadata in a way that does not 
> affect purity
> based optimizations. I think that this could be done:

Immutable and mutable variables don't mix well at all. With 
immutable there is a high probability that it ends up in read 
only memory so any poking around there will cause the program to 
crash. Also reference counting with immutable objects doesn't 
make any sense.

When it comes changing data on const objects such as reference 
counting, I think that this is low level code that works under 
the hood of the actual language. This means that you will cast 
away whatever you need in order to get the job done.



More information about the Digitalmars-d mailing list