Flatten a range of static arrays

Steven Schveighoffer schveiguy at gmail.com
Sat Feb 8 14:57:21 UTC 2020


On 2/7/20 8:38 PM, ag0aep6g wrote:

> If that code were allowed, you could do this:
> 
> ----
> struct Joiner
> {
>      Joiner* p;
> }
> Joiner g;
> void main() @safe
> {
>      scope Joiner j;
>      () @trusted { j.p = &j; } (); /* pretend it's allowed */
>      g = *j.p; /* dereference and copy */
> }
> ----
> 
> Returning a copy of a dereferenced `scope` pointer is always allowed, 
> because `scope` only provides one level of protection.

Again, the limitations of dip1000 are apparent. Why can't I mark p as 
only pointing at scope data? And in which cases do I need to do this (in 
the true Joiner code)?

This kind of stuff is so difficult to reason about and develop as a 
library that people will just end up removing dip1000 from their 
compilation.

-Steve


More information about the Digitalmars-d-learn mailing list