Collections question

Marc Schütz via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 2 05:23:45 PST 2015


On Wednesday, 2 December 2015 at 06:45:33 UTC, deadalnix wrote:
> On Tuesday, 1 December 2015 at 17:27:20 UTC, Andrei 
> Alexandrescu wrote:
>> Ah, the good old assignment to reference. We need to prevent 
>> that from happening in safe code. Got any fresh ideas? -- 
>> Andrei
>
> Disable owner when borrowing 'mutably', and not when borrowing 
> 'constly'.

Making it const is enough, it doesn't need to be disabled 
completely. (Except if you want to go full Rust with uniqueness 
etc.)

Maybe there's a way to relax it further. Not all modifications of 
the owner are necessarily bad... If we limit the restriction to 
types with indirections (or types with destructors?), and only 
apply it in @safe functions, this might not even break much code. 
I suspect that almost all @trusted code, and probably most @safe 
code, will already be written in a way that conforms to the new 
rules.


More information about the Digitalmars-d mailing list