Rebooting the __metada/__mutable discussion

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Mon Apr 11 11:46:42 UTC 2022


On Sunday, 10 April 2022 at 23:12:03 UTC, rikki cattermole wrote:
>
> On 11/04/2022 3:04 AM, Alexandru Ermicioi wrote:
>> Isn't better then to try and find design patterns or rules for 
>> use with mutable RC structures?
>
> Yes.
>
> But if the compiler allows RC to become const and not allow RC 
> to occur, that is a bad situation to be in...

This seems like a couple of edge cases and bugs that need to be 
rectified, in order to have proper safe mutable only RC structs. 
You should be able to disallow implicit cast to const of struct 
if it is desired to do so.

>
> That is what my test code above does, it prevents you from 
> using it with const as much as possible.
>
> It is a workaround to a much larger problem.

Regarding const rc use, I think there can be a limited access to 
the payload, if you somehow prohibit taking the address of the 
payload or it's sub-elements. Perhaps instead of returning 
payload itself from rc struct, maybe it can be wrapped into a 
wrapper, that prevents any take of address when a field is 
accessed from payload, or payload itself.


More information about the Digitalmars-d mailing list