Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Don't fear the pen. When in doubt, draw a pretty picture." -- Baker's Third Law of Design.


devel / comp.lang.c / Re: How to disambiguate macro?

SubjectAuthor
* How to disambiguate macro?John Forkosh
+* Re: How to disambiguate macro?Ben Bacarisse
|`* Re: How to disambiguate macro?John Forkosh
| `* Re: How to disambiguate macro?Ben Bacarisse
|  `* Re: How to disambiguate macro?John Forkosh
|   +- Re: How to disambiguate macro?Andrey Tarasevich
|   +* Re: How to disambiguate macro?Keith Thompson
|   |`* Re: How to disambiguate macro?John Forkosh
|   | +- Re: How to disambiguate macro?Keith Thompson
|   | `- Re: How to disambiguate macro?James Kuyper
|   +* Re: How to disambiguate macro?James Kuyper
|   |`* Re: How to disambiguate macro?John Forkosh
|   | +- Re: How to disambiguate macro?Bart
|   | +- Re: How to disambiguate macro?David Brown
|   | +* Re: How to disambiguate macro?Ben Bacarisse
|   | |+* Re: How to disambiguate macro?Ben Bacarisse
|   | ||`* Re: How to disambiguate macro?Bart
|   | || +- Re: How to disambiguate macro?David Brown
|   | || `* Re: How to disambiguate macro?Ben Bacarisse
|   | ||  `* Re: How to disambiguate macro?Bart
|   | ||   +* Re: How to disambiguate macro?David Brown
|   | ||   |+* Re: How to disambiguate macro?Manfred
|   | ||   ||`- Re: How to disambiguate macro?David Brown
|   | ||   |`* Re: How to disambiguate macro?Bart
|   | ||   | `* Re: How to disambiguate macro?David Brown
|   | ||   |  +- Re: How to disambiguate macro?Bart
|   | ||   |  `* Re: How to disambiguate macro?antispam
|   | ||   |   `- Re: How to disambiguate macro?David Brown
|   | ||   `- Re: How to disambiguate macro?Ben Bacarisse
|   | |`* Re: How to disambiguate macro?Manfred
|   | | `- Re: How to disambiguate macro?Scott Lurndal
|   | +- Re: How to disambiguate macro?Andrey Tarasevich
|   | `* Re: How to disambiguate macro?James Kuyper
|   |  +- Re: How to disambiguate macro?Stefan Ram
|   |  +* Re: How to disambiguate macro?Keith Thompson
|   |  |`* Re: How to disambiguate macro?John Forkosh
|   |  | `- Re: How to disambiguate macro?James Kuyper
|   |  +* Re: How to disambiguate macro?John Forkosh
|   |  |+- Re: How to disambiguate macro?Scott Lurndal
|   |  |`- Re: How to disambiguate macro?Ben Bacarisse
|   |  `* OT: possessive adjectives (Was: How to disambiguate macro?)Manfred
|   |   `- Re: OT: possessive adjectivesTim Rentsch
|   `- Re: How to disambiguate macro?Tim Rentsch
+* Re: How to disambiguate macro?David Brown
|`* Re: How to disambiguate macro?John Forkosh
| +* Re: How to disambiguate macro?Bart
| |`- Re: How to disambiguate macro?David Brown
| +- Re: How to disambiguate macro?David Brown
| +- Re: How to disambiguate macro?David Brown
| `- Re: How to disambiguate macro?Tim Rentsch
+- Re: How to disambiguate macro?John Forkosh
`- Re: How to disambiguate macro?Andrey Tarasevich

Pages:123
Re: How to disambiguate macro?

<sd9a5q$qs0$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 15:15:14 +0100
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <sd9a5q$qs0$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Jul 2021 14:15:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d7735f54b1c6d948185852b1a363e0ec";
logging-data="27520"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XJhxp6qp9ipkdxNIDAT7RQgxIMG6WGE8="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:7jBvVGcaomJuIEwMZL7Ih1pyOeg=
In-Reply-To: <8735s7ls5z.fsf@bsb.me.uk>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210721-4, 21/7/2021), Outbound message
 by: Bart - Wed, 21 Jul 2021 14:15 UTC

On 21/07/2021 14:20, Ben Bacarisse wrote:
> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>
>> Neither B nor BCPL had short-circuit logical operators, relying instead
>> on bitwise & and |, as did early C.
>
> Minor correction. B didn't have short-circuit & and | as such, but it
> had a weird rule that in conditional contexts like
>
> if (a & b) ...
>
> the operator short-circuited! C rightly ditched this contextual
> interpretation in favour of explicitly short-circuiting operators.
>

That's not so weird. I used to have something similar (not in C) where
'A and B' (ie. logical and, also 'or') short-circuited in conditional
expressions as used in 'if' and 'while' control expressions, which
tended to be implemented with branching.

But in ordinary expressions, they didn't.

I now have and/or operators that always short-circuit, but I did briefly
have versions that never short-circuited. I called these 'andb' and
'orb' (the 'b' meaning evaluate both). However I couldn't think of
enough use-cases for them.

Evaluation of the second term can usually be forced when needed.

Re: How to disambiguate macro?

<sd9au6$m5$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 16:28:21 +0200
Organization: A noiseless patient Spider
Lines: 50
Message-ID: <sd9au6$m5$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 21 Jul 2021 14:28:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5034648778e76de81508b6aa8e6ee000";
logging-data="709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KLDdMsnojMgIzegPOpKX7ikW+hIK5gio="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:H4TvELF+lxLnVK7uTmiFqr/vNkI=
In-Reply-To: <sd9a5q$qs0$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Wed, 21 Jul 2021 14:28 UTC

On 21/07/2021 16:15, Bart wrote:
> On 21/07/2021 14:20, Ben Bacarisse wrote:
>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>
>>> Neither B nor BCPL had short-circuit logical operators, relying instead
>>> on bitwise & and |, as did early C.
>>
>> Minor correction.  B didn't have short-circuit & and | as such, but it
>> had a weird rule that in conditional contexts like
>>
>>    if (a & b) ...
>>
>> the operator short-circuited!  C rightly ditched this contextual
>> interpretation in favour of explicitly short-circuiting operators.
>>
>
> That's not so weird. I used to have something similar (not in C) where
> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
> expressions as used in 'if' and 'while' control expressions, which
> tended to be implemented with branching.
>
> But in ordinary expressions, they didn't.

It is perhaps not /weird/, but it is highly confusing and risky in the
face of side-effects. It is a seriously bad idea.

Borland Pascal (and Delphi) let you choose to make "and" (and "or")
short-circuiting as an optimisation option, controllable locally with
the Pascal equivalent of pragmas. Again, it is a dangerous idea.

If a language allows side-effects in expressions and sub-expressions,
then the programmer needs to know /exactly/ when they will be executed.
It's fine to say "a && b" is /always/ short-circuiting, and fine to say
it is /never/ short-circuiting - you know either way. It is a terrible
idea to say it is /sometimes/ short-circuiting, depending on how the
expression is used.

Of course, if "b" has no side-effects then it might be good for the
compiler to short-circuit it regardless of the language rules - but
that's just optimisation and efficiency, not a matter of language
semantics and program correctness.

>
> I now have and/or operators that always short-circuit, but I did briefly
> have versions that never short-circuited. I called these 'andb' and
> 'orb' (the 'b' meaning evaluate both). However I couldn't think of
> enough use-cases for them.
>
> Evaluation of the second term can usually be forced when needed.

Re: How to disambiguate macro?

<87sg07k82m.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 16:20:01 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <87sg07k82m.fsf@bsb.me.uk>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4cf7f3a355a2ef187a6fe4ebd693fd15";
logging-data="17879"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jrh6NADSNlMG3xQa14hAKnbuzZ9Upzxs="
Cancel-Lock: sha1:Ii81xH6gRligXXQwNMz5Gh87OIs=
sha1:nxFu0QOTDeHXngrzjiQFRFxGR1o=
X-BSB-Auth: 1.c3a387467a4bc3995e3a.20210721162001BST.87sg07k82m.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 21 Jul 2021 15:20 UTC

Bart <bc@freeuk.com> writes:

> On 21/07/2021 14:20, Ben Bacarisse wrote:
>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>
>>> Neither B nor BCPL had short-circuit logical operators, relying instead
>>> on bitwise & and |, as did early C.
>> Minor correction. B didn't have short-circuit & and | as such, but it
>> had a weird rule that in conditional contexts like
>> if (a & b) ...
>> the operator short-circuited! C rightly ditched this contextual
>> interpretation in favour of explicitly short-circuiting operators.
>
> That's not so weird. I used to have something similar (not in C) where
> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
> expressions as used in 'if' and 'while' control expressions, which
> tended to be implemented with branching.
>
> But in ordinary expressions, they didn't.

I'm don't see how this would persuade someone that it's not weird. A
private language is never going to be used by someone other than the
world authority on its semantics.

In public-facing languages, such context-sensitive semantics seem to me
to be the epitome of "weird".

--
Ben.

Re: How to disambiguate macro?

<adXJI.28783$qk6.7168@fx36.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: How to disambiguate macro?
Newsgroups: comp.lang.c
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk> <sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk> <sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me> <sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk> <sd988e$1ea5$1@gioia.aioe.org>
Lines: 47
Message-ID: <adXJI.28783$qk6.7168@fx36.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 21 Jul 2021 15:39:50 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 21 Jul 2021 15:39:50 GMT
X-Received-Bytes: 2987
 by: Scott Lurndal - Wed, 21 Jul 2021 15:39 UTC

Manfred <noname@add.invalid> writes:
>On 7/21/2021 2:02 PM, Ben Bacarisse wrote:
>> John Forkosh <forkosh@panix.com> writes:
>>
>>> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>>>> On 7/20/21 9:48 PM, John Forkosh wrote:
>>>> ...
>>>>> i.e., "What the heck is he doing that for?" But then again, I never
>>>>> much liked relying that (a&&b) always evaluates a first, immediately
>>>>> becoming 0 without evaluating b at all if a is itself 0. You never know
>>>>> exactly what the next C standard might mess around with.
>>>>
>>>> That is a pretty fundamental feature of C; it's one of the last features
>>>> of C that I would ever expect to see changed. It would break far too
>>>> much existing code.
>>>
>>> I wouldn't be too complacent about that in the future.
>>
>> There absolutely zero chance that the semantics of && will change like
>> that. It is as deliberate a design choice as any in the language.
>> Neither B nor BCPL had short-circuit logical operators, relying instead
>> on bitwise & and |, as did early C. && and || were deliberately added
>> to simplify many common operations:
>>
>> while (np != 0 && np->data != 0) ...
>>
>>> And even today I wouldn't be so blithely sure.
>>
>> I am not "blithely sure", I'm sure for very good reasons!
>
>Just more explicit for the OP:
>- This behaviour is mandated by the standard.
>- This behaviour has been a key feature of the operator since the
>beginning of time, so if anything is going to change in the C standard,
>it's not going to be this part.

And indeed it is also known as "conditional and", which implies that
a false first term will prevent evaluation of subsequent terms.

Although one can find useless tutorials on the web
that are misleading and incomplete, if not incorrect, e.g.

https://www.tutorialspoint.com/cprogramming/c_logical_operators.htm
https://fresh2refresh.com/c-programming/c-operators-expressions/c-logical-operators/

Note that C++ specifies 'and' as an alternative spelling of '&&',
and C supports it as well if <iso646.h> is included.

Re: How to disambiguate macro?

<sd9hkr$j0a$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 09:22:51 -0700
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <sd9hkr$j0a$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Jul 2021 16:22:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="42d85c3a79cb1b8c71619f34a0fb255c";
logging-data="19466"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+18J4V5fzMyJtmka3mC8ee"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:oI2VeEQnIPOcXmCSMU9n/4UXH0U=
In-Reply-To: <sd8rra$f4o$1@reader1.panix.com>
Content-Language: en-US
 by: Andrey Tarasevich - Wed, 21 Jul 2021 16:22 UTC

On 7/21/2021 3:10 AM, John Forkosh wrote:
>
> I wouldn't be too complacent about that in the future.
> And even today I wouldn't be so blithely sure.
> For example, && is commutative, i.e., a&&b == b&&a.
>

&& is NOT commutative in C as explained previously. && is sequenced and
short-circuited. And it will always be.

> I'd never consider a&&b to mean that a is a guard on b's execution.

Then you won't be able to write (or read) normal programs in C.

--
Best regards,
Andrey Tarasevich

Re: How to disambiguate macro?

<sd9ib5$qh1$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 17:34:37 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <sd9ib5$qh1$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Jul 2021 16:34:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d7735f54b1c6d948185852b1a363e0ec";
logging-data="27169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eFEcwWQ+3fiMy8LRHx/KLx8Rc/9vHn/I="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:fHzKjgHe7I+HQy7gMF+hGwGmkQA=
In-Reply-To: <87sg07k82m.fsf@bsb.me.uk>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210721-4, 21/7/2021), Outbound message
 by: Bart - Wed, 21 Jul 2021 16:34 UTC

On 21/07/2021 16:20, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>
>> On 21/07/2021 14:20, Ben Bacarisse wrote:
>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>
>>>> Neither B nor BCPL had short-circuit logical operators, relying instead
>>>> on bitwise & and |, as did early C.
>>> Minor correction. B didn't have short-circuit & and | as such, but it
>>> had a weird rule that in conditional contexts like
>>> if (a & b) ...
>>> the operator short-circuited! C rightly ditched this contextual
>>> interpretation in favour of explicitly short-circuiting operators.
>>
>> That's not so weird. I used to have something similar (not in C) where
>> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
>> expressions as used in 'if' and 'while' control expressions, which
>> tended to be implemented with branching.
>>
>> But in ordinary expressions, they didn't.
>
> I'm don't see how this would persuade someone that it's not weird. A
> private language is never going to be used by someone other than the
> world authority on its semantics.
>
> In public-facing languages, such context-sensitive semantics seem to me
> to be the epitome of "weird".
>

In BASIC, "=" was used for assignments, and "=" was also used as an
equality operator.

Those two contexts didn't clash, so there wasn't any confusion.

It's similar with the special expression that follows if, while etc; the
language can simply say that is a separate context.

In my case, because control expression were expected to be full of
branching anyway, but expressions had linear execution. Nowadays
branchless code is fashionable.

Re: How to disambiguate macro?

<sd9mhe$q8b$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 19:46:21 +0200
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <sd9mhe$q8b$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 21 Jul 2021 17:46:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5034648778e76de81508b6aa8e6ee000";
logging-data="26891"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xW2PY9zufdDOIo+ZXfzgv6JVx3l9JoRs="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:TBE7CCokjxs3bTDPLjROFDYEE1o=
In-Reply-To: <sd9ib5$qh1$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Wed, 21 Jul 2021 17:46 UTC

On 21/07/2021 18:34, Bart wrote:
> On 21/07/2021 16:20, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>>
>>> On 21/07/2021 14:20, Ben Bacarisse wrote:
>>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>>
>>>>> Neither B nor BCPL had short-circuit logical operators, relying
>>>>> instead
>>>>> on bitwise & and |, as did early C.
>>>> Minor correction.  B didn't have short-circuit & and | as such, but it
>>>> had a weird rule that in conditional contexts like
>>>>     if (a & b) ...
>>>> the operator short-circuited!  C rightly ditched this contextual
>>>> interpretation in favour of explicitly short-circuiting operators.
>>>
>>> That's not so weird. I used to have something similar (not in C) where
>>> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
>>> expressions as used in 'if' and 'while' control expressions, which
>>> tended to be implemented with branching.
>>>
>>> But in ordinary expressions, they didn't.
>>
>> I'm don't see how this would persuade someone that it's not weird.  A
>> private language is never going to be used by someone other than the
>> world authority on its semantics.
>>
>> In public-facing languages, such context-sensitive semantics seem to me
>> to be the epitome of "weird".
>>
>
> In BASIC, "=" was used for assignments, and "=" was also used as an
> equality operator.
>
> Those two contexts didn't clash, so there wasn't any confusion.
>
> It's similar with the special expression that follows if, while etc; the
> language can simply say that is a separate context.
>
> In my case, because control expression were expected to be full of
> branching anyway, but expressions had linear execution. Nowadays
> branchless code is fashionable.

That makes little sense.

In an "if", etc., your controlling expression is an expression. In an
assignment, or other expression, you are using an expression.

Are you suggesting that:

x = a && b;

if (a && b) ...

are clearly different contexts and should have different semantics,
despite "a && b" being an expression in each case?

What about

if a && b (for languages that don't need parenthesis)

and

if (a && b)

?

What about

x = a && b;
if (x) ....

It's fine to have the same symbol used in different contexts - look at
how often commas are used in most languages. Having an operator give
different meanings depending on other code around it (other than the
operands), is asking for trouble.

Re: How to disambiguate macro?

<sd9prb$1vlc$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 20:42:50 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sd9prb$1vlc$1@gioia.aioe.org>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
<sd9mhe$q8b$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="65196"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Manfred - Wed, 21 Jul 2021 18:42 UTC

On 7/21/2021 7:46 PM, David Brown wrote:
> On 21/07/2021 18:34, Bart wrote:
>> On 21/07/2021 16:20, Ben Bacarisse wrote:
>>> Bart <bc@freeuk.com> writes:
>>>
>>>> On 21/07/2021 14:20, Ben Bacarisse wrote:
>>>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>>>
>>>>>> Neither B nor BCPL had short-circuit logical operators, relying
>>>>>> instead
>>>>>> on bitwise & and |, as did early C.
>>>>> Minor correction.  B didn't have short-circuit & and | as such, but it
>>>>> had a weird rule that in conditional contexts like
>>>>>     if (a & b) ...
>>>>> the operator short-circuited!  C rightly ditched this contextual
>>>>> interpretation in favour of explicitly short-circuiting operators.
>>>>
>>>> That's not so weird. I used to have something similar (not in C) where
>>>> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
>>>> expressions as used in 'if' and 'while' control expressions, which
>>>> tended to be implemented with branching.
>>>>
>>>> But in ordinary expressions, they didn't.
>>>
>>> I'm don't see how this would persuade someone that it's not weird.  A
>>> private language is never going to be used by someone other than the
>>> world authority on its semantics.
>>>
>>> In public-facing languages, such context-sensitive semantics seem to me
>>> to be the epitome of "weird".
>>>
>>
>> In BASIC, "=" was used for assignments, and "=" was also used as an
>> equality operator.
>>
>> Those two contexts didn't clash, so there wasn't any confusion.
>>
>> It's similar with the special expression that follows if, while etc; the
>> language can simply say that is a separate context.
>>
>> In my case, because control expression were expected to be full of
>> branching anyway, but expressions had linear execution. Nowadays
>> branchless code is fashionable.
>
> That makes little sense.
>
> In an "if", etc., your controlling expression is an expression. In an
> assignment, or other expression, you are using an expression.
>
> Are you suggesting that:
>
> x = a && b;
>
> if (a && b) ...
>
> are clearly different contexts and should have different semantics,
> despite "a && b" being an expression in each case?
>
> What about
>
> if a && b (for languages that don't need parenthesis)
>
> and
>
> if (a && b)
>
> ?
>
> What about
>
> x = a && b;
> if (x) ....
>
>
> It's fine to have the same symbol used in different contexts - look at
> how often commas are used in most languages. Having an operator give
> different meanings depending on other code around it (other than the
> operands), is asking for trouble.
>

This branch stemmed from the word "weird" used for a context-sensitive rule.

Now, "weird" is a subjective connotation, so I think it is not
surprising that someone does not see something as "weird" as I might do.

In fact, it /is/ obviously possible to define context dependent rules
that are formally correct, and the examples given are of real
programming languages, albeit now obsolete.

However I agree that a modern language should keep away from this
context dependent meanings.
In the context (!) of a programming language, logic consistency and
simplicity trumps semantic expressiveness.

Re: How to disambiguate macro?

<sd9tkt$edf$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 20:47:33 +0100
Organization: A noiseless patient Spider
Lines: 105
Message-ID: <sd9tkt$edf$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
<sd9mhe$q8b$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 21 Jul 2021 19:47:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d7735f54b1c6d948185852b1a363e0ec";
logging-data="14767"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5I44B1CymnMxNP7IIEaXm3CKEieT1gyQ="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:ThdxNzR8991qGuVKRIGDdit644E=
In-Reply-To: <sd9mhe$q8b$1@dont-email.me>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210721-4, 21/7/2021), Outbound message
 by: Bart - Wed, 21 Jul 2021 19:47 UTC

On 21/07/2021 18:46, David Brown wrote:
> On 21/07/2021 18:34, Bart wrote:
>> On 21/07/2021 16:20, Ben Bacarisse wrote:
>>> Bart <bc@freeuk.com> writes:
>>>
>>>> On 21/07/2021 14:20, Ben Bacarisse wrote:
>>>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>>>
>>>>>> Neither B nor BCPL had short-circuit logical operators, relying
>>>>>> instead
>>>>>> on bitwise & and |, as did early C.
>>>>> Minor correction.  B didn't have short-circuit & and | as such, but it
>>>>> had a weird rule that in conditional contexts like
>>>>>     if (a & b) ...
>>>>> the operator short-circuited!  C rightly ditched this contextual
>>>>> interpretation in favour of explicitly short-circuiting operators.
>>>>
>>>> That's not so weird. I used to have something similar (not in C) where
>>>> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
>>>> expressions as used in 'if' and 'while' control expressions, which
>>>> tended to be implemented with branching.
>>>>
>>>> But in ordinary expressions, they didn't.
>>>
>>> I'm don't see how this would persuade someone that it's not weird.  A
>>> private language is never going to be used by someone other than the
>>> world authority on its semantics.
>>>
>>> In public-facing languages, such context-sensitive semantics seem to me
>>> to be the epitome of "weird".
>>>
>>
>> In BASIC, "=" was used for assignments, and "=" was also used as an
>> equality operator.
>>
>> Those two contexts didn't clash, so there wasn't any confusion.
>>
>> It's similar with the special expression that follows if, while etc; the
>> language can simply say that is a separate context.
>>
>> In my case, because control expression were expected to be full of
>> branching anyway, but expressions had linear execution. Nowadays
>> branchless code is fashionable.
>
> That makes little sense.
>
> In an "if", etc., your controlling expression is an expression. In an
> assignment, or other expression, you are using an expression.
>
> Are you suggesting that:
>
> x = a && b;
>
> if (a && b) ...
>
> are clearly different contexts and should have different semantics,
> despite "a && b" being an expression in each case?

These do different things. One results in a concrete 1 or 0 boolean
value. The other determines whether or not you jump to some label.

> What about
>
> if a && b (for languages that don't need parenthesis)
>
> and
>
> if (a && b)
>
> ?
>
> What about
>
> x = a && b;
> if (x) ....
>
>
> It's fine to have the same symbol used in different contexts - look at
> how often commas are used in most languages. Having an operator give
> different meanings depending on other code around it (other than the
> operands), is asking for trouble.

I'm not good at keeping old versions of languages. But one I've just
tried didn't even allow && in a normal expresion. It meant having to write:

x = a && b;

as the equivalent of:

x = (a && b ? 1 : 0);

So here && still has one behaviour.

But now all my languages support short-circuiting logic ops in any
context. One idea for non-short-circuiting versions of && and || was
dropped (I had too many features already), but it would have allowed:

if task1() andb task2() then
println "Both succeeded"
end

Here these are independent and you want to attempt both even if the
other failed.

Re: How to disambiguate macro?

<87h7gnju7j.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 21:19:28 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <87h7gnju7j.fsf@bsb.me.uk>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4cf7f3a355a2ef187a6fe4ebd693fd15";
logging-data="27220"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+H8WI86gmWXZ0+hl21jBjH2JknsBJW4xA="
Cancel-Lock: sha1:z4GYc584lf4ke1Z4CXBssElsRiE=
sha1:xCM7pFp9LDRBQLlmA+K9qD8oW+o=
X-BSB-Auth: 1.fe097d093bd5948fabf1.20210721211928BST.87h7gnju7j.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 21 Jul 2021 20:19 UTC

Bart <bc@freeuk.com> writes:

> On 21/07/2021 16:20, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>>
>>> On 21/07/2021 14:20, Ben Bacarisse wrote:
>>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>>
>>>>> Neither B nor BCPL had short-circuit logical operators, relying instead
>>>>> on bitwise & and |, as did early C.
>>>> Minor correction. B didn't have short-circuit & and | as such, but it
>>>> had a weird rule that in conditional contexts like
>>>> if (a & b) ...
>>>> the operator short-circuited! C rightly ditched this contextual
>>>> interpretation in favour of explicitly short-circuiting operators.
>>>
>>> That's not so weird. I used to have something similar (not in C) where
>>> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
>>> expressions as used in 'if' and 'while' control expressions, which
>>> tended to be implemented with branching.
>>>
>>> But in ordinary expressions, they didn't.
>> I'm don't see how this would persuade someone that it's not weird. A
>> private language is never going to be used by someone other than the
>> world authority on its semantics.
>> In public-facing languages, such context-sensitive semantics seem to me
>> to be the epitome of "weird".
>
> In BASIC, "=" was used for assignments, and "=" was also used as an
> equality operator.

Not weird.

> Those two contexts didn't clash, so there wasn't any confusion.

That's not an expression having two meaning depending on where it's
written. That one symbol with two meanings, like ',' in C (and, indeed,
'=' in C).

--
Ben.

Re: How to disambiguate macro?

<sda3ah$l3i$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 17:24:32 -0400
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <sda3ah$l3i$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Jul 2021 21:24:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b632d299d9d6bd11be2d428215431588";
logging-data="21618"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18j/eP+LkNlvB4nQA/vRpLkaPeJKPMLOZ4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:3oLzzUkuew1hEyUt8TBisJHJ/LM=
In-Reply-To: <sd8rra$f4o$1@reader1.panix.com>
Content-Language: en-US
 by: James Kuyper - Wed, 21 Jul 2021 21:24 UTC

On 7/21/21 6:10 AM, John Forkosh wrote:
> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>> On 7/20/21 9:48 PM, John Forkosh wrote:
>> ...
>>> i.e., "What the heck is he doing that for?" But then again, I never
>>> much liked relying that (a&&b) always evaluates a first, immediately
>>> becoming 0 without evaluating b at all if a is itself 0. You never know
>>> exactly what the next C standard might mess around with.
>>
>> That is a pretty fundamental feature of C; it's one of the last features
>> of C that I would ever expect to see changed. It would break far too
>> much existing code.
>
> I wouldn't be too complacent about that in the future.

I suspect that reflects a lack of experience with C. If you had a lot of
experience with C, and in particular, a lot of experience reading other
people's C code, you should have noticed that code which relies upon
this feature of the && and || operators is extremely common. The C
committee is reluctant to make any change that would break a significant
amount of existing strictly conforming code - they would certainly not
approve a change that would break as much existing code as this one would.

> And even today I wouldn't be so blithely sure.
> For example, && is commutative, i.e., a&&b == b&&a.

As others have pointed out, that's explicitly not the case in C, and
there's lots of code that relies upon that fact in order to achieve it's
desired effects.

> So suppose you're compiling with -O3 optimization,
> and your program contains something like...
> ( (very_very_complicated_expression) && (++n>3) )
> So maybe the optimizer says to itself, "Hey, I'll
> just execute that very simple right-hand-side first,
> and if it's false then I don't have to bother evaluating
> that very complicated left-hand-side at all. Could save lots
> of time." Now maybe that's not supposed to happen,
> but it's way too subtle for my liking.

No conforming compiler is allowed to do that, and any compiler which did
would quickly break large quantities of existing code. Developers would
abandon any such compiler quite quickly - and that's a more important
issue than the fact that it doesn't conform to the standard.

> I'd never consider a&&b to mean that a is a guard on b's execution.

Which implies that you're not very experienced as a C programmer. Only a
newbie would have any uncertainty on that matter.

> It certainly doesn't look like a guard, and I wouldn't
> trust interpreting it that way. Clearly very bad practice
> and very bad advice, even if it happens to work.
It's guaranteed to work by the standard, deliberately with the intent of
allowing developers to rely upon that fact, and most C programmers have
written code that relies upon that fact for it's successful execution.
Incidentally, the same is true of C++ - and a gratuitous incompatibly
between C and C++ goes against the official policies of both the C
committee and the C++ committee.

Re: How to disambiguate macro?

<and-operator-20210721223850@ram.dialup.fu-berlin.de>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: 21 Jul 2021 21:40:13 GMT
Organization: Stefan Ram
Lines: 50
Expires: 1 Dec 2021 11:59:58 GMT
Message-ID: <and-operator-20210721223850@ram.dialup.fu-berlin.de>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk> <sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk> <sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me> <sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de wxpyF+yS6ubqvWReYyWVeQIA2jrkOqzv52Eq6QKak/7NFc
X-Copyright: (C) Copyright 2021 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Wed, 21 Jul 2021 21:40 UTC

James Kuyper <jameskuyper@alumni.caltech.edu> writes:
>On 7/21/21 6:10 AM, John Forkosh wrote:
>>I'd never consider a&&b to mean that a is a guard on b's execution.
>Which implies that you're not very experienced as a C programmer. Only a
>newbie would have any uncertainty on that matter.

I can only agree with everything you (James) wrote about "&&".

I remember that at one point I wrote code like

try_to_do_this() &&
try_to_do_that() &&
now_try_to_do_this() &&
now_try_to_do_that() &&
now_try_to_do_this_please();

. The first function that failed would return zero,
and by this this sequence would be aborted. Kind of like

try_to_do_this();
try_to_do_that();
now_try_to_do_this();
now_try_to_do_that();
now_try_to_do_this_please();

in languages with exceptions.

There also is this idiom:

if( p && *p )...

instead of just

if( *p )...

to make sure p is not zero before dereferencing it.

When an optimizing compiler can prove that "p" is
non-zero at this point, it might even remove the guard.

Part of the problem for beginners is that evaluations
can be sequenced and have side effects in C, and so they
effectively can act a bit like executions of statements,
while in mathematics there are no sequence points in
expressions, and in mathematics evaluations do not have
specified side effects. So beginners cannot simply
transfer their knowledge of mathematical expressions
to C expressions.

Re: How to disambiguate macro?

<871r7r1bfs.fsf@nosuchdomain.example.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Wed, 21 Jul 2021 16:42:15 -0700
Organization: None to speak of
Lines: 26
Message-ID: <871r7r1bfs.fsf@nosuchdomain.example.com>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="651f3c8279527657336631adad68c804";
logging-data="4535"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18A0XqZ1b1r6exRaaDuz7Mi"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:tIQV13UJHH+38jDY4LFBXzxG1aU=
sha1:4HxeVQR92yrQboSdiixT7jT65Mo=
 by: Keith Thompson - Wed, 21 Jul 2021 23:42 UTC

James Kuyper <jameskuyper@alumni.caltech.edu> writes:
> On 7/21/21 6:10 AM, John Forkosh wrote:
[...]
>> And even today I wouldn't be so blithely sure.
>> For example, && is commutative, i.e., a&&b == b&&a.
>
> As others have pointed out, that's explicitly not the case in C, and
> there's lots of code that relies upon that fact in order to achieve it's
> desired effects.
[...]

True -- but to be fair, it is commutative-ish.

For example, if a and be are non-volatile variables, then a&&b is
effectively equivalent to b&&a, because neither operand has side
effects.

But in the general case, of course, it's not commutative.

(ptr != NULL && *ptr == some_value) is a very common idiom, and no
future language that breaks that will be called C.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: How to disambiguate macro?

<sdavpm$nkl$1@reader1.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix3.panix.com!not-for-mail
From: fork...@panix.com (John Forkosh)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 05:30:30 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <sdavpm$nkl$1@reader1.panix.com>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk> <sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk> <sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me> <sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me>
Injection-Date: Thu, 22 Jul 2021 05:30:30 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix3.panix.com:166.84.1.3";
logging-data="24213"; mail-complaints-to="abuse@panix.com"
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (NetBSD/9.2 (amd64))
 by: John Forkosh - Thu, 22 Jul 2021 05:30 UTC

James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
> John Forkosh wrote:
>> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>>> John Forkosh wrote:
>>> ...
>>>> i.e., "What the heck is he doing that for?" But then again, I never
>>>> much liked relying that (a&&b) always evaluates a first, immediately
>>>> becoming 0 without evaluating b at all if a is itself 0. You never know
>>>> exactly what the next C standard might mess around with.
>>>
>>> That is a pretty fundamental feature of C; it's one of the last features
>>> of C that I would ever expect to see changed. It would break far too
>>> much existing code.
>>
>> I wouldn't be too complacent about that in the future.
>
> I suspect that reflects a lack of experience with C. If you had a lot of
> experience with C, and in particular, a lot of experience reading other
> people's C code, you should have noticed that code which relies upon
> this feature of the && and || operators is extremely common.

I've been using mostly C (and some Fortran and various assemblers)
since 1984, and before that (first paying job in 1966) Fortran,
various assemblers, PL/1, Cobol, Basic and some other languages
you never heard of like Jovial. And as an independent contractor
since 1986 with contracts between 3months and 2.5years, I've read
tons (maybe megatons) of other people's C code. But can't explicitly
recall ever seeing && used as a guard. While I'm sure it must've been
there in that way somewheres/sometimes, I'm pretty sure I'd have
remembered if that were common practice. And while I've been aware
of that guard-like && semantics since K&R1 (pg19), I don't recall
seeing them ever suggest or illustrate using it as a guard.
That's just (as mentioned above) "weird" -- i.e., whereas anybody
can guess what if(a)b; means, the syntax a&&b doesn't by itself
>>connote<< any guard-like semantics. I'd use it that way if some
goofy syntactic situation warranted it -- like maybe Ben's answer
as a workaround for my original question, but never when if(a)b;
would work just as will, which is pretty much all the time.
Or maybe not: let's see a few snippets besides Ben's where you
feel a&&b as a guard is the better solution...

> The C committee is reluctant to make any change that would break
> a significant amount of existing strictly conforming code - they would
> certainly not approve a change that would break as much existing code
> as this one would.
>
>> And even today I wouldn't be so blithely sure.
>> For example, && is commutative, i.e., a&&b == b&&a.
>
> As others have pointed out, that's explicitly not the case in C,

Yeah, I meant (and thought it was clear) commutative with respect to
the logical result, not with respect to the guard-like side effects.

> and there's lots of code that relies upon that fact in order to
> achieve it's desired effects.

Yeah, I see I was wrong suggesting some future standard (or present
implementation) might behave differently. I still don't like it,
but it's probably safe to assume it'll work as intended for the
forseeable future.

>> So suppose you're compiling with -O3 optimization,
>> and your program contains something like...
>> ( (very_very_complicated_expression) && (++n>3) )
>> So maybe the optimizer says to itself, "Hey, I'll
>> just execute that very simple right-hand-side first,
>> and if it's false then I don't have to bother evaluating
>> that very complicated left-hand-side at all. Could save lots
>> of time." Now maybe that's not supposed to happen,
>> but it's way too subtle for my liking.
>
> No conforming compiler is allowed to do that, and any compiler which did
> would quickly break large quantities of existing code. Developers would
> abandon any such compiler quite quickly - and that's a more important
> issue than the fact that it doesn't conform to the standard.
>
>> I'd never consider a&&b to mean that a is a guard on b's execution.
>
> Which implies that you're not very experienced as a C programmer. Only a
> newbie would have any uncertainty on that matter.
>
>> It certainly doesn't look like a guard, and I wouldn't
>> trust interpreting it that way. Clearly very bad practice
>> and very bad advice, even if it happens to work.
>
> It's guaranteed to work by the standard, deliberately with the intent of
> allowing developers to rely upon that fact, and most C programmers have
> written code that relies upon that fact for it's successful execution.
> Incidentally, the same is true of C++ - and a gratuitous incompatibly
> between C and C++ goes against the official policies of both the C
> committee and the C++ committee.

--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )

Re: How to disambiguate macro?

<sdb0tt$tc$1@reader1.panix.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix3.panix.com!not-for-mail
From: fork...@panix.com (John Forkosh)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 05:49:50 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <sdb0tt$tc$1@reader1.panix.com>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk> <sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk> <sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me> <sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me> <871r7r1bfs.fsf@nosuchdomain.example.com>
Injection-Date: Thu, 22 Jul 2021 05:49:50 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix3.panix.com:166.84.1.3";
logging-data="940"; mail-complaints-to="abuse@panix.com"
User-Agent: tin/2.4.5-20201224 ("Glen Albyn") (NetBSD/9.2 (amd64))
 by: John Forkosh - Thu, 22 Jul 2021 05:49 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>
> (ptr != NULL && *ptr == some_value) is a very common idiom

Okay, thanks, that's a good example where && used as a guard
is a useful construction.

Hmm... and I've got to admit that it's strange I don't recall
running across it. My own stuff usually looks more like, say,
int myfunc ( int *ptr ) {
int status = 0;
if ( ptr == NULL ) goto end_of_job;
do_some_stuff_dereferencing_ptr;
status = 1;
end_of_job: return ( status ); }
i.e., args (or malloc's return, etc) are explicitly checked
to guard a whole block of subsequent code. Your
(ptr != NULL && *ptr == some_value)
only guards that one single ptr dereference statement,
whereas I'd imagine most functionality would involve
further ptr derefernces that would also need to be guarded
against nulls.
--
John Forkosh ( mailto: j@f.com where j=john and f=forkosh )

Re: How to disambiguate macro?

<sdb3o7$234$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 08:37:58 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <sdb3o7$234$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
<sd9mhe$q8b$1@dont-email.me> <sd9prb$1vlc$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 22 Jul 2021 06:37:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b66e6b4432baa37d65ac887260cefb8f";
logging-data="2148"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CyhaQm2LT4qCfxww2UXfcFR75AzJzB64="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:HYwtQmsohxla8Y7lYnY3kwDGBLQ=
In-Reply-To: <sd9prb$1vlc$1@gioia.aioe.org>
Content-Language: en-GB
 by: David Brown - Thu, 22 Jul 2021 06:37 UTC

On 21/07/2021 20:42, Manfred wrote:
> On 7/21/2021 7:46 PM, David Brown wrote:

>> It's fine to have the same symbol used in different contexts - look at
>> how often commas are used in most languages.  Having an operator give
>> different meanings depending on other code around it (other than the
>> operands), is asking for trouble.
>>
>
> This branch stemmed from the word "weird" used for a context-sensitive
> rule.
>
> Now, "weird" is a subjective connotation, so I think it is not
> surprising that someone does not see something as "weird" as I might do.
>

Agreed.

> In fact, it /is/ obviously possible to define context dependent rules
> that are formally correct, and the examples given are of real
> programming languages, albeit now obsolete.
>
> However I agree that a modern language should keep away from this
> context dependent meanings.
> In the context (!) of a programming language, logic consistency and
> simplicity trumps semantic expressiveness.

Agreed. Here, C is the modern language!

Re: How to disambiguate macro?

<sdb4an$56m$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 08:47:51 +0200
Organization: A noiseless patient Spider
Lines: 139
Message-ID: <sdb4an$56m$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
<sd9mhe$q8b$1@dont-email.me> <sd9tkt$edf$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 22 Jul 2021 06:47:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b66e6b4432baa37d65ac887260cefb8f";
logging-data="5334"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rVye71V9+rLUVnZzvKCR8VNDDtJho46k="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:W+duwaWLXFbqTAaAwcecwbBOxlE=
In-Reply-To: <sd9tkt$edf$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Thu, 22 Jul 2021 06:47 UTC

On 21/07/2021 21:47, Bart wrote:
> On 21/07/2021 18:46, David Brown wrote:
>> On 21/07/2021 18:34, Bart wrote:
>>> On 21/07/2021 16:20, Ben Bacarisse wrote:
>>>> Bart <bc@freeuk.com> writes:
>>>>
>>>>> On 21/07/2021 14:20, Ben Bacarisse wrote:
>>>>>> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>>>>>
>>>>>>> Neither B nor BCPL had short-circuit logical operators, relying
>>>>>>> instead
>>>>>>> on bitwise & and |, as did early C.
>>>>>> Minor correction.  B didn't have short-circuit & and | as such,
>>>>>> but it
>>>>>> had a weird rule that in conditional contexts like
>>>>>>      if (a & b) ...
>>>>>> the operator short-circuited!  C rightly ditched this contextual
>>>>>> interpretation in favour of explicitly short-circuiting operators.
>>>>>
>>>>> That's not so weird. I used to have something similar (not in C) where
>>>>> 'A and B' (ie. logical and, also 'or') short-circuited in conditional
>>>>> expressions as used in 'if' and 'while' control expressions, which
>>>>> tended to be implemented with branching.
>>>>>
>>>>> But in ordinary expressions, they didn't.
>>>>
>>>> I'm don't see how this would persuade someone that it's not weird.  A
>>>> private language is never going to be used by someone other than the
>>>> world authority on its semantics.
>>>>
>>>> In public-facing languages, such context-sensitive semantics seem to me
>>>> to be the epitome of "weird".
>>>>
>>>
>>> In BASIC, "=" was used for assignments, and "=" was also used as an
>>> equality operator.
>>>
>>> Those two contexts didn't clash, so there wasn't any confusion.
>>>
>>> It's similar with the special expression that follows if, while etc; the
>>> language can simply say that is a separate context.
>>>
>>> In my case, because control expression were expected to be full of
>>> branching anyway, but expressions had linear execution. Nowadays
>>> branchless code is fashionable.
>>
>> That makes little sense.
>>
>> In an "if", etc., your controlling expression is an expression.  In an
>> assignment, or other expression, you are using an expression.
>>
>> Are you suggesting that:
>>
>>     x = a && b;
>>
>>     if (a && b) ...
>>
>> are clearly different contexts and should have different semantics,
>> despite "a && b" being an expression in each case?
>
> These do different things. One results in a concrete 1 or 0 boolean
> value. The other determines whether or not you jump to some label.
>

The expressions are the same in each case. After calculating "a && b",
they do different things with the results - but that comes /later/.

The way expressions are interpreted and evaluated is, in most languages,
independent of what you do with the results. (The number of programming
languages is so vast that there are bound to be exceptions to almost any
rule or generalisation.)

If you write :

int x = 4 / 3;
float y = 4 / 3;

in most languages, you would not expect the first division to be done as
integers and the second to be done as floating point. You would expect
consistency. It might be consistently integer division, or consistently
floating point (and then converted to integer x and floating point y).
But you want consistency.

>
>
>> What about
>>
>>     if a && b     (for languages that don't need parenthesis)
>>
>> and
>>
>>     if (a && b)
>>
>> ?
>>
>> What about
>>
>>     x = a && b;
>>     if (x) ....
>>
>>
>> It's fine to have the same symbol used in different contexts - look at
>> how often commas are used in most languages.  Having an operator give
>> different meanings depending on other code around it (other than the
>> operands), is asking for trouble.
>
> I'm not good at keeping old versions of languages. But one I've just
> tried didn't even allow && in a normal expresion. It meant having to write:
>
>    x = a && b;
>
> as the equivalent of:
>
>    x = (a && b ? 1 : 0);
>
> So here && still has one behaviour.
>

I guess with your personal little languages, you never really have to
think about things like specifications, consistency, documentation,
compatibility, logical design, or any of these other things that concern
real languages. You can just make things up and modify them as you go
along, changing the language tools as often as the programs written in
the language.

> But now all my languages support short-circuiting logic ops in any
> context. One idea for non-short-circuiting versions of && and || was
> dropped (I had too many features already), but it would have allowed:
>
>   if task1() andb task2() then
>       println "Both succeeded"
>   end
>
> Here these are independent and you want to attempt both even if the
> other failed.

Adding rarely used and cryptic operators or syntaxes is always a mistake
in a language, unless there is no other way to achieve the same goals.

Re: How to disambiguate macro?

<sdbhf6$lbo$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 11:31:56 +0100
Organization: A noiseless patient Spider
Lines: 122
Message-ID: <sdbhf6$lbo$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
<sd9mhe$q8b$1@dont-email.me> <sd9tkt$edf$1@dont-email.me>
<sdb4an$56m$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 22 Jul 2021 10:32:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5931370de13184dd22c1e81964028b1d";
logging-data="21880"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+VT+ncQEs4fQyieLKlan61pqp1oXzFm8="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:FmyLaoPkSihlI12Dg9+IA21v7iE=
In-Reply-To: <sdb4an$56m$1@dont-email.me>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210722-0, 22/7/2021), Outbound message
 by: Bart - Thu, 22 Jul 2021 10:31 UTC

On 22/07/2021 07:47, David Brown wrote:
> On 21/07/2021 21:47, Bart wrote:

>> These do different things. One results in a concrete 1 or 0 boolean
>> value. The other determines whether or not you jump to some label.
>>
>
> The expressions are the same in each case. After calculating "a && b",
> they do different things with the results - but that comes /later/.

As I implement it, there is no actual result calculated from 'a && b'
when used in 'if (a && b)'.

Because once it's figured out whether the result will 1 or 0, it will
also have figured out whether to do that jump or not.

> The way expressions are interpreted and evaluated is, in most languages,
> independent of what you do with the results. (The number of programming
> languages is so vast that there are bound to be exceptions to almost any
> rule or generalisation.)
>
> If you write :
>
> int x = 4 / 3;
> float y = 4 / 3;
>
> in most languages, you would not expect the first division to be done as
> integers and the second to be done as floating point. You would expect
> consistency. It might be consistently integer division, or consistently
> floating point (and then converted to integer x and floating point y).
> But you want consistency.

A && B will consistently reqire both operands to be bools [Python and
others are a little different]. The quibble here is whether B should
always be evaluated.

I at one time (iirc) made a decision in /my/ language that B should be
evaluated when the actual result of A&&B is needed. This actually made
it /more/ consistent, not less!

So given A op B, you know that B will always be evaluated (barring A
halting execution in some way), whatever 'op' actually is.

The distinction was that 'and' was considered syntax (between and-less
expressions) when used in a conditional statement, and an operator
otherwise. This is not hard to express in a grammar.

I think that Algol68 works the same way: both operands of AND will
always be evaluated. To get short-circuiting behaviour, you need to write:

if A thef B then ...

Here, it is clear that 'thef' (I believe short for 'then if') is syntax
similar to 'then', but AND is an operator.

>> I'm not good at keeping old versions of languages. But one I've just
>> tried didn't even allow && in a normal expresion. It meant having to write:
>>
>>    x = a && b;
>>
>> as the equivalent of:
>>
>>    x = (a && b ? 1 : 0);
>>
>> So here && still has one behaviour.
>>
>
> I guess with your personal little languages, you never really have to
> think about things like specifications, consistency, documentation,
> compatibility, logical design, or any of these other things that concern
> real languages. You can just make things up and modify them as you go
> along, changing the language tools as often as the programs written in
> the language.

Not quite. Because they are self-hosted, and have been in a chain going
back decades, I have to be careful with breaking changes. If you use C
as an implementation language, then you can do what you like; there are
a million C compilers to choose from, or to reinstall if you somehow
corrupt your copy.

But yes, I still have a lot more freedom than long-established languages.

In the case of expression terms that may involve branching within the
expression, C has these:

* && and ||
* ? :

I now have those plus:

* N-way selection
* Switch
* Case (unrestricted form of Switch)
* Normal, long-form 'if'

(These are on top of the arbitrary statements that can be written inside
expressions, as they can with gnu C. But gnu C I think doesn't allow
statements of if and switch to return a value.)

>> But now all my languages support short-circuiting logic ops in any
>> context. One idea for non-short-circuiting versions of && and || was
>> dropped (I had too many features already), but it would have allowed:
>>
>>   if task1() andb task2() then
>>       println "Both succeeded"
>>   end
>>
>> Here these are independent and you want to attempt both even if the
>> other failed.
>
> Adding rarely used and cryptic operators or syntaxes is always a mistake
> in a language, unless there is no other way to achieve the same goals.
>

You mean like && & || | ! ~ ^ ?

Those are only considered non-cryptic because of familiarity! My
equivalents are:

and iand or ior not inot ixor

OT: possessive adjectives (Was: How to disambiguate macro?)

<sdbqcc$1ir3$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: OT: possessive adjectives (Was: How to disambiguate macro?)
Date: Thu, 22 Jul 2021 15:04:11 +0200
Organization: Aioe.org NNTP Server
Message-ID: <sdbqcc$1ir3$1@gioia.aioe.org>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="52067"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Thu, 22 Jul 2021 13:04 UTC

On 7/21/2021 11:24 PM, James Kuyper wrote:

Sorry about the grammar nit-picking, but...

>
> As others have pointed out, that's explicitly not the case in C, and
> there's lots of code that relies upon that fact in order to achieve it's
> desired effects.

The expression "it's" is a contraction for "it is", and it doesn't make
sense here. What you mean here is "its", which is the proper possessive
adjective to be used in this sentence. Confusing the two expressions
would be the same as confusing "they're" and "their".

[...]

> It's guaranteed to work by the standard, deliberately with the intent of
You got "it's" right here...

> allowing developers to rely upon that fact, and most C programmers have
> written code that relies upon that fact for it's successful execution.
.... but not here either

> Incidentally, the same is true of C++ - and a gratuitous incompatibly
> between C and C++ goes against the official policies of both the C
> committee and the C++ committee.
>

Sorry for patronizing, but your posts usually read fairly correct, so I
thought this remark might not be like the proverbial drop in an ocean in
your case - besides, I have a kind of allergy to non-compiling sentences
(even if English is not my native language, and I make mistakes myself)

[PS. the argument that this is a very common mistake doesn't work for me]

Re: How to disambiguate macro?

<C3fKI.35774$5Y6.24879@fx10.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!peer02.ams4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: How to disambiguate macro?
Newsgroups: comp.lang.c
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk> <sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk> <sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me> <sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me> <sdavpm$nkl$1@reader1.panix.com>
Lines: 43
Message-ID: <C3fKI.35774$5Y6.24879@fx10.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 22 Jul 2021 14:14:58 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 22 Jul 2021 14:14:58 GMT
X-Received-Bytes: 2589
 by: Scott Lurndal - Thu, 22 Jul 2021 14:14 UTC

John Forkosh <forkosh@panix.com> writes:
>James Kuyper <jameskuyper@alumni.caltech.edu> wrote:

>
>I've been using mostly C (and some Fortran and various assemblers)
>since 1984, and before that (first paying job in 1966) Fortran,
>various assemblers, PL/1, Cobol, Basic and some other languages
>you never heard of like Jovial. And as an independent contractor
>since 1986 with contracts between 3months and 2.5years, I've read
>tons (maybe megatons) of other people's C code. But can't explicitly
>recall ever seeing && used as a guard.

I've been programming in C since 1979, and in other languages since
1975.

The use of && as a guard has been frequent and common over
the last forty years. Including in Unix.

grep "&&" /work/reference/usl/unix/v7/usr/src/cmd/*.c

/work/reference/usl/unix/v7/usr/src/cmd/ac.c: while (--argc > 0 && **++argv == '-')
....
/work/reference/usl/unix/v7/usr/src/cmd/ac.c: for (j=0; j<8 && up->uname[j]==ibuf.ut_name[j]; j++);
....
/work/reference/usl/unix/v7/usr/src/cmd/date.c: if (argc>1 && argv[1][0]=='-' && argv[1][1]=='u') {
....
/work/reference/usl/unix/v7/usr/src/cmd/diff.c: if(stat(a1,&stbuf)!=-1 && ((stbuf.st_mode&S_IFMT)==S_IFDIR)) {

and the rather common idiom:

/work/reference/usl/unix/v7/usr/src/cmd/join.c: while (argc > 1 && argv[1][0] == '-') {

where the end of the while loop is:
argc--;
argv++;
}

These prevent a possible NULL pointer dereference, an out
of bounds array access and access to uninitialized
data, and there were 430 other hits on &&
in the command directly alone (not all of which were
explicitly used as a guard, to be sure).

Re: How to disambiguate macro?

<sdbvrb$2s7$1@z-news.wcss.wroc.pl>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 14:37:31 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 38
Message-ID: <sdbvrb$2s7$1@z-news.wcss.wroc.pl>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk> <sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk> <sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me> <sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk> <8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me> <87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me> <sd9mhe$q8b$1@dont-email.me> <sd9tkt$edf$1@dont-email.me> <sdb4an$56m$1@dont-email.me>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1626964651 2951 156.17.86.1 (22 Jul 2021 14:37:31 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Thu, 22 Jul 2021 14:37:31 +0000 (UTC)
Cancel-Lock: sha1:iaIGqRVHp8H5nypM+Hxzsu7HVP0=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
 by: antis...@math.uni.wroc.pl - Thu, 22 Jul 2021 14:37 UTC

David Brown <david.brown@hesbynett.no> wrote:
>
> The way expressions are interpreted and evaluated is, in most languages,
> independent of what you do with the results. (The number of programming
> languages is so vast that there are bound to be exceptions to almost any
> rule or generalisation.)
>
> If you write :
>
> int x = 4 / 3;
> float y = 4 / 3;
>
> in most languages, you would not expect the first division to be done as
> integers and the second to be done as floating point. You would expect
> consistency. It might be consistently integer division, or consistently
> floating point (and then converted to integer x and floating point y).
> But you want consistency.

There are languages that do overloading resolution based on result
type. In language that I frequently use both are wrong: division
on integers produces rational number and can not give back an integer.
Similarely, division for floats needs floats as arguments while
3 and 4 are not floats. But there are valid expressions in similar
spirit: they will do different things depending on result type.

Probably the most prominent example of language that has overloading
on result type is Ada. However, IIUC in C++ it is possible to
have eqivalent effect. Of course, C++ keeps built-in stuff
reasonably compatible with C, so your examples work as in C.
But there are interesting examples using user-defiend types.

AFAIK the main criterion for "weird" is familiarity: C is widely
used and several languages ape some aspects of C. But for
uninitiated many things in C look weird (including your
division example).

--
Waldek Hebisch

Re: How to disambiguate macro?

<87r1fqib99.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 17:06:26 +0100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <87r1fqib99.fsf@bsb.me.uk>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me>
<sdavpm$nkl$1@reader1.panix.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="18da31ae2601e847790a079f7e4074e1";
logging-data="24308"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ChL5o3L6U4e6QdBN5eKgfUuc177zbHt8="
Cancel-Lock: sha1:s4Xfx9MCgcD6U9W+JyJ4BY4xHvM=
sha1:y4urlqGLn2+0YxOyFns3NTDrZvQ=
X-BSB-Auth: 1.d3f8f9c295efa42c799b.20210722170626BST.87r1fqib99.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 22 Jul 2021 16:06 UTC

John Forkosh <forkosh@panix.com> writes:

> ... I've read
> tons (maybe megatons) of other people's C code. But can't explicitly
> recall ever seeing && used as a guard. While I'm sure it must've been
> there in that way somewheres/sometimes, I'm pretty sure I'd have
> remembered if that were common practice. And while I've been aware
> of that guard-like && semantics since K&R1 (pg19), I don't recall
> seeing them ever suggest or illustrate using it as a guard.

There are quite a few examples of using && as a guard in K&R.

<cut>
>>> And even today I wouldn't be so blithely sure.
>>> For example, && is commutative, i.e., a&&b == b&&a.
>>
>> As others have pointed out, that's explicitly not the case in C,
>
> Yeah, I meant (and thought it was clear) commutative with respect to
> the logical result, not with respect to the guard-like side effects.

How could that be clear when your example was of the compiler using the
supposed commutativity of && when the operands had explicit side-effects:

| So suppose you're compiling with -O3 optimization,
| and your program contains something like...
| ( (very_very_complicated_expression) && (++n>3) )

Anyway, && is not commutative even in the absence of side effects:

i < SIZE && a[i] == 0

--
Ben.

Re: How to disambiguate macro?

<sdc5i6$4l2$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 18:15:02 +0200
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <sdc5i6$4l2$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <87k0ljlvsu.fsf@bsb.me.uk>
<8735s7ls5z.fsf@bsb.me.uk> <sd9a5q$qs0$1@dont-email.me>
<87sg07k82m.fsf@bsb.me.uk> <sd9ib5$qh1$1@dont-email.me>
<sd9mhe$q8b$1@dont-email.me> <sd9tkt$edf$1@dont-email.me>
<sdb4an$56m$1@dont-email.me> <sdbvrb$2s7$1@z-news.wcss.wroc.pl>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 22 Jul 2021 16:15:02 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b66e6b4432baa37d65ac887260cefb8f";
logging-data="4770"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/XvTFjJGLVwl2UTNNbn02QWDZBARG2qEQ="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101
Thunderbird/68.10.0
Cancel-Lock: sha1:Ny+6SFLBVUjRuJMdZBA9oiITCKM=
In-Reply-To: <sdbvrb$2s7$1@z-news.wcss.wroc.pl>
Content-Language: en-GB
 by: David Brown - Thu, 22 Jul 2021 16:15 UTC

On 22/07/2021 16:37, antispam@math.uni.wroc.pl wrote:
> David Brown <david.brown@hesbynett.no> wrote:
>>
>> The way expressions are interpreted and evaluated is, in most languages,
>> independent of what you do with the results. (The number of programming
>> languages is so vast that there are bound to be exceptions to almost any
>> rule or generalisation.)
>>
>> If you write :
>>
>> int x = 4 / 3;
>> float y = 4 / 3;
>>
>> in most languages, you would not expect the first division to be done as
>> integers and the second to be done as floating point. You would expect
>> consistency. It might be consistently integer division, or consistently
>> floating point (and then converted to integer x and floating point y).
>> But you want consistency.
>
> There are languages that do overloading resolution based on result
> type. In language that I frequently use both are wrong: division
> on integers produces rational number and can not give back an integer.
> Similarely, division for floats needs floats as arguments while
> 3 and 4 are not floats. But there are valid expressions in similar
> spirit: they will do different things depending on result type.
>

Overloading on the operand types is normal :

float y = (float) 4 / 3;

There are some languages that overload on result type too, but they are
less common.

> Probably the most prominent example of language that has overloading
> on result type is Ada. However, IIUC in C++ it is possible to
> have eqivalent effect. Of course, C++ keeps built-in stuff
> reasonably compatible with C, so your examples work as in C.
> But there are interesting examples using user-defiend types.

You can certainly do odd things with C++ to get a related effect, for
your own types. You can have a type "num" with a division operator that
returns a "deferred_division" type encapsulating the numerator and
denominator, with conversions to float, integer (and rational if you
like) which do the actual division. There is a name for that pattern,
which I have completely forgotten, and it can be useful in some types of
coding.

>
> AFAIK the main criterion for "weird" is familiarity: C is widely
> used and several languages ape some aspects of C. But for
> uninitiated many things in C look weird (including your
> division example).
>

Re: How to disambiguate macro?

<sdctvo$c1i$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jameskuy...@alumni.caltech.edu (James Kuyper)
Newsgroups: comp.lang.c
Subject: Re: How to disambiguate macro?
Date: Thu, 22 Jul 2021 19:11:52 -0400
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <sdctvo$c1i$1@dont-email.me>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk>
<sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk>
<sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me>
<sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me>
<871r7r1bfs.fsf@nosuchdomain.example.com> <sdb0tt$tc$1@reader1.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 22 Jul 2021 23:11:52 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="293f7360ca0c850ce98f73732b510147";
logging-data="12338"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4FmtkQ33CYsoLbK1dQQc4g6wFMgFRdAg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:CVITG7kUejks/6GBhR7yhFVlgOw=
In-Reply-To: <sdb0tt$tc$1@reader1.panix.com>
Content-Language: en-US
 by: James Kuyper - Thu, 22 Jul 2021 23:11 UTC

On 7/22/21 1:49 AM, John Forkosh wrote:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>>
>> (ptr != NULL && *ptr == some_value) is a very common idiom
>
> Okay, thanks, that's a good example where && used as a guard
> is a useful construction.
>
> Hmm... and I've got to admit that it's strange I don't recall
> running across it. ...

I'm glad that you agree that it's strange, because it could be hard to
convince you of that if you can't remember ever noticing it. I suspect
that you have actually seen it, but failed to notice.

> ... My own stuff usually looks more like, say,
> int myfunc ( int *ptr ) {
> int status = 0;
> if ( ptr == NULL ) goto end_of_job;
> do_some_stuff_dereferencing_ptr;
> status = 1;
> end_of_job: return ( status ); }
> i.e., args (or malloc's return, etc) are explicitly checked
> to guard a whole block of subsequent code. Your
> (ptr != NULL && *ptr == some_value)
> only guards that one single ptr dereference statement,
> whereas I'd imagine most functionality would involve
> further ptr derefernces that would also need to be guarded
> against nulls.

In many cases that's not a problem:

if(ptr != NULL && ptr->value == some_value)
{
// All further dereferences will occur here, because
// we're only interested in other dereferences of
// ptr if ptr->value has the specified value.
}

And when that's not the case, this idiom shouldn't (and wouldn't) be used:

if(ptr) {

if(ptr->value == some_value) {
// some dereferences of ptr
}
// other dereferences of ptr
}

Re: OT: possessive adjectives

<865yw7yd86.fsf@linuxsc.com>

  copy mid

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

  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: OT: possessive adjectives
Date: Sat, 14 Aug 2021 13:37:29 -0700
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <865yw7yd86.fsf@linuxsc.com>
References: <sd6b8j$498$1@reader1.panix.com> <878s21gney.fsf@bsb.me.uk> <sd6h5j$hng$2@reader1.panix.com> <87fsw9m4qd.fsf@bsb.me.uk> <sd7ud2$hkh$1@reader1.panix.com> <sd8r8p$fph$1@dont-email.me> <sd8rra$f4o$1@reader1.panix.com> <sda3ah$l3i$1@dont-email.me> <sdbqcc$1ir3$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="e69182db6e8a2e097c43a26c68c35bd4";
logging-data="7567"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187XSyViH6b69B/wKsUHe8xGWq32XnBKUw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:tojrcIF5wkgwEL5Zr/kUekHj0Zc=
sha1:h+juIOxovlZdTfRb79c594mJ62k=
 by: Tim Rentsch - Sat, 14 Aug 2021 20:37 UTC

Manfred <noname@add.invalid> writes:

> On 7/21/2021 11:24 PM, James Kuyper wrote:
>
> Sorry about the grammar nit-picking, but...
>
>> As others have pointed out, that's explicitly not the case in C,
>> and there's lots of code that relies upon that fact in order to
>> achieve it's desired effects.
>
> The expression "it's" is a contraction for "it is", and it doesn't
> make sense here. What you mean here is "its", which is the proper
> possessive adjective to be used in this sentence. Confusing the
> two expressions would be the same as confusing "they're" and
> "their".
>
> [...]
>
>> It's guaranteed to work by the standard, deliberately with the
>> intent of
>
> You got "it's" right here...
>
>> allowing developers to rely upon that fact, and most C programmers
>> have written code that relies upon that fact for it's successful
>> execution.
>
> ... but not here either
>
>> Incidentally, the same is true of C++ - and a gratuitous
>> incompatibly between C and C++ goes against the official policies
>> of both the C committee and the C++ committee.
>
> Sorry for patronizing, but your posts usually read fairly correct,
> so I thought this remark might not be like the proverbial drop in
> an ocean in your case - besides, I have a kind of allergy to
> non-compiling sentences (even if English is not my native
> language, and I make mistakes myself)

It may help to remember that the same rule applies to all
personal pronouns: an apostrophe always indicates a
contraction with "am", "is" or "are" -

I am, we are - I'm, we're
you are - you're
he is, she is, it is, they are - he's, she's, it's, they're

and there is never an apostrophe in the possessive form of a
personal pronoun -

my, our
your
his, hers, its, their

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor