Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news4.ner.bbnplanet.net!cam-news-hub1.bbnplanet.com!news.mathworks.com!newsfeed.internetmci.com!mcsun!EU.net!usenet2.news.uk.psi.net!uknet!usenet1.news.uk.psi.net!uknet!uknet!newsfeed.ed.ac.uk!edcogsci!jeff
From: jeff@cogsci.ed.ac.uk (Jeff Dalton)
Subject: Re: EVAL Implementations
X-Nntp-Posting-Host: pitcairn
Message-ID: <DwwuLA.Azq@cogsci.ed.ac.uk>
Sender: cnews@cogsci.ed.ac.uk (C News Software)
Organization: HCRC, University of Edinburgh
References: <3049754333170201@arcana.naggum.no> <DwrDLA.26q@cogsci.ed.ac.uk> <500t58$rai@Mars.mcs.com>
Date: Thu, 29 Aug 1996 17:43:58 GMT
Lines: 163

In article <500t58$rai@Mars.mcs.com> munyer@MCS.COM (Robert Munyer) writes:
># Note to subscribers: this article is long, but it's 99% flame free.
>
>In article <DwrDLA.26q@cogsci.ed.ac.uk>,
>Jeff Dalton <jeff@cogsci.ed.ac.uk> wrote:

>> [...]   (N.B. special but
>> not _proclaimed_ special, an important distinction.  Special
>> proclamations make all bindings of the name special, declarations don't.)

>Based on those last two sentences I think you actually agree with
>me, not with Erik. 

I do largely agree with you that globals are special/dynamic, but
I haven't found anything in the Standard that is as clear as
CLtL2 p 70.  However, that doesn't seem to be the only issue ...

>                    Erik's latest attempt at spin control seems to
>be a claim that an implementation is allowed (under both CLtL2 and
>the ANSI standard) to PROCLAIM a symbol special, if you use SETQ
>to give it a global value.  I'm not sure if Erik thinks this also
>applies to SET and SETF and (SETF SYMBOL-VALUE), because he refuses
>to answer my questions.

If the aim is to figure out the truth about Common Lisp, rather
than to win over particular individuals, then I don't think it
matters whether Eric has changed his position or not, or whatver
the "spin control" is about.

Anyway, I haven't looked into the question of whether implementations
can proclaim the variable special.  I'd regard that as a hostile act
in most implementations, because it has a pervasive effect and there's
no way to undo it.  (And if there is a way to undo it, it will be an
implementation-specific way.)

>Remember that in the HyperSpec, the unadorned term "variable" refers
>to a binding, not to the symbol that names the binding.

I haven't looked into it in detail, but I'd be careful about
concluding that just because it's what the glossary says.  In any
case, I don't confine my own use of "variable" to that definition.

> I am not
>saying that a BINDING can be something other than lexical or constant
>or dynamic; I am saying that a NAME can have a lexical binding and
>a dynamic binding at the same time -- 

That much is clearly true; moreover, you should be able to refer
to both.  For instance:

>(let ((x 1)) 
   (declare (special x))
   (let ((x 2))
     (list (locally (declare (special x)) x)
           x)))
(1 2)

If you put in special declarations, then I think the Standard is
clear, and you can get the "special but not proclaimed special"
behaviour for global variables.  But without the declarations, what
are implementations allowed to do?  That's not so clear, and you have
to look at lots of stuff: what are conforming implementations allowed
to do in various circumstances, and so on.

>That and in fact, that dynamic
>binding can be global.  If you assign a global value to a variable
>name without proclaiming that name to be special, then you can
>still have lexical bindings on that same variable name.

Also true, even in CMUCL:

* (locally (declare (special snib)) (setq snib 10))
10

* (defun sx ()
    (locally (declare (special snib)) snib))
sx

* (let ((snib 30)) (sx))

In: let ((snib 30))
  (let ((snib 30))
    (sx))
Warning: Variable snib defined but never used.

10

>Apparently you have a CMU CL handy.  If so, could you please use
>it to evaluate the following:
>
>    (let ((data '((       defparameter (defparameter x nil))
>                  (             defvar (defvar x nil))
>                  (                set (set 'x nil))
>                  (               setf (setf x nil))
>                  ((setf symbol-value) (setf (symbol-value 'x) nil))
>                  (               setq (setq x nil)))))
>      (let ((does '()) (doesnt '()))
>        (dolist (d data)
>          (let ((desc (first d)) (form (second d)) (name (gensym)))
>            (eval (subst name 'x form))
>            (if (eval `(let ((,name t))
>                         (declare (ignorable ,name))
>                         (symbol-value ',name)))
>              (push desc does)
>              (push desc doesnt))))
>        (let ((fmt "~&These ~a: ~:[~%~4t[none]~;~:*~{~%~4t~s~}~]"))
>          (format t fmt "proclaim special" (nreverse does))
>          (format t fmt "do not" (nreverse doesnt)))))
>
>and let us know what it says?  The results should be:
>
>    These proclaim special: 
>        DEFPARAMETER
>        DEFVAR
>    These do not: 
>        SET
>        SETF
>        (SETF SYMBOL-VALUE)
>        SETQ

In CMU CL 17f, I get:

These proclaim special: 
    defparameter
    defvar
    setf
    setq
These do not: 
    set
    (setf symbol-value)

>In fact, since you've used over a dozen Common Lisps, you probably
>have several of them handy.  It would be great if you could evaluate
>the above code in each of them.

I have only a few of them handy these days.  However, both GCL-1.1
and Lucid 4.1 give the result you think they should.

>Also, any implementation which follows Erik's suggestion, and
>proclaims symbols special when not explicitly required to by the
>standard, will be unable to evaluate standard example code
>successfully.  For example, see the code in the section on EVAL:
>
>    http://www.harlequin.com/books/HyperSpec/Body/fun_eval.html

Good point.  But I'm not sure examples really count -- I'd have
to find what the Spec says about the status of examples.

>> For instance, from PROCLAIM-LEXICAL version 2:
>
>This PROCLAIM-LEXICAL document to which you refer is very interesting.
>This is the first time I've heard that anyone on the committee has
>addressed this issue directly.  PROCLAIM-LEXICAL is not mentioned
>in the standard; does that mean the issue never came to a vote?

It came to a vote; no proposals passed (or at least not any
that changed anything).  But since this message is already long,
and since I'm out of time, I'll respond to your comments on
PROCLAIM-LEXICAL in a separate message later on.  Meanwhile,
I've put some things on the Web that you may find of interest.
See http://www.aiai.ed.ac.uk/~jeff/lisp/special.html

-- jd
