This was something new to me; I learned that in
INT n = 8;
[n] REF [] INT tri;
FOR i TO n DO
tri[i] := LOC [i] INT # LOC is okay #
OD;
between the DO and the OD there's no Local Range!
With the consequence that the LOC element will be
accessible outside the FOR loop!
And that the Local Range "gets into existence" by
some (even unrelated) declaration, so that [...]
the same (previously valid) code becomes an error
only by existence of the "spurious" declaration.
I find that quite irritating; I'd have expected
that even a closed clause without any declaration
would constitute an (albeit "empty") Local Range.
What's the rationale behind that design decision?
On 20/12/2025 12:28, Janis Papanagnou wrote:
This was something new to me; I learned that in
INT n = 8;
[n] REF [] INT tri;
FOR i TO n DO
tri[i] := LOC [i] INT # LOC is okay #
OD;
between the DO and the OD there's no Local Range!
My reading of RR3.5 interprets that as incorrect, so I think
this is an A68G-ism. I can't offhand see a stated difference between
A68 and A68G in this area, but I just have an impression that A68G
tries to minimise the number of nested ranges.
[...]
My reading of RR3.5 interprets that as incorrect, so I think this is
an A68G-ism.
On Sat, 20 Dec 2025 14:01:27 +0000, Andy Walker wrote:
My reading of RR3.5 interprets that as incorrect, so I think this is
an A68G-ism.
Particularly since the loop index is supposed to be a constant, and by
normal Algol 68 rules you can’t redeclare a constant (as needs to
happen each time round the loop) without entering a new scope.
Re "A68G"; actually (AFAICT) that's not a Genie issue. I found that
property explicitly described and with a similar example in
Lindsey, van der Meulen: "Informal Introduction to ALGOL 68" [*]
(If I understand correctly that's an informal amendment to the RR?)No, it's supposed to be an informal description of A68, readable
On 20/12/2025 16:39, Janis Papanagnou wrote:
[re "LOC" inside loops:]
Re "A68G"; actually (AFAICT) that's not a Genie issue. I found that
property explicitly described and with a similar example in
Lindsey, van der Meulen: "Informal Introduction to ALGOL 68" [*]
Hmm. You seem to be correct. "FOR i ..." seems to be a local definition of "i", but technically not a declaration, so that a few
weasel words later, you get the effect you describe. So in deeply nested loops you can have arbitrarily many copies of values with the same identifier. This is pretty yucky, IMO, and also breaks the equivalence
of loops with "the same" code written out using jumps and explicit tests
[as described in the RR].
(If I understand correctly that's an informal amendment to the RR?)
No, it's supposed to be an informal description of A68, readable
by people who don't understand two-level grammars. [...]
There were enough errors [I found and reported half a dozen] that an
updated RR would not have been a bad thing,
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,090 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 63:13:51 |
| Calls: | 13,949 |
| Calls today: | 2 |
| Files: | 187,035 |
| D/L today: |
3,464 files (1,014M bytes) |
| Messages: | 2,461,403 |