Why D const is annoying

Walter Bright newshound2 at digitalmars.com
Sat Dec 10 03:27:41 PST 2011


On 12/10/2011 3:17 AM, Mehrdad wrote:
> Yup, I started using it as soon as Timon mentioned it (thanks for the suggestion!).
> But I was referring to the bug, not to the workaround. :)

It isn't a bug, it is designed to work that way. The type of the instantiation 
is based on the argument types, not the parameter types. (Note that "2" is the 
argument and "N" is the parameter.)

Hence the message:

Error: cannot implicitly convert expression (m) of type Matrix!(int,2) to 
Matrix!(int,N)


> (I don't understand
> why Matrix!(int, cast(int)1) is considered a different instantiation, when it
> can't even be instantiated...)

Yes, it can be instantiated. But it cannot be implicitly converted to type 
Matrix!(int, cast(uint)1) because they are different types.


More information about the Digitalmars-d mailing list