DMD 0.150 release

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Wed Mar 22 12:21:33 PST 2006


xs0 wrote:
> Walter Bright wrote:
>> "Kyle Furlong" <kylefurlong at gmail.com> wrote in message
>> news:dvr1n7$2sub$1 at digitaldaemon.com...
>>> And the rest of the post...?
>>
>> Casting is a blunt instrument, you need to be careful with it.
>> Disabling casting is a bad idea, because one needs a way around the
>> type system. 
> 
> So how come you can't cast a double to int delegate(int)? :P
> 
> You can still go via void*, if you want to. But normally, it should be
> forbidden, because the result is both useless and dangerous (in the
> sense that attempting to use it will call some random method). I can't
> believe you don't agree this should be an error; currently it's not even
> a run-time error!?!
> 
> Note that this will be a major minus for anyone coming from Java. There,
> it's completely natural that a FooClass[] can be treated as
> FooInterface[] and Anything[] can be treated as Object[] (the cast is
> even implicit).
> 
Yes, if this is not "fixed", we certainly need some Java->D tutorials
regarding this issue. IMHO all ugly explicit casts should be done behind
the scenes.

> Furthermore, it's quite common to refactor code by making type Whatever
> an interface when it was a class before,

Exactly.

> and while you claim you want D
> to be practical, you obviously expect a coder to manually go through the
> entire code base each time he does that, just in case the type was used
> in a way that won't work anymore.

No! It shouldn't go that way. Usually these casts aren't necessary in
CPU-intensive loops (at least they can be avoided). An extra overhead
from implicit reference handling wouldn't cause much performance loss.



More information about the Digitalmars-d-announce mailing list