Computer Old Farts Forum
 help / color / mirror / Atom feed
* [COFF] Formatting of Expressions.  (Was: Re: FD 2)
       [not found]                         ` <alpine.BSF.2.21.9999.2302010807480.82487@aneurin.horsfall.org>
@ 2023-02-01  9:36                           ` Ralph Corderoy
  0 siblings, 0 replies; only message in thread
From: Ralph Corderoy @ 2023-02-01  9:36 UTC (permalink / raw)
  To: coff

Hi Dave,

COFF'd.

> > I'll never do if (a==b&&c==d), always if ((a==b)&&(c==d)).
>
> Indeed; I *always* use parentheses even if they are not necessary (for
> my benefit, at least).

I find unnecessary parenthesis annoying and clutter which obscures
reading.  If parenthesis are used only when overriding the default
precedence then this beneficially draws attention to the exception.

I doubt mandatory parenthesis are used in maths formulas by those that
use them in expression.

Whitespace is beneficial in both maths formulas and expressions.  The
squashed expression above will often be spaced more.

    if (a==b && c==d)
    if (a == b && c == d)

Go's source formatter will vary which operators get spaces to reflect
precedence, e.g. https://go.dev/play/p/TU95Oz57GuF shows ‘4*3’ differs.

    fmt.Println(4 * 3)
    fmt.Println(5 ^ 4*3)
    fmt.Println(5 ^ 4*3 + 2/1.9)

-- 
Cheers, Ralph.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-01  9:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CANCZdfrnO-a7bUGRVHtGLdkGFYeaNCyTzwdR1tO+keKkmKf9cA@mail.gmail.com>
     [not found] ` <CANCZdfqxAZRt-KUEeqqmpg4Q-D39cDQmqjQVSoQoJVYszSUa-A@mail.gmail.com>
     [not found]   ` <emfc4c1646-a458-4e3c-9e39-ca09e9935f74@e41218a5.com>
     [not found]     ` <CANCZdfp5PpSjbALMtC39=pZcfWxVrGpAfN8OnD7bYLt-WS3-zA@mail.gmail.com>
     [not found]       ` <202301300750.30U7oQTh013304@freefriends.org>
     [not found]         ` <CAKzdPgzUCv5yAyeUQAB36-ar_PEpTkgiVb1JqAmJ285kcKNh4A@mail.gmail.com>
     [not found]           ` <20230130150219.GD12306@mcvoy.com>
     [not found]             ` <CAEoi9W4Y=hK9CmCS5jTKRn++VRQ0oCq6JVQD+LeDqfG6yse9Rg@mail.gmail.com>
     [not found]               ` <20230130152703.GE12306@mcvoy.com>
     [not found]                 ` <CAEoi9W5LGcJrWAueKQES0H2L=EG+BkzZ83KmZMxQE=AtE1pn7w@mail.gmail.com>
     [not found]                   ` <20230130154555.GF12306@mcvoy.com>
     [not found]                     ` <CAEoi9W60rwcUwOS4wZooZtnRg3cUPbQFR5vDjXnVO0vxRtSMhw@mail.gmail.com>
     [not found]                       ` <alpine.DEB.2.21.2301301115080.5005@sd-119843.dedibox.fr>
     [not found]                         ` <alpine.BSF.2.21.9999.2302010807480.82487@aneurin.horsfall.org>
2023-02-01  9:36                           ` [COFF] Formatting of Expressions. (Was: Re: FD 2) Ralph Corderoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).