C style casts

E

evil

I haven't conceded anything. My initial stance is clear in my first
post. My second post is based on rereading the text and questioning the
nature of the comments.

Anyway, the idea is to avoid using C-style casts. Bottom line, if they
are removed from the language in future, then whoever takes that advice
will not be impacted.

I find it highly unlikely that a feature as widely used as c-style casts
will ever be removed in the future. I wouldn't avoid it just because of this.
It's true that c++ style casts usually show the programmer's intent more clearly
but imho it doesn't really matter; any half decent programmer will know how
both styles of typecasts work anyway and can read/use them equally well.
This really is not an issue worth fighting over.
 
D

Dakka

Pete said:
In this context (i.e. standard C++) deprecated means that the C++
language definition says they are deprecated, which in turn means that
they might be removed from a future standard.
Yes and pedantry thrives in this group. We all know it is not in the
standard. I won't be telling anybody it is. But *I* consider them
deprecated as do many others (including Stroustrup - see earlier post).
And in *that* context - 'frowned upon' they are. Do you use them? If
not, why?

--dakka

*Dykstra's Observation:*
/If debugging is the process of removing bugs, then programming must be
the process of putting them in./
 
B

Ben Pope

evil said:
It's true that c++ style casts usually show the programmer's intent more clearly
but imho it doesn't really matter; any half decent programmer will know how
both styles of typecasts work anyway and can read/use them equally well.
This really is not an issue worth fighting over.

I'd say it's importance was somewhere between const correctness and
exception specifications. I'd lean towards the former.

Ben Pope
 
P

Pete Becker

Dakka said:
Yes and pedantry thrives in this group. We all know it is not in the
standard.

On the contrary: many people have expressed surprise that it is not.
I won't be telling anybody it is. But *I* consider them
deprecated as do many others (including Stroustrup - see earlier post).

No, he said they "should have been deprecated." That carefully preserves
the meaning of the technical term "deprecated". Call it pedantry if you
like, but sloppy terminology is responsible for much of the confusion in
this discussion (and in newsgroup discussions in general).
And in *that* context - 'frowned upon' they are.

Sure: some people frown upon everything.
Do you use them? If
not, why?

Yes, I use them.
 
R

roberts.noah

Dakka said:
Yes and pedantry thrives in this group. We all know it is not in the
standard. I won't be telling anybody it is. But *I* consider them
deprecated as do many others (including Stroustrup - see earlier post).

This isn't pedantry. The difference between depricated and, "should
be," is very important. If they are depricated then any C++ code that
uses them must be changed or you risk running into much trouble later.
If they, "should be," then there is no chance that they will suddenly
not work anymore when you upgrade or switch compilers.
And in *that* context - 'frowned upon' they are. Do you use them? If
not, why?

I don't use them because they are ugly as hell. C++ casts have a much
cleaner syntax and you don't see crap loads of parantheses around them.
They are also much safer and declare the writer's intention much
clearer. When you see a C-style cast on a const object that removes
const and changes type, which of those things were the developer's
intention or did he actually intend to do both? Finally, searches on
C++ casts are much easier.

In other words I don't use them for all the reasons everyone says they
are better. Nothing new there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,251
Latest member
41Ki

Latest Threads

Top