Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #387453

Re: how cast works?

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: how cast works?
Date 2024-08-09 14:47 -0700
Organization None to speak of
Message-ID <87v8095pwx.fsf@nosuchdomain.example.com> (permalink)
References (5 earlier) <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>

Show all headers | View raw


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 */

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-07 08:28 -0300
  Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-07 08:33 -0300
    Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-07 13:13 -0700
    Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 17:43 -0700
      Re: how cast works? Vir Campestris <vir.campestris@invalid.invalid> - 2024-08-12 11:51 +0100
        Challenge/exercise problem - signum() function Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-12 08:17 -0700
          Re: Challenge/exercise problem - signum() function Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2024-08-12 16:07 +0000
            Re: Challenge/exercise problem - signum() function Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-12 09:57 -0700
  Re: how cast works? Dan Purgert <dan@djph.net> - 2024-08-07 20:00 +0000
    Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-07 13:26 -0700
    Re: how cast works? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-08-07 23:00 +0000
    Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-08 08:14 -0300
      Re: how cast works? Bart <bc@freeuk.com> - 2024-08-08 14:23 +0100
        Re: how cast works? Michael S <already5chosen@yahoo.com> - 2024-08-08 19:32 +0300
          Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-08 14:11 -0300
          Re: how cast works? Bart <bc@freeuk.com> - 2024-08-08 18:29 +0100
            Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-08 14:50 -0300
              Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-08 14:57 -0300
              Re: how cast works? Bart <bc@freeuk.com> - 2024-08-08 19:01 +0100
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-08 15:13 -0300
              Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-08 12:29 -0700
            Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-08 19:58 +0200
              Re: how cast works? Bart <bc@freeuk.com> - 2024-08-08 20:09 +0100
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 00:32 +0200
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-08 16:14 -0700
                Re: how cast works? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-08-09 02:47 +0000
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-08 22:55 -0700
                Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-09 02:08 -0400
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 18:16 +0200
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 12:18 -0700
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 17:07 -0700
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-11 20:14 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-09 01:56 +0100
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 19:08 +0200
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-10 11:03 +0100
                Re: how cast works? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-08-09 02:45 +0000
      Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-08 12:42 -0700
        Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-08 17:34 -0300
          Re: how cast works? Bart <bc@freeuk.com> - 2024-08-08 22:41 +0100
            Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-08 16:17 -0700
              Re: how cast works? Bart <bc@freeuk.com> - 2024-08-09 11:04 +0100
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 19:12 +0200
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-12 15:36 +0100
                Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-09 13:57 -0400
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-09 21:59 +0100
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 14:47 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-10 00:32 +0100
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 17:12 -0700
                Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-09 18:29 -0400
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-13 11:18 +0200
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-13 11:34 +0100
                Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-13 07:51 -0400
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-13 14:01 +0100
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-13 12:46 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-13 21:51 +0100
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-13 16:46 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-14 00:56 +0100
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-18 03:37 -0700
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 14:29 -0700
                Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-09 18:35 -0400
                Re: how cast works? Kaz Kylheku <643-408-1753@kylheku.com> - 2024-08-09 21:30 +0000
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 14:57 -0700
                Re: how cast works? Kaz Kylheku <643-408-1753@kylheku.com> - 2024-08-09 23:14 +0000
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 16:58 -0700
                Re: how cast works? Kaz Kylheku <643-408-1753@kylheku.com> - 2024-08-10 00:06 +0000
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 17:27 -0700
                Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-09 20:31 -0400
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-10 01:11 +0100
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-13 11:23 +0200
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 17:32 -0700
                Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-09 18:35 -0400
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 17:27 -0700
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 12:23 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-09 21:31 +0100
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 13:49 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-09 22:01 +0100
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-12 00:33 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-12 12:21 +0100
              Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 17:46 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-12 02:00 +0100
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-11 20:23 -0700
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 20:37 -0700
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-11 21:33 -0700
                Re: how cast works? Ben Bacarisse <ben@bsb.me.uk> - 2024-08-12 16:57 +0100
                Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-12 10:04 -0700
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-12 13:35 -0700
            Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-09 07:57 -0300
              Re: how cast works? Bart <bc@freeuk.com> - 2024-08-09 16:25 +0100
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 12:06 -0700
              Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 19:20 +0200
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-09 15:54 -0300
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-09 16:05 -0300
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 21:43 +0200
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 13:28 -0700
                Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 22:01 +0200
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-10 11:17 +0100
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-10 10:15 -0300
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-10 17:14 +0100
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-10 20:01 -0300
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-10 17:10 -0700
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-11 09:23 -0300
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-11 13:30 +0100
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-11 14:16 -0300
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-11 13:38 -0700
                Re: how cast works? Bart <bc@freeuk.com> - 2024-08-12 12:24 +0100
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 13:26 -0700
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-09 18:01 -0300
                Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 14:53 -0700
              Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-09 12:03 -0700
                Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-09 16:22 -0300
          Re: how cast works? David Brown <david.brown@hesbynett.no> - 2024-08-09 00:36 +0200
    Re: how cast works? Dan Purgert <dan@djph.net> - 2024-08-08 14:08 +0000
    Re: how cast works? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-08-09 02:42 +0000
  Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-07 13:08 -0700
    Re: how cast works? Thiago Adams <thiago.adams@gmail.com> - 2024-08-08 08:35 -0300
      Re: how cast works? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-08-08 12:39 -0700
      Re: how cast works? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-08-08 18:40 -0400
        Re: how cast works? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-08-11 17:15 -0700
    Is there an audio book version (Was: how cast works?) gazelle@shell.xmission.com (Kenny McCormack) - 2024-08-08 16:19 +0000
  Re: how cast works? Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-08-07 23:03 +0000

csiph-web