Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!gatech!swrinde!pipex!uknet!festival!edcogsci!jeff
From: jeff@aiai.ed.ac.uk (Jeff Dalton)
Subject: Re: Macros vs. Special opertors (was Re: SETQ is to SET as LET is to ???)
Message-ID: <D01r8v.KIK@cogsci.ed.ac.uk>
Keywords: lisp, common lisp, progv, let, unwind-protect, special form
Sender: usenet@cogsci.ed.ac.uk (C News Software)
Nntp-Posting-Host: bute-alter.aiai.ed.ac.uk
Organization: AIAI, University of Edinburgh, Scotland
References: <3avv57$j4n@sand.cis.ufl.edu> <CzqyEn.8BC@cogsci.ed.ac.uk> <3bddj9$is2@sand.cis.ufl.edu>
Date: Tue, 29 Nov 1994 20:50:55 GMT
Lines: 50

In article <3bddj9$is2@sand.cis.ufl.edu> kem@prl.ufl.edu (Kelly Murray) writes:
>In article <CzqyEn.8BC@cogsci.ed.ac.uk>, jeff@aiai.ed.ac.uk (Jeff Dalton) writes:
>|> >|> >  (defmacro progv (&rest whatever)
>|> >|> >    `(do-a-progv-somehow ',whatever))
>|> >|> >
>|> >|> >  (defun do-a-progv-somehow (args)
>|> >|> >    (whatever-magic-internal-stuff-you-want args))
>|> 
>|> There was a CL implementation that actually did this sort of
>|> thing for DEFUN.  Yet the body was still compiled.  How can that be? 
>|> Well, it's not for nothing that I used the name whatever-magic-
>|> internal-stuff-you-want.
>
>At the risk of belaboring the point, the fact that the compiler recognizes
>a function as a special-case is exactly why they are called "special forms".
>So the function is, in fact, not a function, but a special form. 

Many compilers recognize car and cdr as special cases.  Car and
cdr are not therefore special forms.  I can see your point
nonetheless, but I don't think it helps, say, someone writing a
code-walker.  (I'll use defun as the example, rather than progv.)

If you write a code-walker and try it in such an implementation, you
will expand defun (unless you treat defun as a special case) and find
a function call.  The code walker can't tell it's a special form by,
say, calling special-form-p.  It could tell only by knowing something
about defun (e.g. that it contains some body forms that shouldn't end
up inside a quoted list).

>To belabor and nit-pick even more, in the above, do-a-progv-somehow
>must be the special-form
>and not whatever-magic-internal-stuff-you-want, since do-a-progv-somehow 
>is the point where you can analyze it's argument at compile-time 
>to treat specially. 

Interestingly enough, eval is a function, as is compile.

Anyway, in the implementation in question, do-a-defun (which actually
had a different name) would call the compiler.  But for all I
know it called whatever-magic-internal-stuff-you-want, and
whatever-magic-internal-stuff-you-want called the compler.
So why is do-a-defun the special form and not
whatever-magic-internal-stuff-you-want?

Of course, a function that calls eval or compile is at least very like
a special form.  In CL we supposedly cannot define new special forms.
But we can define such functions.  So there's surely a sense of
special-form in which such functions aren't special forms.

-- jd
