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


Groups > comp.lang.c > #41652

Re: typecasting (was Re: c prog -plz explain)

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.c
Subject Re: typecasting (was Re: c prog -plz explain)
Date 2014-03-12 15:06 +0000
Organization Aioe.org NNTP Server
Message-ID <20140312073849.250@kylheku.com> (permalink)
References <71fb68ed-69a6-42da-b988-520f9c400ff4@googlegroups.com> <bo7eimFbpi1U3@mid.individual.net> <slrnli01lt.81f.grahn+nntp@frailea.sa.invalid> <87zjkvoczg.fsf@gmail.com> <lfpkin$g79$2@news.xmission.com>

Show all headers | View raw


On 2014-03-12, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <87zjkvoczg.fsf@gmail.com>, Richard  <rgrdev_@gmail.com> wrote:
>>Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
>>
>>> On Tue, 2014-03-11, Ian Collins wrote:
>>>> SAHIL MAHLA wrote:
>>> ...
>>>>> It's because we are typecasting i's address into a double* and [...]
>>>
>>>> You are "casting", not "typecasting".
>>>
>>> For the record, I sometimes say "typecast" too.  Picked it up 25 years
>>> ago or so, probably from my teachers. I'm tempted to suggest that it
>>> should be tolerated as a nickname ...
>>>
>>> /Jorgen
>>
>>And so do 99% of programmers.
>
> Yeah, but not in this Establishment...

I've been here since 1995, which makes me the Establishment; not these
barking newcomers.

You may use "typecast" as a synonym for "cast".  Also "explicit cast" is fine,
even though there is no "implicit cast".

If anyone corrects you on this, and wasn't seen here before Y2K, you can safely
tell them to fuck the hell off, with my full support. 

(I would somewhat prefer that conversions that are not explicitly requested
not be called casts. At least think about it a little, but it's your call.
Do unions cast? You decide.)

I also propose that "typecast" be used specifically when a value is being
reinterpreted (type punned): that is to say, a pointer to that type is being
cast, and the object itself (which wasn't subject to the cast notation) is
being typecast. (If unions do cast, they definitely typecast.)

I.e. i / (double) j is a cast, (bar_struct *) &foo_struct_obj is a typecast.
The pointer is cast; what is typecast is foo_struct_obj itself (whose value
is not even being accessed, let alone converted, in the cast).

Example sentence: "In this area of the code, foo_struct_obj {is/has been}
typecast {to/as a} bar_struct".

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


Thread

c prog -plz explain SAHIL MAHLA <sahilmehla@gmail.com> - 2014-03-10 14:50 -0700
  Re: c prog -plz explain Keith Thompson <kst-u@mib.org> - 2014-03-10 15:41 -0700
    Re: c prog -plz explain Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-10 23:21 +0000
      Re: c prog -plz explain Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-10 23:24 +0000
      Re: c prog -plz explain SAHIL MAHLA <sahilmehla@gmail.com> - 2014-03-10 20:28 -0700
        Re: c prog -plz explain James Kuyper <jameskuyper@verizon.net> - 2014-03-11 00:15 -0400
        Re: c prog -plz explain Kaz Kylheku <kaz@kylheku.com> - 2014-03-11 07:12 +0000
          Re: c prog -plz explain Noob <root@127.0.0.1> - 2014-03-12 10:43 +0100
            Re: c prog -plz explain Kaz Kylheku <kaz@kylheku.com> - 2014-03-12 14:38 +0000
              Re: c prog -plz explain Noob <root@127.0.0.1> - 2014-03-12 15:56 +0100
                Re: c prog -plz explain Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-12 11:16 -0400
                Re: c prog -plz explain James Kuyper <jameskuyper@verizon.net> - 2014-03-12 11:36 -0400
                Re: c prog -plz explain Kaz Kylheku <kaz@kylheku.com> - 2014-03-12 15:38 +0000
              Re: c prog -plz explain glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-12 19:13 +0000
                Re: c prog -plz explain Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-03-12 16:05 -0400
                Re: c prog -plz explain James Kuyper <jameskuyper@verizon.net> - 2014-03-12 16:32 -0400
                Re: c prog -plz explain Ian Collins <ian-news@hotmail.com> - 2014-03-13 09:38 +1300
                Re: c prog -plz explain Tim Rentsch <txr@alumni.caltech.edu> - 2014-03-29 08:32 -0700
            Re: c prog -plz explain glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-12 19:03 +0000
              Re: c prog -plz explain James Kuyper <jameskuyper@verizon.net> - 2014-03-12 15:33 -0400
                Re: c prog -plz explain Kaz Kylheku <kaz@kylheku.com> - 2014-03-12 20:56 +0000
                Re: c prog -plz explain Ian Collins <ian-news@hotmail.com> - 2014-03-13 10:07 +1300
        Re: c prog -plz explain "BartC" <bc@freeuk.com> - 2014-03-11 10:33 +0000
  Re: c prog -plz explain Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-03-10 18:48 -0400
    Re: c prog -plz explain SAHIL MAHLA <sahilmehla@gmail.com> - 2014-03-10 20:26 -0700
      Re: c prog -plz explain Ian Collins <ian-news@hotmail.com> - 2014-03-11 16:34 +1300
        typecasting (was Re: c prog -plz explain) Jorgen Grahn <grahn+nntp@snipabacken.se> - 2014-03-12 07:03 +0000
          Re: typecasting (was Re: c prog -plz explain) Kaz Kylheku <kaz@kylheku.com> - 2014-03-12 07:40 +0000
            Re: typecasting (was Re: c prog -plz explain) Lowell Gilbert <lgusenet@be-well.ilk.org> - 2014-03-12 10:47 -0400
            Re: typecasting (was Re: c prog -plz explain) Ken Brody <kenbrody@spamcop.net> - 2014-03-12 13:01 -0400
          Re: typecasting (was Re: c prog -plz explain) Richard <rgrdev_@gmail.com> - 2014-03-12 12:47 +0100
            Re: typecasting (was Re: c prog -plz explain) gazelle@shell.xmission.com (Kenny McCormack) - 2014-03-12 12:39 +0000
              Re: typecasting (was Re: c prog -plz explain) Kaz Kylheku <kaz@kylheku.com> - 2014-03-12 15:06 +0000
      Re: c prog -plz explain Kaz Kylheku <kaz@kylheku.com> - 2014-03-11 07:26 +0000
        Re: c prog -plz explain Richard <rgrdev_@gmail.com> - 2014-03-11 08:39 +0100
          Re: c prog -plz explain Kaz Kylheku <kaz@kylheku.com> - 2014-03-11 08:08 +0000
      Re: c prog -plz explain Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2014-03-11 09:14 -0400
      Re: c prog -plz explain Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-11 15:38 +0000
  Re: c prog -plz explain Ken Brody <kenbrody@spamcop.net> - 2014-03-11 12:53 -0400
    Re: c prog -plz explain Keith Thompson <kst-u@mib.org> - 2014-03-11 11:47 -0700
      Re: c prog -plz explain glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-03-11 21:41 +0000
        Re: c prog -plz explain Kaz Kylheku <kaz@kylheku.com> - 2014-03-11 22:01 +0000

csiph-web