DIP1000: Scoped Pointers
Joseph Rushton Wakeling via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Sat Aug 13 01:13:35 PDT 2016
On Friday, 12 August 2016 at 19:37:47 UTC, Walter Bright wrote:
> That's just what this DIP addresses.
>
> struct MyWrapperStruct (T)
> {
> private T* data;
>
> public this (ref T input)
> {
> this.data = &input; // error: not allowed to take
> address of ref variable
> }
> }
>
> The DIP does not add ownership annotations or semantics.
Unless I've misunderstood you, that doesn't address my use-case
-- it outright bans it!
The above code is unsafe only if the lifetime of `data` outlives
the lifetime of `input`. Surely the new scope rules should be
able to distinguish the cases? If that's already envisioned, how
would that work?
BTW, the application here is a design that Dicebot and I have
been discussing since DConf 2015 to address the concerns related
to range implementations of random number generation and random
algorithms.
More information about the Digitalmars-d-announce
mailing list