[Dlang-internal] DIP1000 discussion and testing

Mathias Lang via Dlang-internal dlang-internal at puremagic.com
Mon Oct 24 14:11:06 PDT 2016


On Monday, 24 October 2016 at 20:57:08 UTC, Walter Bright wrote:
> On 10/24/2016 12:30 PM, Walter Bright wrote:
>> Why? D already infers lots of things.
>
> Like @safe, @trusted, @system, @nogc, pure, nothrow, return.
>
> Consider also that Rust does extensive lifetime attribute 
> inference.

Don't get me wrong, I love inference. I am afraid my feedback may 
have mixed up two things, so I'm going to reinstate them here:

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.

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.


More information about the Dlang-internal mailing list