[Dlang-internal] DIP1000 discussion and testing

Walter Bright via Dlang-internal dlang-internal at puremagic.com
Mon Oct 24 14:30:50 PDT 2016


On 10/24/2016 2:11 PM, Mathias Lang wrote:
> 1) As highlighted in the previous post, we should not change the STC / type of a
> declaration after it is declared. It's a can of worms and will break in many ways.

The definition of a storage class is a bit fuzzy. 'scope' does not say where the 
variable is stored - it does not say "put it on the stack", "put it in the code 
segment", "put it on the heap". It's more of an attribute, just like nothrow, 
pure, etc.


> 2) I don't know a single place in the language where a single "something" (type
> / attributes / STC) is infered. It's either all or nothing (e.g. you cannot have
> a function infering safety but not infering nothrow / @nogc, short of tricking
> the compiler by changing the function's code). Also, I don't know of a single
> place in the language where a type provided explicitly is infered. For example,
> if you do `char[] s = "Hello World";`, `const` or `immutable` is not infered,
> and you get an error, and that's a good thing. Changing it would make code way
> less readable and harder to reason about.

'scope' is not a type, although it does affect function type signatures the same 
as @safe, pure, nothrow and @nogc do, as well as affecting 
covariance/contravariance in an equivalent manner.



More information about the Dlang-internal mailing list