Re: what does declare(x, special) do?
2010-01-01 02:19:59 GMT
On Wed, Dec 16, 2009 at 11:39 AM, nijso beishuizen <nijso <at> hotmail.com> wrote:It's obsolete, probably we should have cut out that stuff long ago.
> what does declare(x,special) do to x?
I'm pretty sure it has no effect whatsoever.
Maxima -- like Maclisp and other Lisps designed in the 1960's -- originally had dynamic scope when interpreted and a limited sort of lexical scope when compiled -- yes, interpreted and compiled code did not always give the same results! Variables declared special were bound dynamically even in compiled code.
Maxima now has dynamic scope both interpreted and compiled (see test below) - in effect, *all* variables are declared special. I do not know what commercial Macsyma did/does.
-s
(%i1) f() := block([a:23],g())$
(%i2) g() := a$
(%i3) f();
(%o3) 23
(%i4) translate(f,g);
(%o4) [f, g]
(%i5) f();
(%o5) 23
(%i6) compile(f,g);
Compiling C:/Users/Stavros/AppData/Local/Temp/gazonk_2036_0.lsp.
End of Pass 1.
End of Pass 2.
OPTIMIZE levels: Safety=2, Space=3, Speed=3
Finished compiling C:/Users/Stavros/AppData/Local/Temp/gazonk_2036_0.lsp.
Compiling C:/Users/Stavros/AppData/Local/Temp/gazonk_2036_0.lsp.
End of Pass 1.
End of Pass 2.
OPTIMIZE levels: Safety=2, Space=3, Speed=3
Finished compiling C:/Users/Stavros/AppData/Local/Temp/gazonk_2036_0.lsp.
(%o6) [f, g]
(%i7) f();
(%o7) 23
(%i8) block([a:56],f());
(%o8) 23
For the record, all Maxima variables are special variables in the
sense of Lisp special variables (from which the Maxima special
declaration was copied, I suppose). From time to time I wish that
Maxima implemented some kind of lexical variable, but that's
a separate topic ....
_______________________________________________ Maxima mailing list Maxima <at> math.utexas.edu http://www.math.utexas.edu/mailman/listinfo/maxima
RSS Feed