Re: Functions named by keywords
[glossing over details ... ]
In CL, symbols are 2-tuples: {package, name}.
CL is a lisp2. Symbols have a value and a function and ...
The Reader understands 2-tuple symbols {abc, xyz} when written with a double colon, e.g. abc::xyz.
When the compiler/interpreter sees a list, it interprets it as (<function> <val> <val> ...). This is still just a list, it is the *compiler* which interprets the *meaning* of the list as "something more than a list".
When a symbol is in the <function> position, the compiler looks up the function value of the symbol.
When a symbol is in the <val> position, the compiler looks up the value of the symbol (which can be different from the function value of the symbol).
CL has a built-in shorthand for KEYWORD::xxx symbols. The shorthand uses a single colon (not a double colon). E.G. the reader expands :xxx to be KEYWORD::xxx (the 2-tuple {“KEYWORD", “xxx"}).
CL has another built-in shorthand for xxx symbols (i.e. no package name given, no colons at all). The reader expands xxx to be <package>::xxx [where <package> is the current package, defined as the value of *package*].
DEFUN and DEFMETHOD take a bunch of args, the first one being a symbol (i.e. a 2-tuple symbol).
Usually, one uses the form (DEFUN xxx ...). The reader expands this to mean (DEFUN <package>::xxx ...).
But, furthermore... E.G. I have added methods for classes by using:
(defmethod abc::xyz (...) ...) [where abc is the package that the class symbol is in, and xyz is some new function/method that I want to add to the class]
So, it would not surprise me that keywords can be used in DEFUN and DEFMETHOD. (In fact, DEFUN and DEFMETHOD are just 2-tuple symbols, too, but I don't want to go there :-).
Many non-CL Lisps are lisp1's, and use 1-tuple symbols (name only). Many other languages don't have the concept of symbols and use various syntactic kludges to attack the packge problem.
pt
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html