Casts, especially array casts

bearophile bearophileHUGS at lycos.com
Wed Feb 24 16:09:35 PST 2010


Rainer Deyke:

> Casts are yet another issue where moving from C++ to D feels like
> regressing to C.

Yet, currently D casts aren't like C ones, D casts performs dynamic casts of object references, etc.


> If you don't understand C++ casts, then you don't understand D casts.

C++ has 4+1 casts, they are a good amount of complexity, and it's not easy to learn their difference and purposes. So probably Jonathan is right when he says many C++ programmers don't use C++ casts well and probably tend to stick to one or two only. I think casts of C++ are too much complex, as most things in C++ :-)
That's why I have suggested only two casts for D, that differ a lot in purposes, and where most times you can use just one of them (the one with the simpler and shorter name) and be happy.

Bye,
bearophile



More information about the Digitalmars-d mailing list