<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Also, I would like to insist on the fact that SETF creates a lexical variable (on behavior at least,<div><div>it is weird for me to say that because for me when I learned Common Lisp I was told that</div><div>there a daynamic and lexical variables).</div><div><br></div><div>The following example shows that SETF creates a lexical variable (because f always returns</div><div>the value of x as defined by SETF)</div><div><br></div><div><div>? (setf x 1)</div><div>1</div><div>? (defun f () (+ x 1))</div><div>;Compiler warnings :</div><div>;   In F: Undeclared free variable X</div><div>F</div><div>? (let ((x 5)) (f))</div><div>;Compiler warnings :</div><div>;   In an anonymous lambda form: Unused lexical variable X</div><div>2</div><div>? (defvar y 1)</div><div>Y</div><div>? (defun g () (+ 1 y))</div><div>G</div><div>? (let ((x 5) (y 10)) (values (f) (g)))</div><div>;Compiler warnings :</div><div>;   In an anonymous lambda form: Unused lexical variable X</div><div>2</div><div>11</div><div><br></div><div>If you do not agree please explain in more details so I learn and understand something new.</div><div><br></div><div>Taoufik</div></div><div><div><br><div><div>On Oct 18, 2009, at 1:05 PM, Taoufik Dachraoui wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Sorry but I have to insist.<div><br></div><div>In the CL specs </div><div><br></div><div><div><span class="Apple-style-span" style="font-family: Times; "><b><font class="Apple-style-span" face="Helvetica"><span class="Apple-style-span" style="font-weight: normal; ">"</span></font><a rel="DEFINITION" href="file:///usr/local/doc/HyperSpec/Body/s_the.htm#the">the</a></b> specifies that the <a rel="DEFINITION" href="file:///usr/local/doc/HyperSpec/Body/26_glo_v.htm#value"><i>values</i></a>[1a] returned by <i>form</i> are of the <a rel="DEFINITION" href="file:///usr/local/doc/HyperSpec/Body/26_glo_t.htm#type"><i>types</i></a> specified by <i>value-type</i>. </span></div><div><span class="Apple-style-span" style="font-family: Times; ">The consequences are undefined if any <i>result</i> is not of the declared type."</span></div></div><div><br></div><div>It is clear that (THE type expr)  specifies the the returned value of expr is of type type.</div><div><br></div><div>Again the example:</div><div><br></div><div><div>? (setf z 1)</div><div>1</div><div>? (the fixnum z)</div><div>;Compiler warnings :</div><div>;   In an anonymous lambda form: Undeclared free variable Z</div><div>1</div><div>? z</div><div>1</div><div>? (the fixnum 1)</div><div>1</div><div>?</div><div><br></div><div>As you can see, after the SETF z has a value of 1 and (THE fixnum 1) does not raise a </div><div>warning but  (THE fixnum z) does, this means to me that the THE operator does not </div><div>merely uses the returned value of z but has something too say about z, and this is wrong</div><div>I believe.</div><div><br></div><div>Taoufik</div><div><br></div><div><br></div><div><br></div></div><div><br></div><div><div><div>On Oct 18, 2009, at 12:40 PM, Ron Garret wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br><br>On Oct 18, 2009, at 3:28 AM, Taoufik Dachraoui wrote:<br><br><blockquote type="cite">I am not talking about the warnings, warnings are sometimes necessary, and I understand the<br></blockquote><blockquote type="cite">difference between dynamic and lexical variables.<br></blockquote><br>But not, apparently, the difference between compile-time and run-time.<br><br><blockquote type="cite">I am puzzled by the special operator THE as implemented in CCL. Why the THE operator<br></blockquote><blockquote type="cite">expects a special variable<br></blockquote><br>It doesn't.<br><br><blockquote type="cite">and not simply specifies the value returned by the expression as<br></blockquote><blockquote type="cite">described in the CLHS:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">again the example I gave shows the awkwardness:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">? (setf x 3)<br></blockquote><blockquote type="cite">3<br></blockquote><blockquote type="cite">? (the fixnum x)<br></blockquote><blockquote type="cite">;Compiler warnings :<br></blockquote><blockquote type="cite">;   In an anonymous lambda form: Undeclared free variable X<br></blockquote><blockquote type="cite">3<br></blockquote><blockquote type="cite">? (defun f () x)<br></blockquote><blockquote type="cite">;Compiler warnings :<br></blockquote><blockquote type="cite">;   In F: Undeclared free variable X<br></blockquote><blockquote type="cite">F<br></blockquote><blockquote type="cite">? (the fixnum (f))<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The last form shows that the THE operator did not care about the x it just specified the<br></blockquote><blockquote type="cite">value of the result without complaining, but if the expression directly contain a non defined<br></blockquote><blockquote type="cite">variable as in the first form, the THE operator raise a warning.<br></blockquote><br>This has nothing to do with THE.  This warning is generated by the compiler.  In CCL, most, but not all, expressions are compiled before they are run.  *Any* expression sufficiently complex to trigger a compilation will produce the warning:<br><br>Welcome to Clozure Common Lisp Version 1.4-dev-r12726M-trunk  (DarwinX8664)!<br>? (setf x 1)<br>1<br>? (let ((y x)) y)<br>;Compiler warnings :<br>;   In an anonymous lambda form: Undeclared free variable X<br>1<br>? ((lambda () x))<br>;Compiler warnings :<br>;   In an anonymous lambda form: Undeclared free variable X<br>1<br><br>"THE" is a red-herring (except insofar as it is one of the forms that triggers a compilation rather than using the simple evaluator).<br><br><blockquote type="cite">Also, two other things one again about the THE operator and one about SETF.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I would like to understand; what is the purpose of the THE operator if it does not raise<br></blockquote><blockquote type="cite">an error if the expression returns a value with a type different from the specified one?<br></blockquote><br>It's to help the compiler produce more efficient code.<br><br><blockquote type="cite">As you saw in the examples that I provided in my previous submission, we see that CMUCL<br></blockquote><blockquote type="cite">declares the variables defined by SETF as special (so dynamic), unlike CCL the variables are not dynamic (but lexical, at least they behave like that as I showed in the examples).<br></blockquote><br>No, you haven't, and they aren't.  See my earlier response to you in this thread.<br><br>rg<br><br><br><br></div></blockquote></div><br></div></div></blockquote></div><br></div></div></div></body></html>