'scope' confusion

Dom DiSc dominikus at scherkl.de
Fri Apr 15 10:31:31 UTC 2022


On Friday, 15 April 2022 at 06:12:06 UTC, Paul Backus wrote:
> No, because `scope` isn't transitive. [...]
> That example does work. It's only when you get to two levels of 
> indirection that it fails; for example:
>
> ```d
> @safe @nogc pure nothrow:
>
> void f() {
> 	int x = 0;
> 	scope int* y = &x;
> 	scope int** z = &y; // error
> }
> ```

     If it's not transitive, perhaps we need something to make it 
explicit:
     ```d
     void f() {
        int x = 0;
        scope int* y = &x;
        scope int* scope* z = &y; // like const* in C++
     }
     ```




More information about the Digitalmars-d mailing list