Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A LISP programmer knows the value of everything, but the cost of nothing. -- Alan Perlis


devel / comp.lang.c / Re: Memorizing C operator precedence

SubjectAuthor
* Memorizing C operator precedenceStefan Ram
+* Re: Memorizing C operator precedenceBen
|`- Re: Memorizing C operator precedencefir
+- Re: Memorizing C operator precedenceStefan Ram
+- Re: Memorizing C operator precedenceAndrey Tarasevich
+* Re: Memorizing C operator precedenceJens Stuckelberger
|`* Re: Memorizing C operator precedenceAlan Mackenzie
| +* Re: Memorizing C operator precedenceStefan Ram
| |`- Re: Memorizing C operator precedenceKaz Kylheku
| +- Re: Memorizing C operator precedenceSiri Cruise
| +* Re: Memorizing C operator precedenceKaz Kylheku
| |`* Re: Memorizing C operator precedenceAlan Mackenzie
| | +- Re: Memorizing C operator precedenceKaz Kylheku
| | +* Re: Memorizing C operator precedenceStefan Ram
| | |`* Re: Memorizing C operator precedenceAlan Mackenzie
| | | `* Re: Memorizing C operator precedencePaul N
| | |  +* Re: Memorizing C operator precedenceAlan Mackenzie
| | |  |`* Re: Memorizing C operator precedenceVir Campestris
| | |  | +- Re: Memorizing C operator precedenceMalcolm McLean
| | |  | `- Re: Memorizing C operator precedenceKaz Kylheku
| | |  `- Re: Memorizing C operator precedenceTim Rentsch
| | `* Re: Memorizing C operator precedenceTim Rentsch
| |  `* Re: Memorizing C operator precedenceAlan Mackenzie
| |   +* Re: Memorizing C operator precedenceBen
| |   |`- Re: Memorizing C operator precedenceAlan Mackenzie
| |   +* Re: Memorizing C operator precedenceMalcolm McLean
| |   |`- Re: Memorizing C operator precedenceAlan Mackenzie
| |   `- Re: Memorizing C operator precedenceTim Rentsch
| `- Re: Memorizing C operator precedenceDavid Brown
`* Re: Memorizing C operator precedenceChristian HannĂ©
 +* Re: Memorizing C operator precedenceGuillaume
 |`- Re: Memorizing C operator precedenceKeith Thompson
 `* Re: Memorizing C operator precedenceKaz Kylheku
  `* Re: Memorizing C operator precedenceKenny McCormack
   `- Re: Memorizing C operator precedenceKaz Kylheku

Pages:12
Re: Memorizing C operator precedence

<86levs6c6n.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21472&group=comp.lang.c#21472

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Memorizing C operator precedence
Date: Mon, 25 Apr 2022 15:16:48 -0700
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <86levs6c6n.fsf@linuxsc.com>
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="e7f354bf3c65e91fece722955444236f";
logging-data="32215"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UOlxtW1dvvbihn+ijS5mrvkVchtNpSmw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Pgbt91xMP90/+gX3efQvvLY6QLw=
sha1:vWbtvWUTM3X2uBaX1HgOt6Y2WVo=
 by: Tim Rentsch - Mon, 25 Apr 2022 22:16 UTC

Alan Mackenzie <acm@muc.de> writes:

> Kaz Kylheku <480-992-1380@kylheku.com> wrote:
>
>> On 2022-04-13, Alan Mackenzie <acm@muc.de> wrote:

[...]

>>> 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.

I definitely agree with this.

>> Too much complexity in one expression makes it hard to read.

I also agree with this.

>> Other
>> than breaking it up into smaller expression, what can help is to
>> split it into multiple lines and use indentation.

Sometimes, but rarely. In most cases another choice is better.

> This is a common attitude, and I'm sure it is wrong a lot of the time.
> Breaking up a complicated expression _fragments_ it - it spreads it over
> a greater number of source code lines, some of which may not be visible
> on the screen. While each fragment may in itself be easier to read, the
> entire expression has become more difficult.
>
>> Parenthesized expressions are much more amenable for splitting across
>> lines and indenting than pure infix operator expressions.

Yuck. Any expression complicated enough to need parentheses
_and_ multiple lines _and_ some indication of nesting merits
rewriting into simpler components.

> I'm not sure I agree with this, my background being the maintainer of
> Emacs's CC Mode.
>
> How about a real world example? In the following (from Emacs's
> syntax.c):
>
> if (code == Sendcomment
> && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style
> && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ?
> (nesting > 0 && --nesting == 0) : nesting < 0)
> && !comment_ender_quoted (from, from_byte, syntax))
>
> , which is a moderately complicated example, extra parentheses around
> the operands of the &&s would clutter up the code rather than clarifying
> it. Yet the whole expression being on just five lines makes it
> relatively easy to understand.

I'm a longtime emacs user, and definitely a fan, but this code
is horrible, on several different levels. I agree that adding
extra parentheses around the &&s operands would make things
worse, but it's already way below threshold for any reasonable
standard of code review.

Just my unabashed impressions.. :)

Re: Memorizing C operator precedence

<fcd20f44-525f-42da-b95b-301433a22ad5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21475&group=comp.lang.c#21475

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:b4d:0:b0:69f:7742:9778 with SMTP id 74-20020a370b4d000000b0069f77429778mr1268057qkl.109.1650967368122;
Tue, 26 Apr 2022 03:02:48 -0700 (PDT)
X-Received: by 2002:a05:622a:12:b0:2f3:3ea5:71db with SMTP id
x18-20020a05622a001200b002f33ea571dbmr14591931qtw.411.1650967367931; Tue, 26
Apr 2022 03:02:47 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 26 Apr 2022 03:02:47 -0700 (PDT)
In-Reply-To: <t46fih$qkr$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:d137:ca9a:1203:6caa;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:d137:ca9a:1203:6caa
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org>
<t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com>
<t38tjs$cnl$1@news.muc.de> <extract-variable-20220415185849@ram.dialup.fu-berlin.de>
<t3ejp3$2ch3$1@news.muc.de> <6295432d-6ca9-49ea-b29c-858de4b65b75n@googlegroups.com>
<t45sne$2r7r$1@news.muc.de> <t46fih$qkr$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fcd20f44-525f-42da-b95b-301433a22ad5n@googlegroups.com>
Subject: Re: Memorizing C operator precedence
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Tue, 26 Apr 2022 10:02:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: Malcolm McLean - Tue, 26 Apr 2022 10:02 UTC

On Monday, 25 April 2022 at 16:43:25 UTC+1, Vir Campestris wrote:
> On 25/04/2022 11:21, Alan Mackenzie wrote:
> > I think that is the best of all! Inserting brief, meaningful comments,
> > as above, makes the thing easy to understand without bloating the code.
> > I wish more people would code like this.
> Absolutely.
>
> It has the great advantage that the comments say what the code is
> _supposed_ to do. If they disagree that's a great big alarm bell to
> anyone looking for bugs.
>
> "self documenting code" doesn't do that.
>
However code tends to change over time. Since the compiler has no way
of understanding the comments, it can't warn when a comment is not
updated to reflect a change in the code.
If you have a "self-documenting" language or system, like Doxygen, which
ties comments to code features, then you can issue such warnings.

Re: Memorizing C operator precedence

<t48hs2$urk$1@news.muc.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21476&group=comp.lang.c#21476

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: acm...@muc.de (Alan Mackenzie)
Newsgroups: comp.lang.c
Subject: Re: Memorizing C operator precedence
Date: Tue, 26 Apr 2022 10:34:42 -0000 (UTC)
Organization: muc.de e.V.
Message-ID: <t48hs2$urk$1@news.muc.de>
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de> <86levs6c6n.fsf@linuxsc.com>
Injection-Date: Tue, 26 Apr 2022 10:34:42 -0000 (UTC)
Injection-Info: news.muc.de; posting-host="news.muc.de:2001:608:1000::2";
logging-data="31604"; mail-complaints-to="news-admin@muc.de"
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (FreeBSD/12.3-RELEASE-p5 (amd64))
 by: Alan Mackenzie - Tue, 26 Apr 2022 10:34 UTC

Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
> Alan Mackenzie <acm@muc.de> writes:

>> Kaz Kylheku <480-992-1380@kylheku.com> wrote:

>>> On 2022-04-13, Alan Mackenzie <acm@muc.de> wrote:

> [...]

>>>> 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.

> I definitely agree with this.

>>> Too much complexity in one expression makes it hard to read.

> I also agree with this.

>>> Other
>>> than breaking it up into smaller expression, what can help is to
>>> split it into multiple lines and use indentation.

> Sometimes, but rarely. In most cases another choice is better.

>> This is a common attitude, and I'm sure it is wrong a lot of the time.
>> Breaking up a complicated expression _fragments_ it - it spreads it over
>> a greater number of source code lines, some of which may not be visible
>> on the screen. While each fragment may in itself be easier to read, the
>> entire expression has become more difficult.

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

> Yuck. Any expression complicated enough to need parentheses
> _and_ multiple lines _and_ some indication of nesting merits
> rewriting into simpler components.

That was my point. Such rewriting bloats code, making it more difficult,
as a whole, to understand.

>> I'm not sure I agree with this, my background being the maintainer of
>> Emacs's CC Mode.

>> How about a real world example? In the following (from Emacs's
>> syntax.c):

>> if (code == Sendcomment
>> && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style
>> && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ?
>> (nesting > 0 && --nesting == 0) : nesting < 0)
>> && !comment_ender_quoted (from, from_byte, syntax))

>> , which is a moderately complicated example, extra parentheses around
>> the operands of the &&s would clutter up the code rather than
>> clarifying it. Yet the whole expression being on just five lines
>> makes it relatively easy to understand.

> I'm a longtime emacs user, and definitely a fan, but this code
> is horrible, on several different levels.

I disagree. The condition being coded is "horrible", so the code cannot
be "nice". That condition is testing whether an ostensible comment ender
actually ends a comment. There are several things to test, namely,
that we're not trying to end a // comment with */, that the comment, if
nested (this can happen, for example, in Lisp or Pascal), reaches the
outer level of nesting, and that the comment ender isn't quoted.

> I agree that adding extra parentheses around the &&s operands would
> make things worse, ....

Agreed.

> .... but it's already way below threshold for any reasonable standard
> of code review.

This is simply untrue. That piece of code has been reviewed many times,
including by me, and presents no particular difficulties in
understanding.

I don't think it could be written better.

> Just my unabashed impressions.. :)

--
Alan Mackenzie (Nuremberg, Germany).

Re: Memorizing C operator precedence

<871qxkqbyj.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21477&group=comp.lang.c#21477

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben)
Newsgroups: comp.lang.c
Subject: Re: Memorizing C operator precedence
Date: Tue, 26 Apr 2022 13:13:40 +0100
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <871qxkqbyj.fsf@bsb.me.uk>
References: <memo-20220412132213@ram.dialup.fu-berlin.de>
<t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de>
<20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de>
<86levs6c6n.fsf@linuxsc.com> <t48hs2$urk$1@news.muc.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="85664e1ccf3261638e2e61e9936c7a03";
logging-data="31203"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//V9CPDJr81jkz41Gfb/SCbGQ7gUGBhCw="
Cancel-Lock: sha1:HbD5j0/KNNZzoPo/0pnw82IGQ9o=
sha1:RAb37CB4Pe1V81Y/JolI6IB0jGk=
X-BSB-Auth: 1.70ae7dcacb179c184a39.20220426131340BST.871qxkqbyj.fsf@bsb.me.uk
 by: Ben - Tue, 26 Apr 2022 12:13 UTC

Alan Mackenzie <acm@muc.de> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>> Alan Mackenzie <acm@muc.de> writes:

>>> How about a real world example? In the following (from Emacs's
>>> syntax.c):
>
>>> if (code == Sendcomment
>>> && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style
>>> && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ?
>>> (nesting > 0 && --nesting == 0) : nesting < 0)
>>> && !comment_ender_quoted (from, from_byte, syntax))
>
>>> , which is a moderately complicated example, extra parentheses around
>>> the operands of the &&s would clutter up the code rather than
>>> clarifying it. Yet the whole expression being on just five lines
>>> makes it relatively easy to understand.
>
>> I'm a longtime emacs user, and definitely a fan, but this code
>> is horrible, on several different levels.
>
> I disagree. The condition being coded is "horrible", so the code cannot
> be "nice". That condition is testing whether an ostensible comment ender
> actually ends a comment. There are several things to test, namely,
> that we're not trying to end a // comment with */, that the comment, if
> nested (this can happen, for example, in Lisp or Pascal), reaches the
> outer level of nesting, and that the comment ender isn't quoted.
>
>> I agree that adding extra parentheses around the &&s operands would
>> make things worse, ....
>
> Agreed.
>
>> .... but it's already way below threshold for any reasonable standard
>> of code review.
>
> This is simply untrue. That piece of code has been reviewed many times,
> including by me, and presents no particular difficulties in
> understanding.
>
> I don't think it could be written better.

One concern is that this is not a plain condition since it sometimes has
side effects. I'm comfortable with trivial cases of that (while (*cp++)
.... for example) but there is more to check here. For example, it's not
obvious that the conditional decrement must not happen when the rather
opaque condition

SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style

is false.

And I also find myself wondering why the value of nesting is significant
when SYNTAX_FLAGS_COMMENT_NESTED (syntax) is false. Is it playing some
dual role?

--
Ben.

Re: Memorizing C operator precedence

<c170f4ee-4c90-4291-af8b-478f98862cbfn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21478&group=comp.lang.c#21478

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:9ed7:0:b0:69e:a6bf:cc37 with SMTP id h206-20020a379ed7000000b0069ea6bfcc37mr13016323qke.744.1650978744422;
Tue, 26 Apr 2022 06:12:24 -0700 (PDT)
X-Received: by 2002:a05:6214:4108:b0:456:31ce:d5ff with SMTP id
kc8-20020a056214410800b0045631ced5ffmr9120302qvb.127.1650978744216; Tue, 26
Apr 2022 06:12:24 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Tue, 26 Apr 2022 06:12:24 -0700 (PDT)
In-Reply-To: <t48hs2$urk$1@news.muc.de>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:b5b6:e426:bfae:e19a;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:b5b6:e426:bfae:e19a
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org>
<t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com>
<t38tjs$cnl$1@news.muc.de> <86levs6c6n.fsf@linuxsc.com> <t48hs2$urk$1@news.muc.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c170f4ee-4c90-4291-af8b-478f98862cbfn@googlegroups.com>
Subject: Re: Memorizing C operator precedence
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Tue, 26 Apr 2022 13:12:24 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 115
 by: Malcolm McLean - Tue, 26 Apr 2022 13:12 UTC

On Tuesday, 26 April 2022 at 11:34:55 UTC+1, Alan Mackenzie wrote:
> Tim Rentsch <tr.1...@z991.linuxsc.com> wrote:
> > Alan Mackenzie <a...@muc.de> writes:
>
> >> Kaz Kylheku <480-99...@kylheku.com> wrote:
>
> >>> On 2022-04-13, Alan Mackenzie <a...@muc.de> wrote:
>
> > [...]
>
> >>>> 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.
>
> > I definitely agree with this.
>
> >>> Too much complexity in one expression makes it hard to read.
>
> > I also agree with this.
>
> >>> Other
> >>> than breaking it up into smaller expression, what can help is to
> >>> split it into multiple lines and use indentation.
>
> > Sometimes, but rarely. In most cases another choice is better.
>
> >> This is a common attitude, and I'm sure it is wrong a lot of the time.
> >> Breaking up a complicated expression _fragments_ it - it spreads it over
> >> a greater number of source code lines, some of which may not be visible
> >> on the screen. While each fragment may in itself be easier to read, the
> >> entire expression has become more difficult.
>
> >>> Parenthesized expressions are much more amenable for splitting across
> >>> lines and indenting than pure infix operator expressions.
>
> > Yuck. Any expression complicated enough to need parentheses
> > _and_ multiple lines _and_ some indication of nesting merits
> > rewriting into simpler components.
> That was my point. Such rewriting bloats code, making it more difficult,
> as a whole, to understand.
> >> I'm not sure I agree with this, my background being the maintainer of
> >> Emacs's CC Mode.
>
> >> How about a real world example? In the following (from Emacs's
> >> syntax.c):
>
> >> if (code == Sendcomment
> >> && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style
> >> && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ?
> >> (nesting > 0 && --nesting == 0) : nesting < 0)
> >> && !comment_ender_quoted (from, from_byte, syntax))
>
> >> , which is a moderately complicated example, extra parentheses around
> >> the operands of the &&s would clutter up the code rather than
> >> clarifying it. Yet the whole expression being on just five lines
> >> makes it relatively easy to understand.
>
> > I'm a longtime emacs user, and definitely a fan, but this code
> > is horrible, on several different levels.
> I disagree. The condition being coded is "horrible", so the code cannot
> be "nice". That condition is testing whether an ostensible comment ender
> actually ends a comment. There are several things to test, namely,
> that we're not trying to end a // comment with */, that the comment, if
> nested (this can happen, for example, in Lisp or Pascal), reaches the
> outer level of nesting, and that the comment ender isn't quoted.
> > I agree that adding extra parentheses around the &&s operands would
> > make things worse, ....
>
> Agreed.
>
> > .... but it's already way below threshold for any reasonable standard
> > of code review.
>
> This is simply untrue. That piece of code has been reviewed many times,
> including by me, and presents no particular difficulties in
> understanding.
>
> I don't think it could be written better.
>
/*
Does a comment ender token actually end a comment?
Params: code - the token (e.g. Sendcomment, Receivecomment [Malcolm ??])
syntax - syntax flags for current comment style (see SYNTAX_FLAGS)
style - current comment style [Malcolm, how does this differ from syntax?]
nesting - nesting level (note can be negative [Malcolm, explain how])
from - start of comment
from_byte - [Malcolm ???]
Returns: true if the comment ends, else false.
*/
bool is_comment_ended(int code, unsigned int syntax, unsigned int style, int nesting, char *from, char from_byte)
{ if (code != Sendcomment)
return false; // Not an end comment token
if (SYNTAX_FLAGS_COMMENT_STYLE(syntax, 0) != style)
return false; // Wrong comment style
if (SYNTAX_FLAGS_COMMENT_NESTED(syntax))
{
if (nesting != 1)
return false; // in a nested comment
}
else
{
if (nesting < 0)
return false; // [Malcolm - suspect nasty hack here, why can nesting go negative?]
}
if (comment_ender_quoted(from, from_byte, syntax))
return false; // Comment ender token is in quotes, not a comment ender

// All tests passed, must be valid comment ender.
return true;
}

Now you need to fix up the decrement on the nesting flag. That should be done outside
of the test, as it is logically separate from it.
The Malcolm comments are because Malcolm, who is totally unfamilar with the code, has
dived in and tried to fix it.Naturally they should be replaced.

Re: Memorizing C operator precedence

<20220426065706.709@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21480&group=comp.lang.c#21480

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Memorizing C operator precedence
Date: Tue, 26 Apr 2022 13:58:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <20220426065706.709@kylheku.com>
References: <memo-20220412132213@ram.dialup.fu-berlin.de>
<t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de>
<20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de>
<extract-variable-20220415185849@ram.dialup.fu-berlin.de>
<t3ejp3$2ch3$1@news.muc.de>
<6295432d-6ca9-49ea-b29c-858de4b65b75n@googlegroups.com>
<t45sne$2r7r$1@news.muc.de> <t46fih$qkr$1@dont-email.me>
Injection-Date: Tue, 26 Apr 2022 13:58:11 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="08271151a6d20611ec2715656efe93ee";
logging-data="16550"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gEAz4CpbFlNKpHRDv+7gj+o4oWf3N53g="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:demL39p6FmK5f9g1CeNee/ncMos=
 by: Kaz Kylheku - Tue, 26 Apr 2022 13:58 UTC

On 2022-04-25, Vir Campestris <vir.campestris@invalid.invalid> wrote:
> On 25/04/2022 11:21, Alan Mackenzie wrote:
>> I think that is the best of all! Inserting brief, meaningful comments,
>> as above, makes the thing easy to understand without bloating the code.
>> I wish more people would code like this.
>
> Absolutely.
>
> It has the great advantage that the comments say what the code is
> _supposed_ to do. If they disagree that's a great big alarm bell to
> anyone looking for bugs.
>
> "self documenting code" doesn't do that.

I will take a set of test cases that break right away, over some comment
that started lying 13 years ago, but nobody noticed untl now.

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

Re: Memorizing C operator precedence

<t499fu$13fs$1@news.muc.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21486&group=comp.lang.c#21486

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: acm...@muc.de (Alan Mackenzie)
Newsgroups: comp.lang.c
Subject: Re: Memorizing C operator precedence
Date: Tue, 26 Apr 2022 17:17:50 -0000 (UTC)
Organization: muc.de e.V.
Message-ID: <t499fu$13fs$1@news.muc.de>
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de> <86levs6c6n.fsf@linuxsc.com> <t48hs2$urk$1@news.muc.de> <c170f4ee-4c90-4291-af8b-478f98862cbfn@googlegroups.com>
Injection-Date: Tue, 26 Apr 2022 17:17:50 -0000 (UTC)
Injection-Info: news.muc.de; posting-host="news.muc.de:2001:608:1000::2";
logging-data="36348"; mail-complaints-to="news-admin@muc.de"
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (FreeBSD/12.3-RELEASE-p5 (amd64))
 by: Alan Mackenzie - Tue, 26 Apr 2022 17:17 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> On Tuesday, 26 April 2022 at 11:34:55 UTC+1, Alan Mackenzie wrote:
>> Tim Rentsch <tr.1...@z991.linuxsc.com> wrote:
>> > Alan Mackenzie <a...@muc.de> writes:

>> >> Kaz Kylheku <480-99...@kylheku.com> wrote:

>> >>> On 2022-04-13, Alan Mackenzie <a...@muc.de> wrote:

>> > [...]

>> >>>> 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.

>> > I definitely agree with this.

>> >>> Too much complexity in one expression makes it hard to read.

>> > I also agree with this.

>> >>> Other than breaking it up into smaller expression, what can help
>> >>> is to split it into multiple lines and use indentation.

>> > Sometimes, but rarely. In most cases another choice is better.

>> >> This is a common attitude, and I'm sure it is wrong a lot of the
>> >> time. Breaking up a complicated expression _fragments_ it - it
>> >> spreads it over a greater number of source code lines, some of
>> >> which may not be visible on the screen. While each fragment may in
>> >> itself be easier to read, the entire expression has become more
>> >> difficult.

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

>> > Yuck. Any expression complicated enough to need parentheses _and_
>> > multiple lines _and_ some indication of nesting merits rewriting
>> > into simpler components.

>> That was my point. Such rewriting bloats code, making it more
>> difficult, as a whole, to understand.

>> >> I'm not sure I agree with this, my background being the maintainer
>> >> of Emacs's CC Mode.

>> >> How about a real world example? In the following (from Emacs's
>> >> syntax.c):

>> >> if (code == Sendcomment
>> >> && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style
>> >> && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ?
>> >> (nesting > 0 && --nesting == 0) : nesting < 0)
>> >> && !comment_ender_quoted (from, from_byte, syntax))

>> >> , which is a moderately complicated example, extra parentheses
>> >> around the operands of the &&s would clutter up the code rather
>> >> than clarifying it. Yet the whole expression being on just five
>> >> lines makes it relatively easy to understand.

>> > I'm a longtime emacs user, and definitely a fan, but this code
>> > is horrible, on several different levels.

>> I disagree. The condition being coded is "horrible", so the code
>> cannot be "nice". That condition is testing whether an ostensible
>> comment ender actually ends a comment. There are several things to
>> test, namely, that we're not trying to end a // comment with */, that
>> the comment, if nested (this can happen, for example, in Lisp or
>> Pascal), reaches the outer level of nesting, and that the comment
>> ender isn't quoted.

>> > I agree that adding extra parentheses around the &&s operands would
>> > make things worse, ....

>> Agreed.

>> > .... but it's already way below threshold for any reasonable
>> > standard of code review.

>> This is simply untrue. That piece of code has been reviewed many
>> times, including by me, and presents no particular difficulties in
>> understanding.

>> I don't think it could be written better.

> /*
> Does a comment ender token actually end a comment?
> Params: code - the token (e.g. Sendcomment, Receivecomment [Malcolm ??])
> syntax - syntax flags for current comment style (see SYNTAX_FLAGS)
> style - current comment style [Malcolm, how does this differ from syntax?]
> nesting - nesting level (note can be negative [Malcolm, explain how])
> from - start of comment
> from_byte - [Malcolm ???]
> Returns: true if the comment ends, else false.
> */
> bool is_comment_ended(int code, unsigned int syntax, unsigned int style, int nesting, char *from, char from_byte)
> {
> if (code != Sendcomment)
> return false; // Not an end comment token
> if (SYNTAX_FLAGS_COMMENT_STYLE(syntax, 0) != style)
> return false; // Wrong comment style
> if (SYNTAX_FLAGS_COMMENT_NESTED(syntax))
> {
> if (nesting != 1)
> return false; // in a nested comment
> }
> else
> {
> if (nesting < 0)
> return false; // [Malcolm - suspect nasty hack here, why can nesting go negative?]
> }
> if (comment_ender_quoted(from, from_byte, syntax))
> return false; // Comment ender token is in quotes, not a comment ender

> // All tests passed, must be valid comment ender.
> return true;
> }

You make my point more eloquently than I could. ;-) 5 lines have become
20 non-comment lines plus comments, and several more lines will be needed
to handle the decrementation of the variable `nesting'. These 20 lines
have been fragmented from the context where they formally belonged. Or,
in plain English, you've got to keep moving backwards and forwards
between this new functiom and the calling point to understand things.

This new function is a bit like the long gentle ramp often seen at the
entrance to public buildings for the benefit of wheelchair users. It is
less effort to walk up than climbing the stairs, since each step is
gentler, but the total time and energy expended is much more. Otherwise,
able bodied people would walk up the ramp rather than climbing the
stairs. In this analogy, the stairs correspond with the five line
original piece of code.

> Now you need to fix up the decrement on the nesting flag. That should
> be done outside of the test, as it is logically separate from it.

Perhaps, perhaps not. If one construes the 5-line original as "handle a
comment closer", then decrementing the nesting level is an integral part
of it.

> The Malcolm comments are because Malcolm, who is totally unfamilar with
> the code, has dived in and tried to fix it.Naturally they should be
> replaced.

:-)

There're quite a lot of pieces of code like my original citation in the
Emacs C code. I can't remember there ever being a call to make it less
compact.

--
Alan Mackenzie (Nuremberg, Germany).

Re: Memorizing C operator precedence

<t499v1$13fs$2@news.muc.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21488&group=comp.lang.c#21488

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.in-chemnitz.de!news2.arglkargh.de!news.karotte.org!news.space.net!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: acm...@muc.de (Alan Mackenzie)
Newsgroups: comp.lang.c
Subject: Re: Memorizing C operator precedence
Date: Tue, 26 Apr 2022 17:25:53 -0000 (UTC)
Organization: muc.de e.V.
Message-ID: <t499v1$13fs$2@news.muc.de>
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de> <86levs6c6n.fsf@linuxsc.com> <t48hs2$urk$1@news.muc.de> <871qxkqbyj.fsf@bsb.me.uk>
Injection-Date: Tue, 26 Apr 2022 17:25:53 -0000 (UTC)
Injection-Info: news.muc.de; posting-host="news.muc.de:2001:608:1000::2";
logging-data="36348"; mail-complaints-to="news-admin@muc.de"
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (FreeBSD/12.3-RELEASE-p5 (amd64))
 by: Alan Mackenzie - Tue, 26 Apr 2022 17:25 UTC

Ben <ben.usenet@bsb.me.uk> wrote:
> Alan Mackenzie <acm@muc.de> writes:

>> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>>> Alan Mackenzie <acm@muc.de> writes:

>>>> How about a real world example? In the following (from Emacs's
>>>> syntax.c):

>>>> if (code == Sendcomment
>>>> && SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style
>>>> && (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ?
>>>> (nesting > 0 && --nesting == 0) : nesting < 0)
>>>> && !comment_ender_quoted (from, from_byte, syntax))

>>>> , which is a moderately complicated example, extra parentheses around
>>>> the operands of the &&s would clutter up the code rather than
>>>> clarifying it. Yet the whole expression being on just five lines
>>>> makes it relatively easy to understand.

>>> I'm a longtime emacs user, and definitely a fan, but this code
>>> is horrible, on several different levels.

>> I disagree. The condition being coded is "horrible", so the code cannot
>> be "nice". That condition is testing whether an ostensible comment ender
>> actually ends a comment. There are several things to test, namely,
>> that we're not trying to end a // comment with */, that the comment, if
>> nested (this can happen, for example, in Lisp or Pascal), reaches the
>> outer level of nesting, and that the comment ender isn't quoted.

>>> I agree that adding extra parentheses around the &&s operands would
>>> make things worse, ....

>> Agreed.

>>> .... but it's already way below threshold for any reasonable standard
>>> of code review.

>> This is simply untrue. That piece of code has been reviewed many times,
>> including by me, and presents no particular difficulties in
>> understanding.

>> I don't think it could be written better.

> One concern is that this is not a plain condition since it sometimes
> has side effects. I'm comfortable with trivial cases of that (while
> (*cp++) ... for example) but there is more to check here. For example,
> it's not obvious that the conditional decrement must not happen when
> the rather opaque condition

> SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style

> is false.

That condition just checks that we're not trying to close a C line
comment with a */, for example.

> And I also find myself wondering why the value of nesting is significant
> when SYNTAX_FLAGS_COMMENT_NESTED (syntax) is false. Is it playing some
> dual role?

Yes, unfortunately so. There's an ad-hoc convention where this variable
is -1 in non-nested comments. It plays a role where there are both
nested and non-nested comments in a language (such as Common Lisp).

> --
> Ben.

--
Alan Mackenzie (Nuremberg, Germany).

Re: Memorizing C operator precedence

<86v8uq4qfg.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21568&group=comp.lang.c#21568

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Memorizing C operator precedence
Date: Sat, 30 Apr 2022 07:05:39 -0700
Organization: A noiseless patient Spider
Lines: 187
Message-ID: <86v8uq4qfg.fsf@linuxsc.com>
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <t34f1f$s4u$1@gioia.aioe.org> <t373kj$1avk$1@news.muc.de> <20220413163721.82@kylheku.com> <t38tjs$cnl$1@news.muc.de> <86levs6c6n.fsf@linuxsc.com> <t48hs2$urk$1@news.muc.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="947a81ba8a661bedfa1d3062f5b6bffa";
logging-data="27619"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/grzvylyAPD7ck9qO+SlFu/Aer4FI7F+Y="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:0PO2y1yuwFAsHKlZ2dRfqmEiFiE=
sha1:X/5mG4G87WbkxeG6gMC6l2XWm8E=
 by: Tim Rentsch - Sat, 30 Apr 2022 14:05 UTC

Alan Mackenzie <acm@muc.de> writes:

> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

[...]

I should note here that I have read through your previous
comments but don't have any response to them at this time.

>> .... but it's already way below threshold for any reasonable
>> standard of code review.
>
> This is simply untrue.

My statement is a statement of opinion, not a statement of fact,
and so it is neither true nor false -- it is just my opinion.

> That piece of code has been reviewed many times, including by
> me, and presents no particular difficulties in understanding.
>
> I don't think it could be written better.

Different people have different metrics for "better". I'm
interested to hear reactions from other people on this question.

To give some additional context, below is the function forw_comment,
taken from syntax.c in emacs 28.1, and which containts the if()
expression (or something very much like it) under discussion.

What do other comp.lang.c folks think of the code below? Does it
present any difficulties in understanding it? Can or should it
be revised to make it "better"? If yes, what kinds of changes
would make it better? Any other comments are also welcome.

(The excerpt below starts with a function-level comment, and after
that has one C function definition. There is no indentation except
what was present in the original code, and there is nothing more in
the posting after the excerpt.)

/* Jump over a comment, assuming we are at the beginning of one.
FROM is the current position.
FROM_BYTE is the bytepos corresponding to FROM.
Do not move past STOP (a charpos).
The comment over which we have to jump is of style STYLE
(either SYNTAX_FLAGS_COMMENT_STYLE (foo) or ST_COMMENT_STYLE).
NESTING should be positive to indicate the nesting at the beginning
for nested comments and should be zero or negative else.
ST_COMMENT_STYLE cannot be nested.
PREV_SYNTAX is the SYNTAX_WITH_FLAGS of the previous character
(or 0 if the search cannot start in the middle of a two-character).

If successful, return true and store the charpos of the comment's
end into *CHARPOS_PTR and the corresponding bytepos into
*BYTEPOS_PTR. Else, return false and store the charpos STOP into
*CHARPOS_PTR, the corresponding bytepos into *BYTEPOS_PTR and the
current nesting (as defined for state->incomment) in
*INCOMMENT_PTR. Should the last character scanned in an incomplete
comment be a possible first character of a two character construct,
we store its SYNTAX_WITH_FLAGS into *last_syntax_ptr. Otherwise,
we store Smax into *last_syntax_ptr.

The comment end is the last character of the comment rather than the
character just after the comment.

Global syntax data is assumed to initially be valid for FROM and
remains valid for forward search starting at the returned position. */

static bool
forw_comment (ptrdiff_t from, ptrdiff_t from_byte, ptrdiff_t stop,
EMACS_INT nesting, int style, int prev_syntax,
ptrdiff_t *charpos_ptr, ptrdiff_t *bytepos_ptr,
EMACS_INT *incomment_ptr, int *last_syntax_ptr)
{ unsigned short int quit_count = 0;
int c, c1;
enum syntaxcode code;
int syntax, other_syntax;

if (nesting <= 0) nesting = -1;

/* Enter the loop in the middle so that we find
a 2-char comment ender if we start in the middle of it. */
syntax = prev_syntax;
code = syntax & 0xff;
if (syntax != 0 && from < stop) goto forw_incomment;

while (1)
{
if (from == stop)
{
*incomment_ptr = nesting;
*charpos_ptr = from;
*bytepos_ptr = from_byte;
*last_syntax_ptr =
(code == Sescape || code == Scharquote
|| SYNTAX_FLAGS_COMEND_FIRST (syntax)
|| (nesting > 0
&& SYNTAX_FLAGS_COMSTART_FIRST (syntax)))
? syntax : Smax ;
return 0;
}
c = FETCH_CHAR_AS_MULTIBYTE (from_byte);
syntax = SYNTAX_WITH_FLAGS (c);
code = syntax & 0xff;
if (code == Sendcomment
&& SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style
&& (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ?
(nesting > 0 && --nesting == 0) : nesting < 0)
&& !(comment_end_can_be_escaped && char_quoted (from, from_byte)))
/* We have encountered a comment end of the same style
as the comment sequence which began this comment
section. */
break;
if (code == Scomment_fence
&& style == ST_COMMENT_STYLE)
/* We have encountered a comment end of the same style
as the comment sequence which began this comment
section. */
break;
if (nesting > 0
&& code == Scomment
&& SYNTAX_FLAGS_COMMENT_NESTED (syntax)
&& SYNTAX_FLAGS_COMMENT_STYLE (syntax, 0) == style)
/* We have encountered a nested comment of the same style
as the comment sequence which began this comment section. */
nesting++;
if (comment_end_can_be_escaped
&& (code == Sescape || code == Scharquote))
{
inc_both (&from, &from_byte);
UPDATE_SYNTAX_TABLE_FORWARD (from);
if (from == stop) continue; /* Failure */
}
inc_both (&from, &from_byte);
UPDATE_SYNTAX_TABLE_FORWARD (from);

forw_incomment:
if (from < stop && SYNTAX_FLAGS_COMEND_FIRST (syntax)
&& (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte),
other_syntax = SYNTAX_WITH_FLAGS (c1),
SYNTAX_FLAGS_COMEND_SECOND (other_syntax))
&& SYNTAX_FLAGS_COMMENT_STYLE (syntax, other_syntax) == style
&& ((SYNTAX_FLAGS_COMMENT_NESTED (syntax) ||
SYNTAX_FLAGS_COMMENT_NESTED (other_syntax))
? nesting > 0 : nesting < 0))
{
syntax = Smax; /* So that "|#" (lisp) can not return
the syntax of "#" in *last_syntax_ptr. */
if (--nesting <= 0)
/* We have encountered a comment end of the same style
as the comment sequence which began this comment section. */
break;
else
{
inc_both (&from, &from_byte);
UPDATE_SYNTAX_TABLE_FORWARD (from);
}
}
if (nesting > 0
&& from < stop
&& SYNTAX_FLAGS_COMSTART_FIRST (syntax)
&& (c1 = FETCH_CHAR_AS_MULTIBYTE (from_byte),
other_syntax = SYNTAX_WITH_FLAGS (c1),
SYNTAX_FLAGS_COMMENT_STYLE (other_syntax, syntax) == style
&& SYNTAX_FLAGS_COMSTART_SECOND (other_syntax))
&& (SYNTAX_FLAGS_COMMENT_NESTED (syntax) ||
SYNTAX_FLAGS_COMMENT_NESTED (other_syntax)))
/* We have encountered a nested comment of the same style
as the comment sequence which began this comment section. */
{
syntax = Smax; /* So that "#|#" isn't also a comment ender. */
inc_both (&from, &from_byte);
UPDATE_SYNTAX_TABLE_FORWARD (from);
nesting++;
}

rarely_quit (++quit_count);
}
*charpos_ptr = from;
*bytepos_ptr = from_byte;
*last_syntax_ptr = Smax; /* Any syntactic power the last byte had is
used up. */
return 1;
}

Re: Memorizing C operator precedence

<317f5a24-6c0e-41ac-b25d-0b543673511fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21622&group=comp.lang.c#21622

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5905:0:b0:2f3:9fdd:22f1 with SMTP id 5-20020ac85905000000b002f39fdd22f1mr10271614qty.191.1652004654539;
Sun, 08 May 2022 03:10:54 -0700 (PDT)
X-Received: by 2002:a05:622a:1794:b0:2f3:cce5:498a with SMTP id
s20-20020a05622a179400b002f3cce5498amr7255563qtk.266.1652004654397; Sun, 08
May 2022 03:10:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 8 May 2022 03:10:54 -0700 (PDT)
In-Reply-To: <877d7u1kcc.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=5.172.255.190; posting-account=Sb6m8goAAABbWsBL7gouk3bfLsuxwMgN
NNTP-Posting-Host: 5.172.255.190
References: <memo-20220412132213@ram.dialup.fu-berlin.de> <877d7u1kcc.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <317f5a24-6c0e-41ac-b25d-0b543673511fn@googlegroups.com>
Subject: Re: Memorizing C operator precedence
From: profesor...@gmail.com (fir)
Injection-Date: Sun, 08 May 2022 10:10:54 +0000
Content-Type: text/plain; charset="UTF-8"
 by: fir - Sun, 8 May 2022 10:10 UTC

i dont remember them still.. thought probabbly it would be really nice
to learn them

for example i was surprised recently by bug in my code i wrote

if(!atoms.first[right_bracket ].beg[0]==']')

i thought ! negates this == , it showed i need to add

if(!(atoms.first[right_bracket ].beg[0]==']'))

which is unfortunate, fortunatelly at least some may write
if(atoms.first[right_bracket ].beg[0]!=']')

overally what is worse i got no or for for ifs i mean i much prefer like writing

if(a) if(b) if(c) than if(a && b && c)
and it is cool i can but i need or
if(a) if(b) if(c) or if(d) if(e) { }
and this dont work

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor