Add local declarations in share/numeric/interpol.mac
It prevents errors like
(%i1) load("interpol")$ (%i2) tab[any]:=error(); (%o2) tab := error() any (%i3) linearinterpol(dat1), dat1: matrix([6.5,3],[1.8,-8],[9,2],[-2,4],[1/8,1][9/12,3],[10,%pi]); #0: lambda([any],error())(any=2) #1: linearinterpol(tab=matrix([6.5,3],[1.8,-8],[9,2],[-2,4],[1/8,1],[3/4,3],[10,%pi]),select=[])(interpol.mac line 148) -- an error. To debug this try: debugmode(true);
Add missing file with a patch.
This doesn't happen in the latest version of maxima. First, there's a typo in the definition of
dat1
. There's a missing comma before the list[9/12,3]
. When that is fixed, I get:I didn't check to see if this is correct or not, but the error is gone.
Closing since the error no longer happens.
The problem is still there. Other examples exist in the bug list; e.g. https://sourceforge.net/p/maxima/bugs/2519/ . Although this behavior is "broken as designed", that doesn't rule out trying to work around it, so I guess we might apply this patch; I'm undecided.
Any function which has a function argument or block variable which is subscripted has the potential for showing the bug, if there exists a global symbol which has the same name. For example, I see in the
interpol
source code that there is a symboldata
which is subscripted. So here's a way to tickle the bug:which provokes
This is an example of a whole class of global-local name collision bugs which go away when symbols have lexical scope, something I've worked on from time to time; I guess I should get it together and finish it. Anyone who wants to help is welcome to do so.
I agree that lexical scope will fix this, but in the meantime, a
local statement
fixes the particular case in interpol.
You can blindly add local(...) for all the function parameters and local
variables -- being careful to exclude global variables like ratprint --
and it will work. Of course, better if you only use local for the symbols
that need it.
This is much less efficient than a good lexical scope solution, because it
saves and restores properties of the symbols, but at least it is correct.
On Thu, Sep 14, 2023 at 3:45 PM Robert Dodier robert_dodier@users.sourceforge.net wrote:
Related
Patches:
#54