On 02.02.20 19:49, ag0aep6g wrote:
On 02.02.20 19:18, Steven Schveighoffer wrote:
I'm not sure if I got it right, but like this?

     int*[][] g1;
     int*[] g2;
     int* g3;

     void main() @safe
     {
         /* An array stored on the stack, of references to heap data: */
         int*[3] a1 = [new int, new int, new int];
         /* Another such array: */
         int*[3] a2 = [new int, new int, new int];
         /* An array of those arrays, stored on the stack: */
         int*[][2] b = [a1[], a2[]];

         g1 = b[]; /* Nope. */
         g2 = b[0]; /* Nope. */
         g3 = b[0][0]; /* Ok. */
     }

I guess I kinda missed the point there, and what you want is this:

    scope int*[][] slice = b[];
    /* ... use `slice` in non-leaky ways ... */

Which DIP 1000 doesn't allow, because it wouldn't be able to ensure that the references to a1 and a2 don't leak. Yeah, DIP 1000 falls somewhat short.

Reply via email to