Sujet : Re: how cast works?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 09. Aug 2024, 22:47:58
Autres entêtes
Organisation : None to speak of
Message-ID : <87v8095pwx.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Gnus/5.13 (Gnus v5.13)
Bart <
bc@freeuk.com> writes:
On 09/08/2024 18:57, James Kuyper wrote:
On 09/08/2024 12:04, Bart wrote:
>
A cast is a piece of syntax that is used to explicitly request that
a
conversion be performed. Conversions that are explicitly requested in C
code are referred to as casts only by people who don't understand what
they're saying - the standard never refers to them as such.
>
Are you sure? What else would they be known as?
I believe James made a small error here, either omitting a "not" or
accidentally writing "explicitly" rather than "implicitly".
With that correction, I presume what James wrote is clear enough.
I ask you not to pretend that you still don't understand it.
[...]
Here it uses the term 'explicit cast'. Why is that; isn't the term
'cast' unambiguous without needing to say 'explicit'?
It's redundant.
Also, what is exactly is the difference between 'explicit conversion'
and 'explicit cast'?
The both mean the same thing in C, but "explicit cast" is redundant.
Why can't there also be a similar correlation between 'implicit
conversion' and 'implicit cast'? The only reason I can see is that out
of these four terms, only 3 of them happen to appear in the standard.
Because a cast is an explicit operator.
I don't see that as a compelling reason why that term should be
considered absolutely wrong; 'implicit cast' just never came up.
>
It's not as though the standard provides an official glossary,
In fact it does. Some terms are defined in section 3, and others are
defined elsewhere in the standard (definitions are denoted by italics).
I don't see a definition for the term "cast", but it's clearly described
in N3220 6.5.4 "Cast operators".
Array indexing is defined in terms of pointer arithmetic. The
evaluation of `a[i]` involves an implicit addition operation. It does
not involve an implicit "+" symbol.
even if it did, surely people ought to be allowed to use alternate
terms for an informal discussion? This is a not a committee meeting.
You're allowed to write whatever nonsense you like, and the rest of us
are allowed to tell you that you're wrong.
Explain why using the word "cast" incorrectly is better than using it
correctly. Explain why you can't just refer to explicit and implicit
conversions. Do you have a motivation other than being annoying?
I remember people here getting castigated for using the term 'type
cast'. And yet, in H.2.4p1:
>
"The LIA−1 type conversions are the following type casts:"
That wording is no longer there in more recent editions. Annex H refers
to LIA-1 (Language Independent Arithmetic), ISO/IEC 10967–1; perhaps
that standard use the term "type casts". (I'm not going to pay CHF 216
to find out.)
[...]
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */