On Wed, Jul 24, 2024 at 10:30:07PM +0200, Ralf Hemmecke wrote:
> The attached program results in the output given below.
>
> Why is revb3 showing the empty list whereas lb3 does not?
>
> Interestingly, when I remove the line marked with ***, then the output for
> revb3 comes out as expected (see second session below).
>
> It seems like assignment to "revb" inside "delay" is creating a new variable
> revb that is not the same as the argument of restRecip. That's the only
> possible explanation I can come up with.
'delay' is a normal function call, but due to special complier rule
its argument is compiled as a nested function. In current Spad
compiler nested function gets new set of variables, and assigment
to those variables have no effect on enclosing function. Also,
there is official rule that if your first use of variable is a read,
then its initial value is inherited from enclosing scope, but I
suspect that our current code does not follow this rule. A safe
way of coding is to use new variables for anything that you want
to mutate in a nested function.
--
Waldek Hebisch
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/ZqIJoMA-JjRXUQhb%40fricas.org.