[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Status of the PCL's metaclass implementation
- To: commonloops.pa@Xerox.COM
- Subject: Status of the PCL's metaclass implementation
- From: shane%blackcomb@rand.org
- Date: Mon, 07 Nov 88 19:19:53 PST
- Redistributed: commonloops.pa
1] Could someone give me a clear distinction between a
superclass and a metaclass. When would one want to use a
metaclass; and what baggage is required by metaclasses.
;;; --------------------
;;; I defined a metaclass as follows:
;;; --------------------
<fcl 38> (defclass my-standard-class1 ()
((my-slot :accessor my-slot))
(:metaclass standard-class))
NIL
<fcl 39> (setq mcs1 (find-class 'my-standard-class1))
#<Standard-Class MY-STANDARD-CLASS1 17447731>
<fcl 40> (describe mcs1)
The class #<Standard-Class MY-STANDARD-CLASS1 17447731> is an instance of
class #<Standard-Class STANDARD-CLASS 13024421>.
Name: MY-STANDARD-CLASS1
Class-Precedence-List: (MY-STANDARD-CLASS1 OBJECT T)
Local-Supers: (OBJECT)
Direct-Subclasses: NIL
#<Standard-Class MY-STANDARD-CLASS1 17447731>
;;; --------------------
;;; Then I tried to define another class such that my-slot is one of
;;; the class' slots:
;;; --------------------
<fcl 41> (defclass my-class1 () ()
(:metaclass my-standard-class1))
Error: No matching method for the generic-function #<Function
EXPAND-DEFCLASS @ #x2b4599>,
when called with arguments (#<MY-STANDARD-CLASS1 17473401> MY-CLASS1 NIL
NIL NIL).
[1] <fcl 42> :zoom
Evaluation stack:
->(ERROR "No matching method for the generic-function ~S,~@
when called with arguments ~S." #<Function EXPAND-DEFCLASS @
#x2b4599> ...)
(|(METHOD NO-APPLICABLE-METHOD (T))| #<Function EXPAND-DEFCLASS @
#x2b4599> #<MY-STANDARD-CLASS1 17473401> ...)
(NOTICE-METHODS-CHANGE-2 #<Function NO-APPLICABLE-METHOD @ #x3a2ee1>
(#<Function EXPAND-DEFCLASS @ #x2b4599> #<MY-STANDARD-CLASS1 17473401>
MY-CLASS1 ...))
(#:|.NOTICE-METHODS-CHANGE.a714c663| #<Function EXPAND-DEFCLASS @
#x2b4599> #<MY-STANDARD-CLASS1 17473401> ...)
(CACHING-DCODE-MISS #<Function EXPAND-DEFCLASS @ #x2b4599> #(NIL NIL #(2
(NAME CLASS-PRECEDENCE-LIST LOCAL-SUPERS ...) NIL ...) ...) ...)
(#:|..$RANDOM-FORMS$.a714c68a.a714c68b| #<MY-STANDARD-CLASS1 17473401>
MY-CLASS1 ...)
(DEFCLASS (DEFCLASS MY-CLASS1) (COMPILE LOAD EVAL))
... more older frames ...
[1] <fcl 43> :pop
;;; --------------------
;;; Then I defined another class:
;;; --------------------
<fcl 44> (defclass my-standard-class2 (standard-class)
((my-slot :accessor my-slot)))
NIL
<fcl 45> (setq msc2 (find-class 'my-standard-class2))
#<Standard-Class MY-STANDARD-CLASS2 17503031>
<fcl 46> (describe msc2)
The class #<Standard-Class MY-STANDARD-CLASS2 17503031> is an instance of
class #<Standard-Class STANDARD-CLASS 13024421>.
Name: MY-STANDARD-CLASS2
Class-Precedence-List: (MY-STANDARD-CLASS2 STANDARD-CLASS CLASS OBJECT T)
Local-Supers: (STANDARD-CLASS)
Direct-Subclasses: NIL
#<Standard-Class MY-STANDARD-CLASS2 17503031>
#<Standard-Class MY-STANDARD-CLASS1 17447731>
;;; --------------------
;;; And again I tried to define another class such that my-slot is one of
;;; the class' slots:
;;; --------------------
<fcl 47> (defclass my-class2 () ()
(:metaclass my-standard-class2))
Error: The class #<Standard-Class OBJECT 13024201> was specified as a
super-class of the class #<My-Standard-Class2 MY-CLASS2 17563731>;
but the meta-classes #<Standard-Class STANDARD-CLASS 13024421> and
#<Standard-Class MY-STANDARD-CLASS2 17503031> are incompatible.
[1] <fcl 48> :zoom
Evaluation stack:
->(ERROR "The class ~S was specified as a~%super-class of the class ~S;~%~
but the meta-classes ~S and~%~S are incompatible."
#<Standard-Class OBJECT 13024201> ...)
(|(METHOD CHECK-SUPER-METACLASS-COMPATIBILITY (T T))|
#<My-Standard-Class2 MY-CLASS2 17563731> #<Standard-Class OBJECT 13024201>)
(CACHING-DCODE-MISS #<Function CHECK-SUPER-METACLASS-COMPATIBILITY @
#x2c3461> #(NIL NIL NIL ...) ...)
(#:|..$RANDOM-FORMS$.a714c67e.a714c67f| #<My-Standard-Class2 MY-CLASS2
17563731> #<Standard-Class OBJECT 13024201>)
(NOTICE-METHODS-CHANGE-2 #<Function CHECK-SUPER-METACLASS-COMPATIBILITY
@ #x2c3461> (#<My-Standard-Class2 MY-CLASS2 17563731> #<Standard-Class
OBJECT 13024201>))
(#:|.NOTICE-METHODS-CHANGE.a714c663| #<My-Standard-Class2 MY-CLASS2
17563731> #<Standard-Class OBJECT 13024201>)
(|(METHOD UPDATE-CLASS (STANDARD-CLASS))| #<My-Standard-Class2 MY-CLASS2
17563731> :DIRECT-SUPERCLASSES ...)
... more older frames ...
;;; --------------------
Obviously, neither one of these attempts worked. Essentially what I
want is to be able to access the my-slot slot by:
(setf (my-slot mc1) 'hello) => HELLO
(my-slot mc1) => HELLO
2] When describing an instance, containing an unbound slot, is an
error the proper response? For instance,
(defclass c1 () ((a)))
(describe (make-instance 'c1)) =>
#<C1 xxxxxxxx> is an instance of class #<Standard-Class C1 yyyyyyyy>:
The following slots have :INSTANCE allocation:Error: The slot A is
unbound in the object #<C1 xxxxxxxx>.
Thank you,
Darrell Shane
P.S> I am running 8/28/88 (beta rev 1) AAAI PCL under Franz Allegro
CL 3.0.1 [sun3].