Deutsch English Français Italiano |
<v96000$3fvsp$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: how cast works? Date: Fri, 9 Aug 2024 21:59:44 +0100 Organization: A noiseless patient Spider Lines: 67 Message-ID: <v96000$3fvsp$2@dont-email.me> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 09 Aug 2024 22:59:44 +0200 (CEST) Injection-Info: dont-email.me; posting-host="a5ef0e336b797e59eb82473df0f29c2d"; logging-data="3669913"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LQSzGScEfrbuKQ4udIkbh" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:UMch97kInxbkvuCZfCUlK6NdWdA= In-Reply-To: <v95lb7$26koh$1@dont-email.me> Content-Language: en-GB Bytes: 3661 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 don't see a >> problem with talking about implicit and explicit versions. > > There's nothing wrong with talking about implicit conversions versus > explicit conversions. Of course! Because those terms happen to be used in a couple of places in the standard. Usage of any terms not appearing in the standard is apparently outlawed in this newsgroup. > Explicit conversion are also called casts. "6.5.4p3 Conversions that involve pointers, other than where permitted by the constraints of 6.5.16.1, shall be specified by means of an explicit cast." Here it uses the term 'explicit cast'. Why is that; isn't the term 'cast' unambiguous without needing to say 'explicit'? Also, what is exactly is the difference between 'explicit conversion' and 'explicit cast'? 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. 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, but 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. 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:" Look also at H.2.4p4 (also p5): "C’s conversions (casts) from floating-point to floating-point can meet LIA−1 requirements if an implementation uses round-to-nearest (IEC 60559 default)." Here it clearly indicates that 'conversions' (presumably both implicit and explicit) are also known as 'casts'. This seems to imply (no pun) that 'implicit casts' are a thing; the opportunity to use that term just never came up. I don't wish to be rude to you or KT but .....