Deutsch   English   Français   Italiano  
<v96cdg$788i$1@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: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: how cast works?
Date: Fri, 9 Aug 2024 20:31:44 -0400
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <v96cdg$788i$1@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> <20240809142622.467@kylheku.com>
 <87jzgp5php.fsf@nosuchdomain.example.com> <20240809152755.123@kylheku.com>
 <87frrd5jw7.fsf@nosuchdomain.example.com> <20240809170514.433@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 10 Aug 2024 02:31:44 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5da9026e4edcec1e1deb82f9c3783d4d";
	logging-data="237842"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19l+HQiYVIHpigRP8EFMPtDY/zcFmtQxqs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:KevST3VyzC3XiNfGqF5FJXDfPOA=
Content-Language: en-US
In-Reply-To: <20240809170514.433@kylheku.com>
Bytes: 2631

On 8/9/24 20:06, Kaz Kylheku wrote:
> On 2024-08-09, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Kaz Kylheku <643-408-1753@kylheku.com> writes:
....
>>> "cast" means to (try to) project a value into another type.
....
>> I hadn't noticed before that the standard does have a formal definition
>> of the term "cast", ...

Neither had I - noticing that earlier would have shortened this
discussion (I hope).

That definition is:
"Preceding an expression by a parenthesized type name converts the value
of the expression to the unqualified, non-atomic version of the named
type. This construction is called a cast." (6.5.4p6)

The word "cast" is italicized, an ISO convention indicating that the
sentence in which it occurs is the official definition of that term.

> Based on surveying all you quoted, I basically nailed it above.

Not quite. A cast is "this construction", namely "preceding an
expression by a parenthesized type name". It describes a portion of the
text of a program. What you described as a cast is the semantics
associated with that construct when the program is compiled, not the
construct itself. (float)3 is a cast. "Convert 3 to a float" is not.