|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
D - null casts
I've raised this topic once, still... I don't understand why null should be casted to whatever type you want other than void*? It's so annoying! Just look around, no other language has such a restriction: C, C++, Pascal, BASIC... It gets especially #%# when calling WinAPI functions, since many arguments are usually nulls. Just let null be compatible with any pointer type. Or, even better, make void* compatible with all pointers, like it was in C. Dec 21 2001
You're probably right. -Walter "Pavel Minayev" <evilone omen.ru> wrote in message news:a0044r$1m2p$1 digitaldaemon.com...I've raised this topic once, still... I don't understand why null should be casted to whatever type you want other than void*? It's so annoying! Just look around, no other language has such a restriction: C, C++, Pascal, BASIC... It gets especially #%# when calling WinAPI functions, since many arguments are usually nulls. Just let null be compatible with any pointer type. Or, even better, make void* compatible with all pointers, like it was in C. Dec 21 2001
I don't understand. The following works:
object test()
{
return null;
}
works, as well as object*, int*, etc. Can you please post an example where
it doesn't? Thanks!
"Pavel Minayev" <evilone omen.ru> wrote in message
news:a0044r$1m2p$1 digitaldaemon.com...
Dec 21 2001
"Walter" <walter digitalmars.com> wrote in message news:a00pf9$24ri$1 digitaldaemon.com... Dec 22 2001
Ok, I see the problem. It'll get fixed. -Walter "Pavel Minayev" <evilone omen.ru> wrote in message news:a01g85$2ma7$1 digitaldaemon.com... Dec 22 2001
I agree about NULL being compatible with other pointer types, but disagree about void* being implicitly convertable to other pointer types. That leaves a gaping hole in the typechecking safety net that will end up causing bugs. That is why C++ "fixed" that problem. Sean "Pavel Minayev" <evilone omen.ru> wrote in message news:a0044r$1m2p$1 digitaldaemon.com...I've raised this topic once, still... I don't understand why null should be casted to whatever type you want other than void*? It's so annoying! Just look around, no other language has such a restriction: C, C++, Pascal, BASIC... It gets especially #%# when calling WinAPI functions, since many arguments are usually nulls. Just let null be compatible with any pointer type. Or, even better, make void* compatible with all pointers, like it was in C. Dec 22 2001
I fixed D so that null is compatible with other pointer and reference types, but other void*'s will require an explicit cast. -Walter "Sean L. Palmer" <spalmer iname.com> wrote in message news:a02rnb$iij$1 digitaldaemon.com...I agree about NULL being compatible with other pointer types, but disagree about void* being implicitly convertable to other pointer types. That leaves a gaping hole in the typechecking safety net that will end up Dec 22 2001
|