plusto operator definition missing?
chris hermansen
clhermansen@gmail.com
Mon Jul 14 17:05:33 GMT 2025
Just to confirm...
On Mon, Jul 14, 2025 at 7:20 AM chris hermansen <clhermansen@gmail.com>
wrote:
> Good day, Jose & list;
>
> On Sun, Jul 13, 2025 at 1:24 PM Jose E. Marchesi <jemarch@gnu.org> wrote:
>
>>
>> > Hello all,
>> >
>> > I was going through Lindsey a couple of days ago and noticed the plusto
>> > operator definition on p. 244. Here is what it says:
>> >
>> > operator priority mode of a mode of b mode of result meaning
>> > plusto 1 string ref string ref string b := a + b
>> > +=: char ref string ref string
>> >
>> > (I hope that shows up ok in peoples' email; I did it in fixed width
>> text)
>> >
>> > I have a version of the procedure "whole" that I use with GNU Algol 68
>> that
>> > has the line
>> >
>> > digit_string := digit_char + digit_string
>> >
>> > in it, and I thought I'd try +=: instead, as in:
>> >
>> > digit_string +=: digit_char
>> >
>> > However, ga68 complains:
>> >
>> > testl.a68:277:50: error: CHAR cannot be coerced to REF STRING in this
>> > context
>> > 277 | digit_string +=: digit_char;
>> >
>> > I am supposing that this is due to not having the second version of the
>> > operator defined - the one that works with a char on the right hand
>> side.
>> >
>> > Am I missing something? Thanks in advance.
>>
>> I think you mean:
>>
>> digit_char +=: digit_string;
>>
>> Which works as expected.
>>
>
> So I tried this, but I think it does not work as expected.
>
> Again, referring to Lindsey p. 244
>
> a +=: b
>
> is supposed to be equivalent to
>
> b := a + b
>
> That is, the point of plusto is to prepend rather than append.
>
> But it seems like GNU Algol 68 is generating
>
> b := b + a
>
> Perhaps I've missed something?
>
>
Indeed the Revised Report shows this on page 138:
q) op ⦓ plusab, +: = ⦔ = (ref string a, string b) ref string : a := a+ b;
r) op ⦓ plusto, +=: ⦔ = (string a, ref string b) ref string: b := a+ b;
s) op ⦓ plusab, +: = ⦔ = (ref string a, char b) ref string: a +:= string
(b);
t) op ⦓ plusto, +=: ⦔ = (char a, ref string b) ref string: string (a) +=:
b;
--
Chris Hermansen · clhermansen "at" gmail "dot" com
C'est ma façon de parler.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/algol68/attachments/20250714/07080f54/attachment.htm>
More information about the Algol68
mailing list