DMD 0.150 release

xs0 xs0 at xs0.com
Wed Mar 22 11:57:55 PST 2006


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

Furthermore, it's quite common to refactor code by making type Whatever 
an interface when it was a class before, 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.


xs0



More information about the Digitalmars-d-announce mailing list