Scope Containers

bitwise bitwise.pvt at gmail.com
Fri Mar 15 16:10:45 UTC 2019


On Wednesday, 13 March 2019 at 11:35:02 UTC, Olivier FAURE wrote:
>
> One possibility might be to implement at run time what rust 
> does at compile time, eg make it impossible to mutate vector as 
> long as one or more readable view to its content exists.
>
> So for instance, make opSlice and opIndex return a struct that 
> bumps a reference counter up inside the vector; the counter is 
> bumped down once that struct is destructed. As long as the 
> number of "live" slices is non-zero, the vector isn't allowed 
> to re-allocate.

I'm not 100% sure, but it kinda seeems like this solution 
requires, but is obviated by scope.

> It's supposed to be *impossible* to get a memory corruption in 
> @safe code. Not "convoluted and wouldn't pass code review", 
> impossible. When you write a @trusted function, getting a 
> memory corruption with that function is supposed to be 
> impossible as well.

I agree that @safety should be a strict guarantee.


More information about the Digitalmars-d mailing list