The following demonstrates a bug in the interpreter.
OK, doesn't seem to be a bug, but still quite hard to figure out what's
wrong.
Program is attached.
The two functions differ only in a line break after the statement
n3: Z := x2;
Thinking a bit about it, maybe
n2: Z := x2; for i2 in 1..n2 repeat
n3: Z := x2; for i3 in 1..n3 repeat x3 := x3 + 1
is interpreted as
n2: Z := x2; for i2 in 1..n2 repeat n3: Z := x2;
for i3 in 1..n3 repeat x3 := x3 + 1
Thus the error would be clear, since n3 is not available when the second
loop is started.
Still the error is very hard to detect if one mixes indentation with
semicolon.
So to all... be careful when you use just an indented one-line-block.
It's not a block, but just a continuation of the previous line.
Ralf
===============================================================
loop1 1
Compiling function loop1 with type Integer -> Integer
(4) 0
Type:
NonNegativeInteger
loop2 1
Compiling function loop2 with type Integer -> Integer
>> System error:
The value UNINITIALIZED_VARIABLE is not of type FIXNUM.
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Z==>Integer
loop1(x1: Z): Z ==
x0: Z := 0;
x2: Z := 0;
n1: Z := x1; for i1 in 1..n1 repeat
x3: Z := 0;
n2: Z := x2; for i2 in 1..n2 repeat
n3: Z := x2;
for i3 in 1..n3 repeat x3 := x3 + 1
x2 := x2 + 1
return x0
loop2(x1: Z): Z ==
x0: Z := 0;
x2: Z := 0;
n1: Z := x1; for i1 in 1..n1 repeat
x3: Z := 0;
n2: Z := x2; for i2 in 1..n2 repeat n3: Z := x2;
for i3 in 1..n3 repeat x3 := x3 + 1
x2 := x2 + 1
return x0
loop1 1
loop2 1
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.