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


Groups > comp.lang.c > #7676

Re: References in C

From Lowell Gilbert <lgusenet@be-well.ilk.org>
Newsgroups comp.lang.c
Subject Re: References in C
References (5 earlier) <rubrum-5069B7.10323130062011@news.albasani.net> <kfnei2758u9.fsf@x-alumni2.alumni.caltech.edu> <rubrum-84871D.20293403072011@news.albasani.net> <kfnr5653avc.fsf@x-alumni2.alumni.caltech.edu> <rubrum-7978B9.08324905072011@news.albasani.net>
Date 2011-07-05 15:34 -0400
Message-ID <44fwmkldxz.fsf@lowell-desk.lan> (permalink)

Show all headers | View raw


Michael Press <rubrum@pacbell.net> writes:

> In article <kfnr5653avc.fsf@x-alumni2.alumni.caltech.edu>,
>  Tim Rentsch <txr@alumni.caltech.edu> wrote:
>
>> Michael Press <rubrum@pacbell.net> writes:
>> 
>> > In article <kfnei2758u9.fsf@x-alumni2.alumni.caltech.edu>,
>> >  Tim Rentsch <txr@alumni.caltech.edu> wrote:
>> >
>> >> Michael Press <rubrum@pacbell.net> writes:
>> >> 
>> >> > In article <iug9bp$dfi$1@speranza.aioe.org>,
>> >> >  pacman@kosh.dhis.org (Alan Curry) wrote:
>> >> >
>> >> >> In article <lnliwl89uq.fsf@nuthaus.mib.org>,
>> >> >> Keith Thompson  <kst-u@mib.org> wrote:
>> >> >> >pacman@kosh.dhis.org (Alan Curry) writes:
>> >> >> >>
>> >> >> >> Exactly. In my mental type map, "boolean" is a very high level abstract type,
>> >> >> >> and pointers are among its subclasses.
>> >> >> >
>> >> >> >So a "boolean" is anything that can be used as a condition, i.e.,
>> >> >> >anything that can be compared against 0?
>> >> >> 
>> >> >> Basically. But "can be compared against 0" is just an under-the-hood detail.
>> >> >> What makes a type boolean is that its values can be cleanly divided into
>> >> >> exactly 2 subsets based on some well-chosen attribute. Null-or-nonnull is
>> >> >> the only obvious way to divide pointer values into exactly 2 subsets, so
>> >> >> their non-null-ness is their truthiness.
>> >> >> 
>> >> >> Look at these examples of concise uses of pointers as booleans, taken from 3
>> >> >> different files in the Linux kernel:
>> >> >> 
>> >> >>         if (drv && drv->pm && drv->pm->prepare)
>> >> >> 
>> >> >>         if (p && p->detect && p->detect() > 0)
>> >> >> 
>> >> >>         return suspend_ops && suspend_ops->valid && suspend_ops->valid(state);
>> >> >> 
>> >> >> They look so simple. You really think it would help readability to jam a
>> >> >> bunch of "!= 0" or "!= NULL" noise in there?
>> >> >
>> >> > Editors and other experts in grammar and English 
>> >> > composition agree: when you write yourself into a
>> >> > corner, then recast the sentence. 
>> >> >
>> >> >     if (   drv              != NULL
>> >> >         && drv->pm          != NULL
>> >> >         && drv->pm->prepare != NULL)
>> >> >
>> >> >     if (   p          != NULL
>> >> >         && p->detect  != NULL
>> >> >         && p->detect() > 0)
>> >> >
>> >> >     return    suspend_ops               != NULL
>> >> >            && suspend_ops->valid        != NULL
>> >> >            && suspend_ops->valid(state) != NULL;
>> >> 
>> >> These haven't been recasted, just written using a
>> >> different stylistic preference -- like adding a comma
>> >> after the penultimate item in a series of three or
>> >> more.
>> >> 
>> >> Regardless of one's personal preferences about style
>> >> here, any programmer who doesn't immediately and easily
>> >> understand the first, shorter forms of these examples
>> >> either needs a C refresher course or shouldn't be
>> >> programming in C.
>> >
>> > Yes, they have been recast.
>> > The challenge was to readably write the predicates using 
>> > "!= 0" or "!= NULL", and I met the challenge. 
>> >
>> >
>> > recast ...
>> > 2. to improve the form of; reconstruct: as, he recast the sentence.
>> 
>> Apparently you think even trivial changes must amount to a
>> change of form.  That's silly.  Editing is not the same as
>> recasting -- the sets of examples above are different in
>> detail but not in form.  Replacing a tire on a bicycle, even
>> to a different grade of tire, doesn't recast the bicycle.
>
> I take it that you agree with everything else I said,
> or are you working your way up from the most trivial.

I believe he's using the English-language meaning of "recasting", and
you are using the C-language version.  But I could be wrong.

-- 
Lowell Gilbert, embedded/networking software engineer
	 http://be-well.ilk.org/~lowell/

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


Thread

References in C jacob navia <jacob@spamsink.net> - 2011-06-24 10:42 +0200
  Re: References in C BGB <cr88192@hotmail.com> - 2011-06-24 02:53 -0700
    Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-24 22:10 +1200
  Re: References in C "BartC" <bc@freeuk.com> - 2011-06-24 11:14 +0100
    Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-24 16:59 +0200
  Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-24 09:26 -0400
    Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-24 20:08 +0200
      Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-24 11:40 -0700
      Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-24 14:53 -0400
      Re: References in C jt@toerring.de (Jens Thoms Toerring) - 2011-06-24 20:44 +0000
        Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-24 23:09 +0200
          Re: References in C Joe Wright <joewwright@comcast.net> - 2011-06-24 17:38 -0400
            Re: References in C "BartC" <bc@freeuk.com> - 2011-06-24 22:58 +0100
            Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-25 10:11 +1200
              Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-26 17:00 -0500
                Re: References in C "BartC" <bc@freeuk.com> - 2011-06-26 22:55 +0100
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-26 18:25 -0500
                Re: References in C "BartC" <bc@freeuk.com> - 2011-06-26 23:38 +0100
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-26 19:19 -0500
                Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-27 01:27 +0200
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-26 19:13 -0700
                Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-27 16:50 +1200
                Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-27 06:55 +0200
                Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-27 17:10 +1200
                Re: References in C lawrence.jones@siemens.com - 2011-06-27 10:04 -0400
                Re: References in C jt@toerring.de (Jens Thoms Toerring) - 2011-06-26 22:54 +0000
                Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-27 01:29 +0200
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-26 19:39 -0500
                Re: References in C pacman@kosh.dhis.org (Alan Curry) - 2011-06-27 07:16 +0000
                Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-27 09:46 +0200
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-27 12:03 -0400
                Re: References in C Stephen Sprunk <stephen@sprunk.org> - 2011-06-27 12:09 -0500
                Re: References in C pacman@kosh.dhis.org (Alan Curry) - 2011-06-27 22:16 +0000
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-27 11:57 -0400
                Re: References in C pacman@kosh.dhis.org (Alan Curry) - 2011-06-27 22:21 +0000
                Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-28 13:59 +1200
                Re: References in C Ike Naar <ike@iceland.freeshell.org> - 2011-06-27 07:05 +0000
                Re: References in C jt@toerring.de (Jens Thoms Toerring) - 2011-06-27 20:10 +0000
                Re: References in C Stephen Sprunk <stephen@sprunk.org> - 2011-06-27 16:39 -0500
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-26 15:23 -0700
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-26 18:57 -0500
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-26 19:21 -0700
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-27 09:40 -0400
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-27 09:00 -0700
                Re: References in C pacman@kosh.dhis.org (Alan Curry) - 2011-06-27 23:15 +0000
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-28 22:50 -0700
                Re: References in C Seebs <usenet-nospam@seebs.net> - 2011-06-29 17:46 +0000
                Re: References in C Dr Nick <3-nospam@temporary-address.org.uk> - 2011-06-29 20:23 +0100
                Re: References in C pacman@kosh.dhis.org (Alan Curry) - 2011-06-29 22:35 +0000
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-29 16:52 -0700
                Re: References in C Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-07-03 01:31 +0300
                Re: References in C Chad <cdalten@gmail.com> - 2011-07-02 17:20 -0700
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-29 18:54 -0500
                Re: References in C Michael Press <rubrum@pacbell.net> - 2011-06-30 10:32 -0700
                Re: References in C "io_x" <a@b.c.invalid> - 2011-07-01 10:19 +0200
                Re: References in C pacman@kosh.dhis.org (Alan Curry) - 2011-07-01 19:21 +0000
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-07-01 12:31 -0700
                Re: References in C pacman@kosh.dhis.org (Alan Curry) - 2011-07-01 19:32 +0000
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-07-01 13:05 -0700
                Re: References in C Seebs <usenet-nospam@seebs.net> - 2011-07-01 23:58 +0000
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-07-01 20:13 -0500
                Re: References in C Michael Press <rubrum@pacbell.net> - 2011-07-01 12:44 -0700
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-07-01 15:57 -0500
                Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-03 14:54 -0700
                Re: References in C Michael Press <rubrum@pacbell.net> - 2011-07-03 20:29 -0700
                Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-04 16:05 -0700
                Re: References in C Michael Press <rubrum@pacbell.net> - 2011-07-05 08:32 -0700
                Re: References in C Lowell Gilbert <lgusenet@be-well.ilk.org> - 2011-07-05 15:34 -0400
                Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-07-06 15:30 -0700
                Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-27 13:27 +1200
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-27 09:02 -0400
              Re: References in C "Joel C. Salomon" <joelcsalomon@gmail.com> - 2011-06-26 18:35 -0400
                Re: References in C James Kuyper <jameskuyper@verizon.net> - 2011-06-26 19:11 -0400
                Re: References in C "Joel C. Salomon" <joelcsalomon@gmail.com> - 2011-06-28 00:52 -0400
                Re: References in C James Kuyper <jameskuyper@verizon.net> - 2011-06-28 07:56 -0400
          Re: References in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-06-24 22:52 +0100
          Re: References in C jt@toerring.de (Jens Thoms Toerring) - 2011-06-24 23:58 +0000
  Re: References in C Tom St Denis <tom@iahu.ca> - 2011-06-24 06:48 -0700
    Re: References in C David Resnick <lndresnick@gmail.com> - 2011-06-24 07:14 -0700
      Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-24 16:58 +0200
        Re: References in C Tom St Denis <tom@iahu.ca> - 2011-06-24 09:08 -0700
          Re: References in C Stephen Sprunk <stephen@sprunk.org> - 2011-06-24 11:33 -0500
          Re: References in C gazelle@shell.xmission.com (Kenny McCormack) - 2011-06-24 17:47 +0000
            Re: References in C JG <jgrove24@hotmail.com> - 2011-07-01 14:24 -0700
          Re: References in C Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-06-25 04:39 -0700
            Re: References in C BGB <cr88192@hotmail.com> - 2011-06-25 16:15 -0700
              Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-26 11:27 +1200
                Re: References in C BGB <cr88192@hotmail.com> - 2011-06-25 19:13 -0700
                Re: References in C cri@tiac.net (Richard Harter) - 2011-06-26 04:22 +0000
                Re: References in C Robert Wessel <robertwessel2@yahoo.com> - 2011-06-26 01:31 -0500
                Re: References in C BGB <cr88192@hotmail.com> - 2011-06-26 00:03 -0700
                Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-26 13:54 -0500
                Re: References in C luser- -droog <mijoryx@yahoo.com> - 2011-07-07 11:19 -0700
            Re: References in C Dr Nick <3-nospam@temporary-address.org.uk> - 2011-06-26 08:15 +0100
    Re: References in C Ike Naar <ike@sverige.freeshell.org> - 2011-06-24 16:08 +0000
      Re: References in C Tom St Denis <tom@iahu.ca> - 2011-06-24 11:12 -0700
        Re: References in C Ike Naar <ike@iceland.freeshell.org> - 2011-06-24 21:42 +0000
  Re: References in C Stephen Sprunk <stephen@sprunk.org> - 2011-06-24 11:49 -0500
  Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-24 13:17 -0700
    Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-24 16:46 -0400
      Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-24 14:32 -0700
        Re: References in C Gareth Owen <gwowen@gmail.com> - 2011-06-25 09:39 +0100
          Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-07-04 17:38 -0400
  Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-06-24 16:33 -0400
    Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-24 23:04 +0200
  Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-26 17:53 -0700
    Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-27 17:04 +1200
      Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-27 14:28 -0700
        Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-28 14:11 +1200
          Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-28 16:27 -0700
          Re: References in C Michael Press <rubrum@pacbell.net> - 2011-06-29 13:41 -0700
            Re: References in C Seebs <usenet-nospam@seebs.net> - 2011-06-29 21:15 +0000
              Re: References in C Michael Press <rubrum@pacbell.net> - 2011-06-30 09:26 -0700
                Re: References in C Seebs <usenet-nospam@seebs.net> - 2011-06-30 20:55 +0000
                Re: References in C Michael Press <rubrum@pacbell.net> - 2011-06-30 16:20 -0700
                Re: References in C Seebs <usenet-nospam@seebs.net> - 2011-06-30 23:45 +0000
                Re: References in C James Kuyper <jameskuyper@verizon.net> - 2011-07-01 07:58 -0400
    Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-27 10:43 +0200
      Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-27 08:32 -0700
      Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-28 11:01 -0700
        Re: References in C jacob navia <jacob@spamsink.net> - 2011-06-28 22:17 +0200
          Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-29 09:05 +1200
          Re: References in C Keith Thompson <kst-u@mib.org> - 2011-06-28 22:24 -0700
          Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-29 01:07 -0700
            Re: References in C Ian Collins <ian-news@hotmail.com> - 2011-06-29 21:16 +1200
              Re: References in C Seebs <usenet-nospam@seebs.net> - 2011-06-29 17:46 +0000
              Re: References in C Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-29 12:19 -0700
          Re: References in C sandeep <nospam@nospam.com> - 2011-07-03 20:53 +0000
            Re: References in C Chad <cdalten@gmail.com> - 2011-07-03 14:02 -0700
            Re: References in C Keith Thompson <kst-u@mib.org> - 2011-07-03 14:33 -0700
              Re: References in C jacob navia <jacob@spamsink.net> - 2011-07-04 00:22 +0200
                Re: References in C Keith Thompson <kst-u@mib.org> - 2011-07-04 13:41 -0700
              Re: References in C gazelle@shell.xmission.com (Kenny McCormack) - 2011-07-04 00:00 +0000
              Re: References in C Seebs <usenet-nospam@seebs.net> - 2011-07-04 00:20 +0000
      Re: References in C Shao Miller <sha0.miller@gmail.com> - 2011-07-04 17:43 -0400

csiph-web