<p dir="ltr"></p>
<p dir="ltr">On 16 Aug 2016 21:01, "Dicebot via Digitalmars-d-announce" <<a href="mailto:digitalmars-d-announce@puremagic.com">digitalmars-d-announce@puremagic.com</a>> wrote:<br>
><br>
> On Tuesday, 16 August 2016 at 18:55:40 UTC, Dicebot wrote:<br>
>><br>
>> On Tuesday, 16 August 2016 at 18:25:42 UTC, Meta wrote:<br>
>>><br>
>>> What about this?<br>
>>><br>
>>> struct Rnd<br>
>>> {<br>
>>>     int* state;<br>
>>> }<br>
>>><br>
>>> void test()<br>
>>> {<br>
>>>     scope rnd = new Rnd();<br>
>>>     Rnd rnd2 = *rnd;<br>
>>><br>
>>>     saveGlobalState(rnd2);<br>
>>> }<br>
>><br>
>><br>
>> Same as far as I understand, because "from a lifetime analysis viewpoint, a struct is considered a juxtaposition of its direct members" (<a href="https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#aggregates">https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#aggregates</a>). You need to add one more level of indirection for things to start going complicated.<br>
><br>
><br>
> Ah no, sorry, I have missed that you allocate struct on heap. Yes, this is simplified problem case indeed. Intention is that such struct can be made @safe by making all pointer fields private and adding scope semantics in getter methods but it is hard to reason about details at this point.</p>
<p dir="ltr">It will be nice to see a set of tests that are expected to pass, a set that are expected to fail, and a set that segfault.</p>
<p dir="ltr">In my questions I was trying to make small examples, that could become tests. </p>
<p dir="ltr">The examples in the DIP are quite simple actually. The pointer escaping example is what I was missing. <br>
</p>