[GiNaC-devel] assignments in ginsh
Richard B. Kreckel
kreckel at in.terlu.de
Tue Dec 31 19:18:14 CET 2024
Hi,
The behavior of ginsh w.r.t. recursive variable assignment has silently
changed in GiNaC 1.4.4 (eaa0370a). Before, we got:
> a=3+x:
> x=2:
> a;
5
Now, we get:
> a=3+x:
> x=2:
> a;
3+x
It may be worth pointing out that in both cases, one gets:
> x=2:
> a=3+x:
> a;
5
The old behavior can be easily restored (patch attached). Should we?
Pros:
-----
Ginsh isn't a real programming language - it has a global namespace
without scoping. Under these circumstances, it seems natural to think of
assignments as occurring in every variable defined before and after.
(There is even an example in the tutorial which is now wrong; search for
"x=2".)
Cons:
-----
This is not how it works in C++. There, we have:
ex x = symbol("x");
ex a = 3+x;
x = 2;
cout << a << endl; // prints 3+x, not 5
I am inclined to restore the old behavior, but it may be that someone
has other thoughts. Or, maybe it is totally unimportant?
Any comments?
All my best,
-richard.
--
Richard B. Kreckel
<https://in.terlu.de/~kreckel/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ginsh.patch
Type: text/x-patch
Size: 764 bytes
Desc: not available
URL: <http://www.ginac.de/pipermail/ginac-devel/attachments/20241231/07ed8749/attachment.bin>
More information about the GiNaC-devel
mailing list