Dlist and dip1000 challenge

Stanislav Blinov stanislav.blinov at gmail.com
Thu Oct 25 20:14:58 UTC 2018


On Thursday, 25 October 2018 at 13:50:15 UTC, Steven 
Schveighoffer wrote:

> Alarmingly, the current dlist builds fine with dip1000, even 
> though it conceptually is the same thing -- it's just that the 
> casts destroy any tracking of lifetimes (or so my theory goes), 
> so it builds happily. We don't want people to resort to opacity 
> and casts to get around dip1000.

It's the transitivity of `scope` coupled with that other line in 
the spec that just disables errors in non- at safe code.

Lowering your code, conceptually what's happening is that you're 
defining this:

struct Storage(T) {
     void add(scope T x);
}

which means you want to escape 'x'.

Now, I understand that that is not the *intent* of your code, but 
that's what the compiler sees. I'd argue that the "correct" thing 
to do here is leave the range insertion to some OutputRange 
algorithm. Unless we can find a way to define tail-`scope` arrays.


More information about the Digitalmars-d mailing list