The Status of Const
Jonathan M Davis
jmdavisprog at gmail.com
Mon Aug 16 15:57:55 PDT 2010
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.
In any case, converting a collection of one type to a collection of another type
is something that I've never seen done, and I'm not sure that it would be a
desirable feature ultimately. I'm not sure that it should _not_ be possible, but
it would certainly make me nervous. I'd really have to think about the
implications before I agreed that it was a good idea.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list