On 12/10/2011 12:27 PM, Walter Bright wrote:
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.

I think the design might contain a bug and should be revisited.

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.

What is the benefit of having this apparent mis-feature?
It is similar to having the calling conventions of a function depend on the actual arguments instead of the formal parameters. It would likely result in a segmentation fault. For templates, luckily the compiler only blows up with an error message in counter-intuitive ways. I think there must be a very good reason to keep this.

Reply via email to