Deutsch English Français Italiano |
<87v8095pwx.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: how cast works? Date: Fri, 09 Aug 2024 14:47:58 -0700 Organization: None to speak of Lines: 74 Message-ID: <87v8095pwx.fsf@nosuchdomain.example.com> References: <v8vlo9$2oc1v$1@dont-email.me> <slrnvb7kis.28a.dan@djph.net> <v929ah$3u7l7$1@dont-email.me> <87ttfu94yv.fsf@nosuchdomain.example.com> <v93a3t$6q7v$1@dont-email.me> <v93e2q$8put$1@dont-email.me> <87bk228uzg.fsf@nosuchdomain.example.com> <v94pji$m1ib$1@dont-email.me> <v95lb7$26koh$1@dont-email.me> <v96000$3fvsp$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 09 Aug 2024 23:47:59 +0200 (CEST) Injection-Info: dont-email.me; posting-host="153d1bcdb0929153f62e0b2f2aa4005b"; logging-data="212067"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1BXkOSNbH+2YQYFfxKP2P" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:mHddLNO6jyGb1d5Wdp6Abs4WeM0= sha1:K8sWYvo34WnRfjR1t1wCTeqd3f0= Bytes: 4214 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.com void Void(void) { Void(); } /* The recursive call of the void */