Regarding literals and loop indices modes / programming friction
Mohammad-Reza Nabipoor
mnabipoor@gnu.org
Sun Jan 25 15:07:12 GMT 2026
On Sun, Jan 25, 2026 at 03:52:50PM +0100, jpl wrote:
> Quick followup post.
>
> I tried to set the count variable to long int. I was hoping one could do this:
>
> for long int count to 3 do
> zz +:= count
> od;
>
> But, would not compile:
>
> long_learning.a68:45:8: error: keyword expected in loop clause, near
> ‘for’ in this line
> 45 | for long int count to 3 do
> | ^
>
The mode of "control-integer" is `int' and you cannot change it.
> So, attempting this instead (not really optimal to have that variable
> live outside of the loop):
>
> long int count;
> for count to 3 do
> zz +:= count
> od;
>
> Would not compile, error msg:
>
> long_learning.a68:46:10: error: dyadic operator ref long real ‘+:=’
> int has not been declared
> 46 | zz +:= count
> | ^
>
Here `for' introduces a new range (scope) and there it defines `int count := 1'
and basically shadows your `long int count;' variable declaration.
> So, it appears that the "Leng" is needed even when count is a long
> int. This works:
>
> long int count;
> for count to 3 do
> zz +:= Leng count
> od;
>
Yes.
More information about the Algol68
mailing list