Computer Old Farts Forum
 help / color / mirror / Atom feed
From: Ralph Corderoy <ralph@inputplus.co.uk>
To: coff@tuhs.org
Subject: [COFF] Formatting of Expressions.  (Was: Re: FD 2)
Date: Wed, 01 Feb 2023 09:36:31 +0000	[thread overview]
Message-ID: <20230201093631.704E921E5F@orac.inputplus.co.uk> (raw)
In-Reply-To: <alpine.BSF.2.21.9999.2302010807480.82487@aneurin.horsfall.org>

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.

           reply	other threads:[~2023-02-01  9:36 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <alpine.BSF.2.21.9999.2302010807480.82487@aneurin.horsfall.org>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230201093631.704E921E5F@orac.inputplus.co.uk \
    --to=ralph@inputplus.co.uk \
    --cc=coff@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).