Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/2/20 1:57 PM, ag0aep6g wrote: 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 referen

Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread ag0aep6g via Digitalmars-d-learn
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

Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/2/20 1:32 PM, Dennis wrote: On Sunday, 2 February 2020 at 18:18:28 UTC, Steven Schveighoffer wrote: scope should have been a type constructor. I feel the same way, I find const/immutable much easier to reason about than scope in its current state. Do you think scope as a storage class is

Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread ag0aep6g via Digitalmars-d-learn
On 02.02.20 19:18, Steven Schveighoffer wrote: On 2/2/20 10:20 AM, ag0aep6g wrote: [...] void main() @safe { int* a0; scope int** b0 = &a0; /* accepted */ scope int* a2; scope int** b2 = &a2; /* rejected */ } Now it's important to realize tha

Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread Dennis via Digitalmars-d-learn
On Sunday, 2 February 2020 at 18:18:28 UTC, Steven Schveighoffer wrote: scope should have been a type constructor. I feel the same way, I find const/immutable much easier to reason about than scope in its current state. Do you think scope as a storage class is fundamentally broken, or is it s

Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread Dennis via Digitalmars-d-learn
Thanks for your response. On Sunday, 2 February 2020 at 15:20:39 UTC, ag0aep6g wrote: Now it's important to realize that `scope` only applies to the top-level of the type. This is where my confusion was. I knew scope wasn't transitive, so I thought that `scope string[1]` meant the static arra

Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/2/20 10:20 AM, ag0aep6g wrote: On 02.02.20 14:40, Dennis wrote: Compiling the following with -dip1000 gives an error. ``` void main() @safe { string[1] a0; scope int[1] a1; scope string[1] a2; scope string[] b0 = a0[]; // Fine scope int[] b1 = a1[]; // Fine s

Re: Cannot take slice of scope static array in @safe code

2020-02-02 Thread ag0aep6g via Digitalmars-d-learn
On 02.02.20 14:40, Dennis wrote: Compiling the following with -dip1000 gives an error. ``` void main() @safe {     string[1] a0;     scope int[1] a1;     scope string[1] a2;     scope string[] b0 = a0[]; // Fine     scope int[] b1 = a1[]; // Fine     scope string[] b2 = a2[]; // Error: ca

Cannot take slice of scope static array in @safe code

2020-02-02 Thread Dennis via Digitalmars-d-learn
Compiling the following with -dip1000 gives an error. ``` void main() @safe { string[1] a0; scope int[1] a1; scope string[1] a2; scope string[] b0 = a0[]; // Fine scope int[] b1 = a1[]; // Fine scope string[] b2 = a2[]; // Error: cannot take address of scope local a2 }