<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body text="#000000" bgcolor="#ffffff">
<br>
<br>
Taoufik Dachraoui wrote:
<blockquote type="cite" cite="mid:ED693AF3-66CA-4AE7-88A2-D4967F818E8A@wanadoo.fr"><br>
<div>
<div>
<div>
<div><br>
</div>
<div>? (defvar x 1) ; x is special</div>
<div>X</div>
<div>? (let ((x 1)) ; without declaring x special it is special
because of defvar (lost control)</div>
<div> (let ((x 2)) ; so where in the specs that says (defvar
name init) </div>
<div> (+ x x))) ; must treat name as special everywhere
even if it is</div>
<div>4 <span style="white-space: pre;" class="Apple-tab-span"> </span>
<span style="white-space: pre;" class="Apple-tab-span"> </span>
; used in a let block, where let is supposed to create</div>
<div><span style="white-space: pre;" class="Apple-tab-span"> </span>
; a new lexical variable binding (not special unless
declared so)</div>
</div>
</div>
</div>
</blockquote>
No, that's not the Common Lisp language. If x is globally<br>
declared special, and then you do a let naming x as a<br>
variable, let does a dynamic binding operation.<br>
<blockquote type="cite" cite="mid:ED693AF3-66CA-4AE7-88A2-D4967F818E8A@wanadoo.fr">
<div>
<div>
<div><br>
<div><br>
</div>
<div>Again look at this example of a closure:</div>
<div><br>
</div>
<div>(let ((x 1)) (defun foo (y) (+ x y)))</div>
<div><br>
</div>
<div>It is obvious that if x is defvar'ed then the code will not
behave as the programmer</div>
<div>intention.</div>
</div>
</div>
</div>
</blockquote>
That depends on what the programmer did, in fact, intend!<br>
<br>
But if what you're saying is that this form does different<br>
things depending on whether a global special declaration<br>
has been established (as "defvar" does), that's right, it does.<br>
<blockquote type="cite" cite="mid:ED693AF3-66CA-4AE7-88A2-D4967F818E8A@wanadoo.fr">
<div>
<div>
<div>
<div> This closure definition is legitimate, but the programmer can
use a symbol</div>
<div>name that is defvar'ed without him knowing.</div>
</div>
</div>
</div>
</blockquote>
Yes, a programmer could be fooled by not being<br>
aware that x has been declared special.<br>
<br>
That's why the *x* convention is used.<br>
<br>
Now, whether Lisp SHOULD work this way is a separate<br>
discussion, but that's how Common Lisp is defined.<br>
<br>
<br>
</body>
</html>