[Dlang-internal] DIP1000 discussion and testing

Walter Bright via Dlang-internal dlang-internal at puremagic.com
Mon Oct 24 15:47:56 PDT 2016


On 10/24/2016 3:10 PM, Mathias Lang wrote:
> `scope o = new Object;`
> If you prefer to compare it to `nothrow` or `pure`, that's also fine by me.
> I still don't know of any place where an attribute can be added to a
> pre-existing variable declaration.

You're right, that is a bit of a special case, inherited from D1. But storing it 
on the stack is an optimization, it behaves "as if" it was allocated on the heap.


> I see both inference as getting in the way of code readability if not requested
> by the user explicitly.

At this point, we'll just have to disagree on that.


> Could you explain the value there is in not checking `scope` in `@system` ?

Quick and dirty code, for one.


> Also, how does that value offset the user confusion and possible bugs caused by
> people trying to use `scope` in `@system` code without realizing it doesn't do
> any check ?

It still checks the interface.


> Quick note: I notice you said `@system`. The DIP said "only checked in @safe
> code". Will @trusted by checked ?

No, because @trusted code is system code.


> Also, I don't quite see what @safe has to do with code lifetime,

Wouldn't you want to take more care when you write code that will be used for 
years, rather than some throwaway piece of code?


 >  or collaboration.

Because it enables your collaborators to understand your code better.


More information about the Dlang-internal mailing list