The Status of Const

Simen kjaeraas simen.kjaras at gmail.com
Mon Aug 16 16:06:56 PDT 2010


Jonathan M Davis <jmdavisprog at gmail.com> wrote:

> On Monday, August 16, 2010 15:31:23 Steven Schveighoffer wrote:
>> We can move onto the next test:
>>
>> Given:
>>
>> class C {}
>>
>> class D : C {}
>>
>> convert Array!D into Array!(const C)
>>
>> OK, maybe this is a more advanced test :)
>>
>> I'd be happy with just proper factoring of const to be honest.
>
> Um, I don't think that I've ever seen that work in _any_ language, and  
> I'm not
> sure that it would be a good thing if it did. Array!D is a completely  
> different
> type from Array!C or Array!(const C). I could see an argument that  
> Array!D
> should work as Array!(const D), but that seems off to me. Converting  
> Array!D to
> const (Array!D) should work though.

Uhm, it works in D:

class C {}
class D : C {}

void main( ) {
     D[] a;
     C[] b = a;
}

-- 
Simen


More information about the Digitalmars-d mailing list