Why D const is annoying

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Dec 10 11:12:06 PST 2011


On 12/10/11 5:27 AM, 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.

The design is wrong.

> The type of the
> instantiation is based on the argument types, not the parameter types.

This is wrong. The type of parameter is size_t, no two ways about it. It 
is NOT alias.

> (Note that "2" is the argument and "N" is the parameter.)

Not that N has type size_t.

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

The message reflects a mistake.

>> (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.

They shouldn't.


Andrei


More information about the Digitalmars-d mailing list