@safe RCSlice with DIP1000 + runtime checks
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 3 04:07:27 PDT 2016
On Friday, 2 September 2016 at 11:18:58 UTC, Nick Treleaven wrote:
> RCRef increments *RCSlice.count on construction and decrements
> on destruction, but first checks that *count is > 1. If this
> fails, an AssertError is thrown. When -noboundschecks is
> passed, the code assumes no safety checks should be made for
> RCSlice and compiles out all the additional counting code.
BTW a similar approach would be to hold a RCSlice in the RCRef
temporary, which is less efficient but causes no runtime errors.
My way the user has to make their own temporary RCSlice copies
when necessary.
> Of course it would be great to have compile-time checks, so I'm
> looking forward to a DIP for that.
(Actually I meant automatic creation of temporary RC objects when
the compiler detects that they're necessary).
More information about the Digitalmars-d
mailing list