Are compiled maxima functions lexically scoped????
Subject: Are compiled maxima functions lexically scoped????
From: Robert Dodier
Date: Thu, 11 Jan 2007 21:41:34 -0700
On 1/11/07, Michel Van den Bergh <michel.vandenbergh at uhasselt.be> wrote:
> I thought interpreted and compiled maxima functions were supposed
> to behave identically
Yes, that is correct. They are *supposed* to behave the same.
> but now I see they do not even on very simple examples.
Well, that's a bug.
> f(s,t):=s[t]
>
> and
>
> f(s):=s[1]
>
> seem to behave as expected when compiled whereas they behave strangely
> when interpreted
I've lost track of what's expected and not expected here -- anyway
I see the following. (I'm using Maxima + GCL here; Clisp would be
OK too, but SBCL compiles everything so you can't see the function
definitions.)
f(s,t):=s[t];
g(s) := s[1];
translate (f, g);
:lisp #'$f
=> (LAMBDA-BLOCK $F ($S $T) (DECLARE (SPECIAL $T $S)) (MAREF $S $T))
:lisp #'$g
=> (LAMBDA-BLOCK $G ($S) (DECLARE (SPECIAL $S)) (MAREF $S 1))
The special declarations make the arguments dynamically bound
instead of lexical. Maybe something else accounts for the different
behavior -- maybe the array referencing isn't the same.
Hmm, tracing MAREF1 (since MAREF is a macro which expands
into MAREF1) I see that MAREF1 is not called from interpreted code.
So that's different.
Hope this helps,
Robert