Reading about D: few questions

Jonathan M Davis jmdavisProg at
Fri Dec 23 17:02:19 PST 2011

The core problem for a number of these situations is how types are handled 
with regards to expressions. In an expression such as

char[] arr = s ~ '.';

the type of the value being assigned is determined _before_ the assignment is 
done. So, even though in theory the compiler could make it work, it doesn't, 
because by the time it's looking at the type being assigned to, it's too late. 
There would need to be a fundamental change in how the language functions in 
order to fix issues like this.

pure can do it when it can not because it's able to look at what the return 
type is and changing the result of the expression accordingly but because it 
has guarantees which make it so that it knows that the return value could be 
converted to any level of constness and still be valid. The types used in the 
expressions internally are generally irrelevant.

So, while I completely agree that it would be an improvement if the compiler 
did a better job with implicit conversion when it could theoretically be done, 
I'm not sure how much of that we're actually going to end up seeing simply 
because of how the language and type system works in terms of the order of 

- Jonathan M Davis

More information about the Digitalmars-d-learn mailing list