Is @safe still a work-in-progress?

Atila Neves atila.neves at gmail.com
Tue Aug 21 14:31:02 UTC 2018


On Tuesday, 21 August 2018 at 00:09:03 UTC, Walter Bright wrote:
> On 8/20/2018 6:46 AM, Steven Schveighoffer wrote:
>> I would, but I have no idea how dip1000 is supposed to work. I 
>> think only you understand it. Even looking at the PR that you 
>> have been citing over and over, I can't make heads or tails of 
>> what it does or what it allows.
>
> The way to understand dip1000 is to forget about `this`, 
> arrays, structs, classes, delegates, etc. Just think about 
> pointers - functions that take pointers as arguments, and 
> return pointers.
>
> That simplifies things enormously.
>
> Once that makes sense, then deconstruct the higher level 
> constructs into pointers, and then you'll see how they work.
>
> This is why my presentation does it all in terms of pointers:
>
>     http://dconf.org/2017/talks/bright.html
>
> If you're having trouble understanding a particular example, 
> rewrite it in terms of pointers. If it still is inscrutable, 
> then ask about the pointer version here.
>
> (When someone gives me some complex thing and says "I don't 
> understand scope here", I always first rewrite it in terms of 
> pointers. It's the same thing I do with bug reports that use 
> templates - I manually instantiate the templates first.)

The problem is that the code we write doesn't deal directly with 
pointers - see the recent confusion in this forum over where 
`scope` on the left applies to the `this` pointer or the one 
returned by the member function.

Kagamin just told me I needed to use `return` instead of `scope` 
to get things to work and I'm still not sure why.

Also: destructors? Always `scope`? Sometimes? I just add `scope` 
when the compiler complains at this point.

I think it's interesting that when I played with Rust I didn't 
have problems fighting the borrow checker at all. DIP1000 is 
supposed to have the same safety without the Rust complications 
but currently Rust is much easier to understand for me.

It doesn't help that the current implementation of -dip1000 
doesn't match the document it's supposedly based on.


More information about the Digitalmars-d mailing list