Subject: Re: Scoping Question
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 10 Nov 2005 22:14:36 -0600
Newsgroups: comp.lang.lisp
Message-ID: <toednbc__fkxh-neRVn-ug@speakeasy.net>
Alan Crowe  <alan@cawtech.freeserve.co.uk> wrote:
+---------------
| It is a bug in CMUCL. The bug is that the text of the
| warning message is wrong.
...
| The specification doesn't say what is to be done with 
| (setf x 'something) at the top level [absent a decl.]...
| 
| So CMUCL gets to chose what to do with a bare, toplevel
| (setf x). It choses to proclaim it to be special, just as if
| you had preceded it by (defvar x). That's OK.
| 
| Then it gives a warning message
|     Warning:  Declaring X special.
| It could have said "Proclaiming X special" but it doesn't.
+---------------

This is made more amusing(?) by the fact that it really *is* merely
PROCLAIM'ing! From the CMUCL code for EVAL in "src/code/eval.lisp":

	     ...
	     (let ((symbol (first name)))
	       (case (info variable kind symbol)
		 (:special)
		 (:global
		  (case *top-level-auto-declare*
		    (:warn
		     (warn "Declaring ~S special." symbol))
		    ((t))
		    ((nil)
		     (return (eval:internal-eval original-exp))))
#| Here ==> |#	  (proclaim `(special ,symbol)))
		 (t
		  (return (eval:internal-eval original-exp)))))
	     ...

+---------------
| In fact, when it issues this warning message, CMUCL is
| proclaiming that the symbol is special, which will break
| closures. So the text of the warning message is wrong.
+---------------

Easily fixed...  ;-}  ;-}

    cmu> (compile-file "eval-patch.lisp")
    ...[chatter]
    #p"/usr/u/rpw3/eval-patch.x86f"
    NIL
    NIL
    cmu> (load *)

    ; Loading #p"/usr/u/rpw3/eval-patch.x86f".
    ...[drop into debugger because of locked package, select CONTINUE]...
    T
    cmu> (setf foo 37)
    Warning:  Proclaiming FOO special.

    37
    cmu> 

Is that better?  ;-}  ;-}


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607