assignments in ginsh
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/>
Dear Richard, I feel that the earlier situation may be indeed more natural within ginsh. It just needs to be sufficiently documented as in your email. Happy New 2025 Year to everyone! Vladimir -- Vladimir V. Kisil http://v-v-kisil.scienceontheweb.net Book: Geometry of Mobius Maps https://doi.org/10.1142/p835 Soft: Geometry of cycles http://moebinv.sourceforge.net/ Jupyter notebooks: https://github.com/vvkisil?tab=repositories
On Tue, 31 Dec 2024 19:18:14 +0100, "Richard B. Kreckel" <kreckel@in.terlu.de> said: RK> Hi,
RK> The behavior of ginsh w.r.t. recursive variable assignment has RK> silently changed in GiNaC 1.4.4 (eaa0370a). Before, we got: >> a=3+x: x=2: a; RK> 5 RK> Now, we get: >> a=3+x: x=2: a; RK> 3+x RK> It may be worth pointing out that in both cases, one gets: >> x=2: a=3+x: a; RK> 5 RK> The old behavior can be easily restored (patch attached). Should RK> we? RK> Pros: ----- Ginsh isn't a real programming language - it has a RK> global namespace without scoping. Under these circumstances, it RK> seems natural to think of assignments as occurring in every RK> variable defined before and after. (There is even an example in RK> the tutorial which is now wrong; search for "x=2".) RK> Cons: ----- This is not how it works in C++. There, we have: ex RK> x = symbol("x"); ex a = 3+x; x = 2; cout << a << endl; // prints RK> 3+x, not 5 RK> I am inclined to restore the old behavior, but it may be that RK> someone has other thoughts. Or, maybe it is totally unimportant? RK> Any comments? RK> All my best, -richard. -- Richard B. Kreckel
participants (2)
-
Richard B. Kreckel
-
Vladimir V. Kisil