Re: Scheme macros

From: William D Clinger (cesuraSPAM_at_verizon.net)
Date: 03/07/04


Date: 7 Mar 2004 12:26:01 -0800

Peter Seibel <peter@javamonkey.com> wrote:
> I'm not sure it's quite fair to say Common Lisp has 700 "reserved
> words". At least, if there's anyone reading along from a C/C++/Java
> background who's not familiar with the Common Lisp symbol package,
> they shouldn't think that what you're calling "reserved words" in
> Common Lisp are the same thing.

I'm sure it was quite unfair.

It would have fairer to say that Common Lisp has 979 symbols in the
COMMON-LISP package that are restricted in the following ways:
None may be defined as a global function, macro, compiler macro,type
specifier, structure, or declaration. None may be removed from the
COMMON-LISP package, nor may their home package be altered. None may
be traced, declared or proclaimed special, defined as a method
combination type, used as the class-name argument to SETF of
FIND-CLASS, bound as a catch tag, or bound as a restart name. None
may have a SETF expander defined for them, nor may their SETF
function names be defined, undefined, or bound. 751 of these symbols
are restricted in the following ways: None of the 751 may be bound as
a local function or macro, nor may a local SETF function be bound for
them. This list of restrictions is incomplete.

My use of the phrase "reserved words" was a misleading abbreviation
of the truer statement above. Next time I'll try to remember to say
"restricted words" instead.

You gave a very nice example of the difference:

> I ran into a very specific instance of the difference today: I was
> writing some code to take apart Java classfiles. I ended up trying to
> write a class named RETURN to represent the JVM op of the same name.
> Of course I got an error because RETURN is a symbol in the CL package.
> When I had written a similar piece of software in Java I had run into
> the same problem because "return" is reserved word in Java.
>
> However the difference is that in Common Lisp the only restriction is
> on the specific name COMMON-LISP:RETURN. So I was able to cleanly
> solve my problem by making a package JVM which contained the names of
> all the classes I wanted to create to represent JVM ops. There's no
> way to do the same thing in Java because the reserved words are really
> reserved.
>
> -Peter

Will



Relevant Pages

  • Re: Scheme macros
    ... >> Common Lisp are the same thing. ... These ways don't make them reserved keyword. ... COMMON-LISP package. ... can't write your own function called "memcpy" with external linkage. ...
    (comp.lang.lisp)
  • Re: export setf expansion
    ... > So, if I define a setf function in a package, how can I export it? ... The effects of exporting are that one can refer to the symbol using the ... Regardless of whether you export the symbol, in Common Lisp the ... underlying function, setf expander, etc. is always available for use. ...
    (comp.lang.lisp)
  • Re: Extension language, using lisp to extend lisp programs.
    ... > I am writing what is essentially a kind of text-based BBS. ... > just for handling input and creating output quickly. ... > in a custom package, and make sure that package only uses a certain ... PAIP has a bit about a Scheme implementation in Common Lisp. ...
    (comp.lang.lisp)
  • Re: Overloading functions in Common Lisp
    ... > I just wonder if it is possible to overload functions in Common Lisp in ... that use your package, not all the callers of the standard EQUAL. ... > There is no need to say that this is a terrible solution, ... (defmethod equal ((x mystruct) ...
    (comp.lang.lisp)
  • Re: Regular List Expressions?
    ... but against lists instead of strings? ... Running Allegro Common Lisp in XEmacs at CSU ... The way you restrict attention to those things in the user package is with the ...
    (comp.lang.lisp)