On issue #60 (iterate)

2 views
Skip to first unread message

riccard...@gmail.com

unread,
Jun 30, 2021, 12:52:07 PM6/30/21
to fricas...@googlegroups.com
Hi Ralf,

I saw your issue on token iterate (available in interpreter to quit the current iteration and continue with others) which seems missing in compiler (spad files) [1].

Do not ask me why, but spad files in algebra use "iterate" (verbatim, ie a string) in the same way one would use iterate, see e.g. [2].

Actually I see "iterate" used with this semantics also in interpreter's input files [3] and boot files [4].

Riccardo

[1] https://github.com/fricas/fricas/issues/60
[2] https://github.com/fricas/fricas/blob/c0ee6ecbe4a5f44856e3af085282edb7e80e2a18/src/algebra/symbol.spad#L123
[3] https://github.com/fricas/fricas/blob/c0ee6ecbe4a5f44856e3af085282edb7e80e2a18/src/input/integ.input#L11
[4] https://github.com/fricas/fricas/blob/c0ee6ecbe4a5f44856e3af085282edb7e80e2a18/src/interp/format.boot#L563

Ralf Hemmecke

unread,
Jun 30, 2021, 1:24:53 PM6/30/21
to fricas...@googlegroups.com
> I saw your issue on token iterate (available in interpreter to quit the
> current iteration and continue with others) which seems missing in
> compiler (spad files) [1].
>
> Do not ask me why, but spad files in algebra use "iterate" (verbatim, ie
> a string) in the same way one would use iterate, see e.g. [2].
>
> Actually I see "iterate" used with this semantics also in interpreter's
> input files [3] and boot files [4].

In

foo(): Integer ==
z: Integer := 0
for i in 1..9 repeat
odd? i => iterate
z := z+i
z

it would not be a problem to replace iterate by the string "iterate",
because the loop body has the form
(bool => val; otherval)
and the => operator terminates the block exactly at that position.
You would see a change if the body where

if odd? i then "iterate"
z := z + i

So the iterate keyword is not strictly necessary when used with any
value after =>.

However, The FriCAS book explicitly tells about an iterate keyword. In
this sense, the issue I opened is definitely a bug. And, honestly, I do
not like to see a string in a place where there shouldn't be one. All
such strings look like workarounds.

BTW, also in places like

"+": (%,%)->%

there shouldn't actually be quotes. It's a weakness of the SPAD compiler.


Ralf
Reply all
Reply to author
Forward
0 new messages