On 9/26/17 3:14 PM, bitwise wrote:
On Tuesday, 26 September 2017 at 17:27:02 UTC, Steven Schveighoffer wrote:

-Steve


About Variant - I was considering a pull request for retrieving a pointer to the internal data, but figured that it was left out on purpose due to @safety.

OTOH, I was looking through dmd commits, and it seems like there has been significant progress on 'scope'.

So I was thinking this:

struct Variant {

     scope inout(ubyte)[] data() inout
     {
         auto sz = type.tsize;
         assert(sz <= size);
         return store[0..sz];
     }
}

Thoughts?


I just recently fixed Variant so it could accept shared data (so you could pass shared data using std.concurrency), and part of that depends on the fact that I know nothing else can point at the data (so no locking/atomics are necessary, we know the actual data is not shared).

I think it's very dangerous to extract a reference to the data, it breaks all kinds of expectations.

-Steve

Reply via email to