Re: D - dynamic_cast only?

2011-12-26 Thread Nick Sabalausky
bearophile bearophileh...@lycos.com wrote in message news:jd6sbg$qb6$1...@digitalmars.com... Steve Teale: My reading of the current documentation on casts leaves me with the impression that D now has only the equivalent of the C++ dynamic_cast. I'd like this in Phobos:

D - dynamic_cast only?

2011-12-25 Thread Steve Teale
I'll try again on this. My reading of the current documentation on casts leaves me with the impression that D now has only the equivalent of the C++ dynamic_cast. This seems unreasonably restrictive given that C++ has traditional C- style cast, dynamic_cast, static_cast, and reinterpret_cast -

Re: D - dynamic_cast only?

2011-12-25 Thread Vladimir Panteleev
On Sunday, 25 December 2011 at 08:37:21 UTC, Steve Teale wrote: I'll try again on this. My reading of the current documentation on casts leaves me with the impression that D now has only the equivalent of the C++ dynamic_cast. This seems unreasonably restrictive given that C++ has

Re: D - dynamic_cast only?

2011-12-25 Thread bearophile
Steve Teale: My reading of the current documentation on casts leaves me with the impression that D now has only the equivalent of the C++ dynamic_cast. I'd like this in Phobos: http://d.puremagic.com/issues/show_bug.cgi?id=5559 Bye, bearophile

Re: D - dynamic_cast only?

2011-12-25 Thread Steve Teale
On Sun, 25 Dec 2011 08:37:21 +, Steve Teale wrote: So what do you think is happening here? ColorSelectionDialog csd = new ColorSelectionDialog(Choose a Color); writefln(csd %s, csd); void* vp = cast(void*) csd.getColorSelection(); ColorSelection cs = cast(ColorSelection) vp;

Re: D - dynamic_cast only?

2011-12-25 Thread Vladimir Panteleev
On Sunday, 25 December 2011 at 13:39:15 UTC, Steve Teale wrote: The segfault is presumably because Widget does not have a setCurrentColor method, but why is the cast being ignored? Is the compiler optimizing the intermediate cast to void away? I don't find the asm from obj2asm helpful. I

Re: D - dynamic_cast only?

2011-12-25 Thread Steve Teale
On Sun, 25 Dec 2011 15:01:31 +0100, Vladimir Panteleev wrote: I don't understand. Casting a void* to a class bypasses all static type checks. This is one of those cases where you tell the compiler that you know what you're doing - and if you try to call a method that wasn't in the original