Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #101856
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Using == operator |
| Date | 2017-01-15 09:54 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <kfn4m10mcop.fsf@x-alumni2.alumni.caltech.edu> (permalink) |
| References | (9 earlier) <o4h53l$umh$1@dont-email.me> <lnshozu7b7.fsf@kst-u.example.com> <640f8d29-0683-4614-9cde-c22e80e4dd00@googlegroups.com> <586cc622.1844062@news.xs4all.nl> <slrno6q9t7.5q5.grahn+nntp@frailea.sa.invalid> |
Jorgen Grahn <grahn+nntp@snipabacken.se> writes:
> On Wed, 2017-01-04, Richard Bos wrote:
>> supercat@casperkitty.com wrote:
>>
>>> On Tuesday, January 3, 2017 at 4:06:27 PM UTC-6, Keith Thompson wrote:
>>>> Even if we assume that that corresponds to `if (apple_count)`, what's
>>>> the corresponding English for if(node->next)?
>>>
>>> Since every pointer which is used in such a context is required to either
>>> be a valid pointer or a null pointer, the English would be "If the object
>>> pointed to by 'node' has a valid 'next' pointer, then...." Although the
>>> code is in a literal sense comparing a pointer with a null pointer, such
>>> a comparison is merely the means by which code determines that a pointer is
>>> valid.
>>
>> Yes, that's the reasonable way any halfway experienced programmer will
>> read it. But it's not the _immediate English_ reading of the line.
>>
>> Pretending that programming languages should be legible in the same way
>> that natural languages are is daft. Let's not pretend it is anything
>> else.
>
> I assumed when you guys used the phrase "reads as English" you really
> meant something like "reads fluently".
The wording here is a little funny. Usually "fluently" is used
to give an attribute to a reader, not to what is being read.
What I think you mean might be better expressed as "reads easily"
or "reads fluidly".
> I.e. that it doesn't force you
> to stop and think for a fraction of a second.
And indeed this re-wording matches what I just said.
> In some sense, I maintain that code should be readable like that
> when possible. If that makes me daft, so be it.
I think most developers (or most sensible ones anyway) would
agree with that sentiment. The question is, in what language
frame does the "read easily/fluidly" characteristic apply? For
most low-level constructions, eg,
if ( node->next ) ...
I don't "translate" them to an English description of what's
going on - it's faster and easier just to read the code directly.
In cases where it seems important to express some higher-level
conceptualization, normally I would use a procedural abstraction
such as the following (disclaimer: function name probably can be
improved):
if ( more_elements_after(node) ) ...
Normally I would not do that for 'node->next' because it isn't
needed in such cases, but sometimes that depends on the context
where the if() statement appears - what works in one context
doesn't always work well in a different context. And I expect
(albeit sometimes disappointedly) other developers to follow
similar precepts in their code.
Bottom line, I agree with your "reads fluidly" principle, but
what is fluid for one reader may be more viscous or even frozen
solid for a different reader. Looking at what language frames
different readers expect may be a way of shedding some light on
why their perceptions differ.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
guidelines for pointer check Thiago Adams <thiago.adams@gmail.com> - 2016-12-29 12:53 -0800
Re: guidelines for pointer check Ian Collins <ian-news@hotmail.com> - 2016-12-30 09:58 +1300
Re: guidelines for pointer check Keith Thompson <kst-u@mib.org> - 2016-12-29 13:39 -0800
Re: guidelines for pointer check Thiago Adams <thiago.adams@gmail.com> - 2016-12-29 15:24 -0800
Re: guidelines for pointer check Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2016-12-29 19:05 -0500
Re: guidelines for pointer check Thiago Adams <thiago.adams@gmail.com> - 2016-12-30 05:27 -0800
Re: guidelines for pointer check Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-12-30 14:35 +0000
Re: guidelines for pointer check supercat@casperkitty.com - 2016-12-30 10:38 -0800
Re: guidelines for pointer check Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-02 02:28 -0800
Re: guidelines for pointer check Keith Thompson <kst-u@mib.org> - 2016-12-29 16:19 -0800
Re: guidelines for pointer check Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-12-29 13:58 -0800
guidelines for pointer check asetofsymbols@gmail.com - 2016-12-30 05:35 -0800
Re: guidelines for pointer check raltbos@xs4all.nl (Richard Bos) - 2017-01-01 10:47 +0000
Re: guidelines for pointer check Noob <root@127.0.0.1> - 2017-01-02 14:19 +0100
Re: guidelines for pointer check David Brown <david.brown@hesbynett.no> - 2017-01-02 14:28 +0100
Re: guidelines for pointer check Noob <root@127.0.0.1> - 2017-01-02 17:35 +0100
Re: Using == operator Noob <root@127.0.0.1> - 2017-01-02 19:03 +0100
Re: Using == operator David Brown <david.brown@hesbynett.no> - 2017-01-02 23:41 +0100
Re: Using == operator Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-02 14:54 -0800
Re: Using == operator Keith Thompson <kst-u@mib.org> - 2017-01-02 15:57 -0800
Re: Using == operator Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2017-01-03 16:31 -0500
Re: Using == operator Keith Thompson <kst-u@mib.org> - 2017-01-03 14:06 -0800
Re: Using == operator Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-03 14:44 -0800
Re: Using == operator Keith Thompson <kst-u@mib.org> - 2017-01-03 15:05 -0800
Re: Using == operator Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-01-04 16:42 +0000
Re: Using == operator Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 11:46 -0800
Re: Using == operator Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-01-03 21:22 -0700
Re: Using == operator supercat@casperkitty.com - 2017-01-03 15:23 -0800
Re: Using == operator Keith Thompson <kst-u@mib.org> - 2017-01-03 15:30 -0800
Re: Using == operator supercat@casperkitty.com - 2017-01-03 16:02 -0800
Re: Using == operator Keith Thompson <kst-u@mib.org> - 2017-01-03 16:30 -0800
Re: Using == operator Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 11:26 -0800
Re: Using == operator raltbos@xs4all.nl (Richard Bos) - 2017-01-04 09:55 +0000
Re: Using == operator Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-01-04 16:49 +0000
Re: Using == operator raltbos@xs4all.nl (Richard Bos) - 2017-01-10 01:28 +0000
Re: Using == operator Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-01-09 19:12 -0700
Re: Using == operator Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 09:12 -0800
Re: Using == operator Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 09:54 -0800
Re: Using == operator raltbos@xs4all.nl (Richard Bos) - 2017-01-03 21:08 +0000
Re: Using == operator Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 06:44 -0800
Re: guidelines for pointer check Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2017-01-04 08:54 -0800
Re: guidelines for pointer check Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-14 00:51 -0800
csiph-web