Sigurd Stenersen said:
No, you're reading a bit too much into what I'm saying. I also think
you should be careful with your assumptions about what "most
participants understand" - you may be right, but you can't *know*
this...
Well, all three of them that are still active in the thread (me, Carl
Daniel and Tom Widmer) referred you to 5.4 at one point or another,
rather emphatically. By the preponderance of evidence, I conclude that
these three believe 5.4 to be an appropriate definition of C-style cast.
In my little brain, C++ is most of what C had and some rather nifty
additions. One of the nifty little additions is the various kinds of
C++ style casts. And as C++ has it's own kind of casts, you could
safely assume that the old-fashioned C-style casts behave pretty much
exactly the same way as they do in C (even tho they may be a bit
stricter, they still *function* the same way).
So it appears that your definition of C-style cast in C++ is as follows:
C-style cast is an expression as defined in C++ standard 5.4, but only
when it is also a valid C expression (e.g. as defined in C99 standard
6.5.4). You then proceed to argue that, under this definition, C-style
cast in C++ always behaves "the same way" - namely, the way it behaves
in C. In other words, you seem to argue that C-style cast syntax in C++
is compatible with that of C: whenever you have a program that is both a
valid C and C++ program, any cast in it behaves in the same way whether
compiled by a C or C++ compiler.
Yes, I believe this to be true. There's nothing here to argue about,
really. Like I said, the whole argument stemmed from the fact that your
implied definitions of terms were different from those of other
participants.
So the conclusion appears to be as follows: C-style cast as defined in
5.4 (full definition) can exhibit a complex behavior that depends on the
types participating in the expression. However, if one limits the
discussion only to simpler cases - those that can appear in a C
program - then the behavior of the C-style cast is simple, intuitive and
consistent (it's still not a "always no-op", see below). Specifically,
the behavior matches that defined in C standard.
Would you agree or disagree with this conclusion?
By the way, under your definition the original poster was not, strictly
speaking, performing a C-style cast (since his or her expression
involved a non-POD structs and references, neither of which can appear
in a valid C program).
Now, it's been a while since I wrote anything in C, but I can't
remember a single time I wrote a cast that turned out to be anything
but a NOP (with the possible exception of the occasional implicit
memcpy).
When casting from a signed type to a larger signed type, the cast may
need to perform sign expansion. When casting between integral and
floating point types, the cast needs to perform non-trivial mathematical
operations.
Well, I hate formalities and I don't at all mind being "unorthodox"
Well, I see a little problem with that. C++ is a complex language, its
definition involves extensive terminology. Then there's a larger problem
area of programming and computer science in general, requiring still
more terminology. It would be tiresome and impractical to start every
discussion with establishing common agreed-upon definitions of the
terms.
Thus, people come to rely on implicit understanding of the accepted
terminology, as established by standards, trade literature and/or
consensus achieved in prior public discussions. Familiarity with this
accepted terminology is necessary to fully participate in the community.
This is what I meant by being "orthodox" - adhere to established
conventions whenever possible, clarify your position explicitly whenever
you don't.
If by being "unorthodox" you mean using terms in a discussion under your
own unconventional definitions, without making other participants aware
of them, then you simply won't be understood, and ultimately will be
ignored. I don't think you would consider this an attractive option.
--
With best wishes,
Igor Tandetnik
"On two occasions, I have been asked [by members of Parliament], 'Pray,
Mr. Babbage, if you put into the machine wrong figures, will the right
answers come out?' I am not able to rightly apprehend the kind of
confusion of ideas that could provoke such a question." -- Charles
Babbage