bug? unexpected variable binding



--Alt-Boundary-28102.49107142
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

>    Volker> (%i1) :lisp(setf a 2)
>    Volker> 2
>    Volker> (%i1) :lisp(defun bar (x) a)
>    Volker> BAR
>    Volker> (%i1) :lisp(defun foo (a) (bar a))
>    Volker> FOO
>    Volker> (%i1) :lisp(foo 1)
>    Volker> 2
>
> I think this is not valid Common Lisp code.  There is no such thing as
> a global lexical, so (setf a 2) isn't legal, unless a has already been
> declared a special variable via defvar or defparameter or declare.
>
> If you do that, then lisp will return the same answer as maxima
> because the call to foo binds a (a special variable) to 1, which is
> what bar sees and returns.
>
> That it works for you just means the Lisp implementation you are using
> has global lexicals of some sort.
>
> Ray

Thanks Ray, 
that makes it clear.
Volker

--Alt-Boundary-28102.49107142
Content-type: text/html; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

<?xml  version="1.0" ?><html>
<head>
<title></title>
</head>
<body>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; (%i1) :lisp(setf a 2)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; 2</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; (%i1) :lisp(defun bar (x) a)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; BAR</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; (%i1) :lisp(defun foo (a) (bar a))</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; FOO</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; (%i1) :lisp(foo 1)</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;&#160;&#160;&#160; Volker&gt; 2</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; I think this is not valid Common Lisp code.&#160; There is no such thing as</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; a global lexical, so (setf a 2) isn't legal, unless a has already been</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; declared a special variable via defvar or defparameter or declare.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; If you do that, then lisp will return the same answer as maxima</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; because the call to foo binds a (a special variable) to 1, which is</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; what bar sees and returns.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; That it works for you just means the Lisp implementation you are using</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; has global lexicals of some sort.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt;</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">&gt; Ray</span></font></div>
<div align="left"><br/>
</div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Thanks Ray, </span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">that makes it clear.</span></font></div>
<div align="left"><font face="Arial"><span style="font-size:10pt">Volker</span></font></div>
</body>
</html>

--Alt-Boundary-28102.49107142--