I want a class named room. But it (CLISP) just won't let me!
(defclass room () ())
(SETF FIND-CLASS)(ROOM): #1=#<PACKAGE COMMON-LISP> is locked
[Condition of type SYSTEM::SIMPLE-PACKAGE-ERROR]
Does such a class already exist? I can find a function (room) but it
shouldn't prevent me from creating a class, right? Is there a way to
shadow the class but still have an access to the function?
--
|a\o/r|,-------------.,---------- Timofei Shatrov aka Grue ------------.
| m"a ||FC AMKAR PERM|| mail: grue at mail.ru http://grue3.tripod.com |
| k || PWNZ J00 || Kingdom of Loathing: Grue3 lvl 18 Seal Clubber |
`-----'`-------------'`-------------------------------------------[4*72]
ยทยทยทยท@mail.ru (Timofei Shatrov) writes:
> I want a class named room. But it (CLISP) just won't let me!
>
> (defclass room () ())
>
> (SETF FIND-CLASS)(ROOM): #1=#<PACKAGE COMMON-LISP> is locked
> [Condition of type SYSTEM::SIMPLE-PACKAGE-ERROR]
>
> Does such a class already exist? I can find a function (room) but it
> shouldn't prevent me from creating a class, right?
See CLHS 11.1.2.1.2. (In one sentence, this restriction exists to
prevent your attempted definition of CL:ROOM as a class to collide
with some other user's definition of CL:ROOM.
> Is there a way to shadow the class but still have an access to the
> function?
(defpackage "MY-PACKAGE"
(:use "CL")
(:shadow "ROOM"))
(in-package "MY-PACKAGE")
(defun room (&optional (arg :default))
(cl:room arg))
(define-compiler-macro room (&whole whole &optional arg)
(declare (ignore arg))
`(cl:room ,@(cdr whole)))
Christophe