C style casts

R

roberts.noah

Where is it in the standard that C style casts are labeled depricated?
I read that on a lot of websites but I can't find it in the standard.
I have BS ISO/IEC 14882:2003 (2nd ed) as published by John Wiley &
Sons. I'm in the middle of a standard argument on this issue and
safety isn't convincing my opponents - deprication might.
 
V

Victor Bazarov

Where is it in the standard that C style casts are labeled depricated?

Deprecated? Nowhere. 5.4 describes the explicit type conversion and what
it means.
I read that on a lot of websites but I can't find it in the standard.

Because it's not there. What web site claims that it's deprecated? Can
you post a link?
I have BS ISO/IEC 14882:2003 (2nd ed) as published by John Wiley &
Sons. I'm in the middle of a standard argument on this issue and
safety isn't convincing my opponents - deprication might.

Sorry to disappoint you. No deprecation on that one.

V
 
A

Alf P. Steinbach

* (e-mail address removed):
Where is it in the standard that C style casts are labeled depricated?

They aren't.

I read that on a lot of websites but I can't find it in the standard.
I have BS ISO/IEC 14882:2003 (2nd ed) as published by John Wiley &
Sons. I'm in the middle of a standard argument on this issue and
safety isn't convincing my opponents - deprication might.

You can't force anyone to write decent code. You can't force anyone to
share your values, your opinion on what is good and bad. So if they
insist on using C style casts, let them.
 
D

Dakka

Victor said:
Deprecated? Nowhere. 5.4 describes the explicit type conversion and what
it means.


Because it's not there. What web site claims that it's deprecated? Can
you post a link?


Sorry to disappoint you. No deprecation on that one.

V
In this context, deprecation means 'frowned upon' not 'no longer
supported'. So in this sense, they are deprecated. Clearly their
addition to the language implied that their use, in most cases, was
preferred to C style casts.
--dakka
 
V

Victor Bazarov

Yep, that's what I see...




http://www.google.com/search?hl=en&q=c+++c+style+casts+deprecated&spell=1

There's a few. A good section of the first few pages actually say it,
the others just contain all words.

The first two pages that come up are about the D language, and not C++.
The third, fourth, and fifth pages do not have it. On the sixth, somebody
named "Chuck Allison" claims they are deprecated, you need to take it up
with him.

The rest... I have no time for chasing ghosts. I didn't find any mention
of deprecation of C-style casts in the C++ Standard.

V
 
R

roberts.noah

Dakka said:
In this context, deprecation means 'frowned upon' not 'no longer
supported'. So in this sense, they are deprecated. Clearly their
addition to the language implied that their use, in most cases, was
preferred to C style casts.

Actually I have run into quite a few websites that state that the
standard committee depricated C-style casts; the committee would not
*depricate* a feature if they didn't mean the formal definition. I
don't know if any in the google search I posted do but I have seen it
in at least 3 different sources so I was rather confused that I
couldn't find any mention of that in the standard (in fact as mentioned
here the only text in the standard I could find on C-Style cast
describes what they are/do and makes no mention of deprication).
Depricated in that context to me means the next standard very well
might not have them and in fact this is exactly what websites that make
this claim say.

Perhaps it is in an addendum or something?
 
V

Victor Bazarov

Dakka said:
In this context, deprecation means 'frowned upon' not 'no longer
supported'.

In what context?

The OP specifically asked about deprecation of C-style casts in the
Standard. There is none. The Standard does not contain any human emotion
or any judgement. It cannot. Nothing is "frowned upon" in the Standard.
> So in this sense, they are deprecated. Clearly their
addition to the language implied that their use, in most cases, was
preferred to C style casts.

Addition of what to which language?

V
 
D

dakka

Victor said:
In what context?

Take out your dictionary, V and look up the meaning of the word.
The OP specifically asked about deprecation of C-style casts in the
Standard. There is none. The Standard does not contain any human emotion
or any judgement. It cannot. Nothing is "frowned upon" in the Standard.


Addition of what to which language?

Well we're not talking about Ada are we? Probably C++ - what do you think?


--dakka
 
D

dakka

Actually I have run into quite a few websites that state that the
standard committee depricated C-style casts; the committee would not
*depricate* a feature if they didn't mean the formal definition. I
don't know if any in the google search I posted do but I have seen it
in at least 3 different sources so I was rather confused that I
couldn't find any mention of that in the standard (in fact as mentioned
here the only text in the standard I could find on C-Style cast
describes what they are/do and makes no mention of deprication).
Depricated in that context to me means the next standard very well
might not have them and in fact this is exactly what websites that make
this claim say.

Perhaps it is in an addendum or something?
Interestingly, Stroustrup also refers to C style casts as deprecated in
the C++ Programming Language, Special Edition, 2000, pp 818-819
 
V

Victor Bazarov

dakka" <"news at electro dot mine dot nu said:
Take out your dictionary, V and look up the meaning of the word.

What meaning of what word? Stop playing your moronic games. You
said "this context". I asked which context you mean. You're now
suggesting looking in the dictionary. Are you challenged? Can you
simply answer the question asked?
Well we're not talking about Ada are we? Probably C++ - what do you
think?

I think when we talk about _C_-style casts, C++ _and_ C are both fair
game. What are you talking about? Dictionaries? English?

V
 
M

michaelkatsilis

Interestingly, Stroustrup also refers to C style casts as deprecated in
the C++ Programming Language, Special Edition, 2000, pp 818-819

People, lets not make false assumptions, thereby misleading others.
Stroustrup makes no such statement, reference or implication in
relation to C style casts. What he states is that they "should have
been deprecated when the new-style casts were introduced" and that the
new style casts should be preferred for reasons we know.

Regards,

Michael
 
D

dakka

Victor said:
What meaning of what word? Stop playing your moronic games. You
said "this context". I asked which context you mean. You're now
suggesting looking in the dictionary. Are you challenged? Can you
simply answer the question asked?

Ho hum. In the context that the original poster queried - that being why
he had seen C style casts being referred to as deprecated in C++. As for
the rest of your hotheaded guff.... yawn.
I think when we talk about _C_-style casts, C++ _and_ C are both fair
game. What are you talking about? Dictionaries? English?

V
Not in a C++ newsgroup they're not. I think its pretty clear what I
meant. For reasons only known to yourself you seem to think otherwise.
--dakka
 
D

dakka

People, lets not make false assumptions, thereby misleading others.
Stroustrup makes no such statement, reference or implication in
relation to C style casts. What he states is that they "should have
been deprecated when the new-style casts were introduced" and that the
new style casts should be preferred for reasons we know.

Regards,

Michael
Um nothing misleading there. Can't find the quote you cited though. He
does say
".. the new-style casts should be preferred because because they are
more explicit and more visible".

He doesn't say that the committee referred to them as deprecated but he
does express his *own* opinion that they should be. That was all I was
pointing out. However this statement appears in his book under the heading

B.2.3 Deprecated Features.

Regardless of whether the committee used the word deprecated or not, it
is clearly implied that they are. Lets just wait and see what comes in
c++0x.
--dakka
 
M

michaelkatsilis

Well, maybe, it's in the deprecated section and he states that the
C-style casts should have been deprecated when the new ones were
introduced but isn't explicit about whether the old casts actually
were at the time of writing. However, it seems from the comments by
others above that the committee has not deprecated them. I don't have a
copy of the standard to reference so I wouldn't know.

Regards,

Michael
 
J

John Carson

Well, maybe, it's in the deprecated section and he states that the
C-style casts should have been deprecated when the new ones were
introduced but isn't explicit about whether the old casts actually
were at the time of writing. However, it seems from the comments by
others above that the committee has not deprecated them. I don't have
a copy of the standard to reference so I wouldn't know.

You are conceding ground you should not. Stroustrup does *not* say C-style
casts are deprecated and on any reasonable interpretation says the opposite.

In the same section he explicitly states that "The use of static to indicate
'local to translation unit' is deprecated". Likewise: "The implicit
conversion of string literal to a (non-const) char * is deprecated."

When by contrast he says "C-style casts *should* have been deprecated" (my
emphasis), he is clearly telling the reader that they have not been.
 
P

Pete Becker

Dakka said:
In this context, deprecation means 'frowned upon' not 'no longer
supported'.

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.
 
P

Pete Becker

Perhaps it is in an addendum or something?

Perhaps it doesn't exist, and various websites by authors with varying
degrees of actual knowledge who claim otherwise are simply wrong. Lots
of people saying something doesn't make it true.
 
M

michaelkatsilis

John said:
You are conceding ground you should not.

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.

Regards,

Michael
 
T

Tom

Heck, two days ago I didn't even know what a C-style cast was.
Just stumbled across the following.

==========================

http://www.freshsources.com/newcpp.html

Old-Style Casts. Old C-style casts are dangerous and ugly, but
sometimes a programmer's got to do what a programmer's got to do.
Unfortunately, programmers occasionally do the wrong thing. The
new-style C++ casts are superior to C-style casts because they

explicitly advertise the type of cast being performed
disallow any type of conversion other than the one requested, and
stand out in code inspections because of their noticeable syntax

For example, the expression
p = reinterpret_cast<char*>(0x00f0x10a)

is much more likely to draw a reader's attention than
p = (char*)(0x00f0x10a)

Furthermore, using static_cast here instead of reinterpret_cast would
fail, since the former only converts between related types. For now,
old-style casts are only deprecated, since otherwise too much existing
code would break, but watch out! Five years from now they're probably
going away.
==========================

there's that deprecated word ^^

added that to my vocabulary last two days too.

dep·re·cate

TRANSITIVE VERB:
de·pre·cat·ed , de·pre·cat·ing , de·pre·cates
1) To express disapproval of; deplore.
2) To belittle; depreciate.
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top