🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1348

Re: Rationales for result type of operations using operators like '+='

#1348
From: Janis Papanagnou
Date: Fri, 06 Nov 2026 09:25
141 lines
7162 bytes
On 2026-11-06 01:27, bartc wrote:
> On 05/11/2026 22:41, Janis Papanagnou wrote:
>> On 2026-11-05 13:17, bartc wrote:
[...]
> 
>>>    i +:= 2 *:= i;
>>
>> What is that supposed to implement in the first place is the question!
>> I suggest to explain a sensible task,
>
> The task doesn't matter.

For a sensible consideration a sensible example (not a made up
one) from a practical application is imperative. Otherwise, as
was already pointed out multiple times in various communications
with you, you stupidly construct just bad code that no one would
write that way in the first place and for no practical use.

> The behaviour needs to be well-defined.

The fine thing here is that programming languages are typically
"well-defined". (Algol 68 is. In "C" there's unfortunately quite
some places where you need a lot deep knowledge to avoid things
that are unreliable because of being undefined, yet accepted by
the compilers.)

> And here that might be unintuitive.

What's intuitive is a subjective matter. You said already that
you have problems with it, that it "confuses" you. (Repetitions
don't make your opinions and your personal problems a fact.)

> 
>>> The second 'i' will have the new value i + 2, not the original, even 
>>> though it has not obviously been modified.
>>
>> Are you now speaking about a left-associative interpretation?
> 
> I'm speaking about observed behaviour from A68G:

Okay, so you speak about a left-associative interpretation here.

> 
>   INT i:=100;
>   i +:= 2 *:= i;
>   print(i)

Hardly any professional programmer would write such expressions
with side-effects; "C" is full of such. ("If it hurts just don't
do it!")

It would really help to make the discussion more serious if you'd
choose sensible examples without side-effects, which always cause
confusion in any language or language-construct where it's used!

> 
> Output is 10404, or 102 * 102. It is not the same as either of:
> 
>    i := i + 2 * i;       # 300 #
>    i := (i + 2) * i;     # 10200 #

Your example appears still nonsensical and bad. I suggested using
examples from real applications and observe the various choices
you have to model such functionality in the respective languages.

> 
> It is also confusing in that here:
> 
>    number *:= base +:= digit
> 
> It looks as though 'base' is being modified too.

Only if you don't know the semantics. - You've been often told (WRT
"C") that you should learn the language you use. It's not different
with other languages.

I don't know about you. I started programming with a comparably lousy
programming language (with strong focus on structuring with 'goto's).
Whenever I learned a new language with new, own paradigms I made use
of its features and modelling styles wherever I saw them applicable
in useful ways for my software. Be it OO, functional, declarational,
whatever. If you are lacking that flexibility, well, just stay with
what serves you, use something that doesn't confuse you.

You regularly say you have problems also with "C", and you regularly
complain about it. - What's your goal with all your complaints; be
it "C" in general, or this specific Algol 68 feature? We meanwhile all
know that there's so much that confuses you. We know that you prefer
to write (despite the necessary effort and the plethora of existing
languages of different kinds you could choose from) own compilers for
self-designed languages that don't confuse you. - What's your goal?
Do you want to just get confirmations from other folks that they are
as confused as you are? (Even despite they are not confused?)

> [ snip another, yet more pathological example with side-effects ]
> 
>> I understand that it is confusing to you. I understand that you seem
>> to consider it to be "fiddly". I understand that you are incapable of
>> defining a clear semantics
> 
> The point is that the semantics are necessarily more obscure and less 
> obvious compared with plain code which only has one assignment.

But they aren't at all obscure. The semantics are really most simple!
Process the expression in your mind like a "pipe" (or like any other
numerical or typical string expressions) just from left to right.

But (in Algol 68) you should also understand that expressions may not
only be comprised of "level-0-values" but also that "level-1-values"
(references, "names", "variables") can be returned. Maybe different
from the languages you know but all most consistent; Algol 68 is known
for its orthogonality and consistency, especially if compared with "C"
or similar. But since it's different you have to learn its concepts
(if you intend to use it, and also if you want to dispute about it).

But at that point I want to remember the intention of my thread. - It
was not to advertise Algol 68, but to ask why "C" invented op= as part
of expressions (as opposed to a statement) with semantics to return a
value and right associativity.

> 
>> so that it won't surprise anyone.
> 
> I understand that you've never had to implement any of this stuff.

What "this stuff"? - You mean side-effects, as in your pathological
examples above? - Yes, you are right. I try to avoid all side effects.
And I certainly wouldn't artificially add them in my code just "for a
kick".

Or are you speaking about writing a compiler that would have this (in
your opinion) "huge difficulty" implementing a proper semantics for
these sorts of expressions? - Others have done that and I've not heard
that this (IMO primitive) detail would have caused any implementation
problems. (Algol 68 certainly has other corners where very demanding
proficiencies are required.)

Janis

> [...]
Technical Details
Message-ID: <11ck6e8$23539$6@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11ceoa2$85p3$3@dont-email.me> <11chs5e$1jlqr$1@dont-email.me> <11cj0n7$85p3$8@dont-email.me> <11cj6t3$242aq$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: Rationales for result type of operations using operators like
 '+='
Date: Fri, 6 Nov 2026 10:25:28 +0100
Organization: A noiseless patient Spider
Lines: 141
Message-ID: <11ck6e8$23539$6@dont-email.me>
References: <11ceoa2$85p3$3@dont-email.me> <11chs5e$1jlqr$1@dont-email.me>
 <11cj0n7$85p3$8@dont-email.me> <11cj6t3$242aq$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 06 Nov 2026 09:25:29 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2200681"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19l9tZY0zhwWg0qgMBnsSIF"; posting-host="a1c3eccefbcc1d6f648cf481fadc4299"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:21aRJWsfpE7Xy6kfOViVbL524uE= sha256:+cp5yt6uQKIgwXY7jRZvPWZg2WigDmPSwTZ6fguHMZI=
	sha1:F63Vdj6qcrlXSP6Xi8XOmiYCXro= sha256:Old9hibyt2MznyttBzTsVP+3QME3zURrB4KukcCAQ+A=
In-Reply-To: <11cj6t3$242aq$1@dont-email.me>
Content-Language: en-US