Comment 4 for bug 539540

Revision history for this message
Pascal J. Bourguignon (pjb-informatimago) wrote :

The problem occurs also with symbols that have been declared constant variables, and with keywords:

cl-user> (defclass c () (example))

debugger invoked on a SB-INT:SIMPLE-PROGRAM-ERROR in thread #<THREAD "repl-thread" RUNNING {100A85B1C3}>: In DEFCLASS C, the slot name EXAMPLE is a constant.
; Evaluation aborted on #<sb-int:simple-program-error "~@<In DEFCLASS ~S, the slot name ~S is a constant.~@:>" {1006CD9753}>.
cl-user> (defclass d () (:example))

debugger invoked on a SB-INT:SIMPLE-PROGRAM-ERROR in thread #<THREAD "repl-thread" RUNNING {100A85B1C3}>: In DEFCLASS D, the slot name :EXAMPLE is a keyword.
; Evaluation aborted on #<sb-int:simple-program-error "~@<In DEFCLASS ~S, the slot name ~S is a keyword.~@:>" {10072AC063}>.

All the symbols are syntactically valid for use as a variable name. I can't fathom what this clause was intended to mean.

Including keywords, which are symbols that name automatically defined constant variables.

Also, the only places where slot names are used, are in slot-value where they are not evaluated, and in with-slots where they are not evaluated either, therefore they don't need to be free to be bound.

One can give a free name for the variables in with-slots:

CL-USER> (defclass e () ((:e :initarg :e)))
#<STANDARD-CLASS E>
CL-USER> (with-slots ((e :e)) (make-instance 'e :e 42) e)
42
CL-USER>

so there's no reason to constrain slot names.