Interesting Algol 68 idiom: UPB a[@1]

Jose E. Marchesi jemarch@gnu.org
Fri Jan 16 09:25:46 GMT 2026


> I think I'm missing something...
>
> On Thu, Jan 15, 2026, 11:34 Jose E. Marchesi <jemarch@gnu.org> wrote:
>
>>
>> Hello people!
>>
>> Just wanted to share a nice idiom I learned while porting the ELLA
>> sources.
>>
>> The usual way to iterated over the elements of a multiple with the
>> intention of indexing them is:
>>
>>
>>   for i from LWB a to UPB a do ... a[i] ... od
>>
>> This can be a bit cumbersome.  The following shorter version is not
>> valid, because the lower bound of the multiple `a' may not be 1:
>>
>>   for i to UPB a do ... a[i] ... od
>>
>> This is also not correct, for the same reason:
>>
>>   for i to ELEMS a do ... a[i] ... od
>>
>> What I learned in ELLA is that you can do:
>>
>>   for i to UPB a[@1] do ... a[i] ... od
>>
>
> Doesn't that have to be
>
> for i to UPB a[@1] do ... a[i + LWB a - 1] ... od
>
> ¿?

Yes I meant to say a[@1][i] in the body.

>
>
>> It is short, and clear.
>>
>> I am actually tempted to put a fixed check in the compiler to compile it
>> optimally so a trimmer doesn't get allocated.
>>
>> Hope this is useful.
>> Salud!
>>
> Chris Hermansen · clhermansen "at" gmail "dot" com
>
> C'est ma façon de parler.


More information about the Algol68 mailing list