what does declare(x, special) do?



On Wed, Dec 16, 2009 at 7:27 PM, Robert Dodier <robert.dodier at gmail.com>wrote:

> On Wed, Dec 16, 2009 at 11:39 AM, nijso beishuizen <nijso at hotmail.com>
> wrote:
> > what does declare(x,special) do to x?
>
> It's obsolete, probably we should have cut out that stuff long ago.
> 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 ....
>