Casts, especially array casts
Rainer Deyke
rainerd at eldwood.com
Wed Feb 24 15:46:39 PST 2010
On 2/24/2010 14:30, Jonathan M Davis wrote:
> C++ is the only language that I'm aware of which has multiple types of
> casts, and I don't think that it really adds anything of benefit.
Really? I think the casts are one of the areas where C++ has a huge
advantage over C. Maybe the new casts are not as important as templates
and RAII, but they're up there in the same category. The best part of
the C++ cast system is that it uses template function syntax, which
allows user-defined casts to use the same syntax.
Casts are yet another issue where moving from C++ to D feels like
regressing to C.
> Can't the compiler figure out which cast is supposed to be used in a given
> situation and deal with it internally?
That's not the point.
> Having multiple casts just confuses
> things (certainly, I don't think that I know anyone who fully understands
> the C++ casts).
If you don't understand C++ casts, then you don't understand D casts.
They do the same thing; the C++ version is just more explicit about what
it does (and therefore safer and easier to read).
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list