empty statement?

4 views
Skip to first unread message

Ralf Hemmecke

unread,
Oct 7, 2023, 12:10:43 PM10/7/23
to fricas-devel
(394) -> for i in 1..10 repeat (print i; print(i^2);)
Line 1: for i in 1..10 repeat (print i; print(i^2);)
...........................................A
Error A: syntax error at top level
Error A: Improper syntax.
2 error(s) parsing

Maybe it is more obvious in the above form that an empty statement is
there. Originally it was something like this:

for i in 1..10 repeat
print i;
print(i^2);

in a .input file.

This

for i in 1..10 repeat ()

works just fine, so why doesn't the one at the beginning?
I think, it should be allowed to have one trailing semicolon. No?

Ralf

Waldek Hebisch

unread,
Oct 8, 2023, 9:42:31 AM10/8/23
to fricas...@googlegroups.com
On Sat, Oct 07, 2023 at 06:10:40PM +0200, Ralf Hemmecke wrote:
> (394) -> for i in 1..10 repeat (print i; print(i^2);)
> Line 1: for i in 1..10 repeat (print i; print(i^2);)
> ...........................................A
> Error A: syntax error at top level
> Error A: Improper syntax.
> 2 error(s) parsing
>
> Maybe it is more obvious in the above form that an empty statement is there.
> Originally it was something like this:
>
> for i in 1..10 repeat
> print i;
> print(i^2);
>
> in a .input file.

Actually, this enough

(print 1; print(2);)

> This
>
> for i in 1..10 repeat ()
>
> works just fine,

Intepreter has special case to handle empty tuple '()'.

> so why doesn't the one at the beginning?
> I think, it should be allowed to have one trailing semicolon. No?

Should, yes. AFAICS this works is Spad. In interpreter this
may be problematic.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages