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


Groups > comp.lang.c > #165673

Re: Memorizing C operator precedence

From Kaz Kylheku <480-992-1380@kylheku.com>
Newsgroups comp.lang.c
Subject Re: Memorizing C operator precedence
Date 2022-04-13 23:48 +0000
Organization A noiseless patient Spider
Message-ID <20220413163721.82@kylheku.com> (permalink)
References <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de>

Show all headers | View raw


On 2022-04-13, Alan Mackenzie <acm@muc.de> wrote:
> Jens Stuckelberger <Jens_Stuckelberger@nowhere.net> wrote:
>> On 12 Apr 2022 13:03:39 GMT, Stefan Ram wrote:
>
>>> [...]
>
>>         What for? Use parentheses - that's what they are there for.
>
> If you want to use parentheses, you should be writing in Lisp.  ;-)

When you write in Lisp, most of the formatting is automatic and almost
always looks good, so you can concentrate on coding.

There are some new developments in this area in the last few years,
like the "parinfer" algorithm. "parinfer" creates a two-way linkage
between indentation and parentheses. Write your code, adjusting
indentation as you go, and the right parentheses materialize
automatically. Or, tweak the parentheses and the indentation fixes
itself accordingly. Google for demos of this.
>
> Too many parentheses can make C code difficult to read.  Difficult to
> read translates to "more bugs".  A knowledge of C's precedence levels,
> at least to a moderate degree, can help avoid such bugs.

Too much complexity in one expression makes it hard to read. Other
than breaking it up into smaller expression, what can help is to
split it into multiple lines and use indentation.

Parenthesized expressions are much more amenable for splitting across
lines and indenting than pure infix operator expressions.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

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


Thread

Re: Memorizing C operator precedence Jens Stuckelberger <Jens_Stuckelberger@nowhere.net> - 2022-04-12 18:05 +0000
  Re: Memorizing C operator precedence Alan Mackenzie <acm@muc.de> - 2022-04-13 18:09 +0000
    Re: Memorizing C operator precedence Siri Cruise <chine.bleu@yahoo.com> - 2022-04-13 15:23 -0700
    Re: Memorizing C operator precedence Kaz Kylheku <480-992-1380@kylheku.com> - 2022-04-13 23:36 +0000
    Re: Memorizing C operator precedence Kaz Kylheku <480-992-1380@kylheku.com> - 2022-04-13 23:48 +0000
      Re: Memorizing C operator precedence Alan Mackenzie <acm@muc.de> - 2022-04-14 10:38 +0000
        Re: Memorizing C operator precedence Kaz Kylheku <480-992-1380@kylheku.com> - 2022-04-14 21:05 +0000
        Re: Memorizing C operator precedence Alan Mackenzie <acm@muc.de> - 2022-04-16 14:27 +0000
          Re: Memorizing C operator precedence Paul N <gw7rib@aol.com> - 2022-04-23 10:23 -0700
            Re: Memorizing C operator precedence Alan Mackenzie <acm@muc.de> - 2022-04-25 10:21 +0000
              Re: Memorizing C operator precedence Vir Campestris <vir.campestris@invalid.invalid> - 2022-04-25 16:43 +0100
                Re: Memorizing C operator precedence Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-04-26 03:02 -0700
                Re: Memorizing C operator precedence Kaz Kylheku <480-992-1380@kylheku.com> - 2022-04-26 13:58 +0000
            Re: Memorizing C operator precedence Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-04-25 14:48 -0700
        Re: Memorizing C operator precedence Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-04-25 15:16 -0700
          Re: Memorizing C operator precedence Alan Mackenzie <acm@muc.de> - 2022-04-26 10:34 +0000
            Re: Memorizing C operator precedence Ben <ben.usenet@bsb.me.uk> - 2022-04-26 13:13 +0100
              Re: Memorizing C operator precedence Alan Mackenzie <acm@muc.de> - 2022-04-26 17:25 +0000
            Re: Memorizing C operator precedence Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2022-04-26 06:12 -0700
              Re: Memorizing C operator precedence Alan Mackenzie <acm@muc.de> - 2022-04-26 17:17 +0000
            Re: Memorizing C operator precedence Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-04-30 07:05 -0700
    Re: Memorizing C operator precedence David Brown <david.brown@hesbynett.no> - 2022-04-14 12:39 +0200

csiph-web