Thread View: comp.lang.clos
2 messages
2 total messages
Started by Len Charest
Wed, 11 Nov 1992 01:02
CHANGE-CLASS on specialized metaclass
Author: Len Charest
Date: Wed, 11 Nov 1992 01:02
Date: Wed, 11 Nov 1992 01:02
45 lines
2914 bytes
2914 bytes
Now that the discussion on class-prototype has died down, I thought I'd throw
this on the fire:
STANDARD-CLASS has the interesting property that it is an instance of itself.
Suppose I want to make a specilized metaclass that also has this property:
(defclass my-class (standard-class)
((arbitrary-slot :initform (gensym))) ;to keep things interesting
)
;;; now make my-class be an instance of itself
(change-class (find-class 'my-class) (find-class 'my-class))
;;; test the result (if any...)
(slot-value (find-class 'my-class) 'arbitrary-slot)
Should this work in a correct implementation of CLOS? Should it matter whether
MY-CLASS has been finalized before the call to CHANGE-CLASS? My intuition is that
the above code should perform as expected--even in the absence of a MOP since the
functions involved (DEFCLASS, CHANGE-CLASS and SLOT-VALUE) are all part of the
'regular' CLOS programmer interface. My experience shows otherwise:
Lisp Platform Result
---- -------- ------
Lucid 4.0.2 Sparc2/SunOS 4.1.1 Throws into debugger during CHANGE-CLASS.
"Expanding stack due to overflow..."
FINALIZE-INHERITANCE not implemented.
PCL July 92 Sparc2/SunOS 4.1.1 Works as expected regardless of whether
on Lucid MY-CLASS is finalized.
Allegro 4.1 Sparc2/SunOS 4.1.1 Throws into debugger during CHANGE-CLASS.
"No methods applicable for gf: CLOS:CLASS-DIRECT-
SLOTS with args (#<CLOS:FORWARD-REFERENCED-CLASS
STANDARD-CLASS...> of classes (CLOS:FORWARD-
REFERENCED-CLASS)"
Same error occurs if attempt to finalize MY-CLASS
before CHANGE-CLASS.
MCL 2.0 Quadra 700/Sys 7 Throws into debugger during CHANGE-CLASS, but
will work if MY-CLASS has no local slots.
FINALIZE-INHERITANCE not implemented.
Comments?
..................................................
Len Charest, Jr.
JPL Artificial Intelligence Group
charest@aig.jpl.nasa.gov
Re: CHANGE-CLASS on specialized metaclass
Author: Steve Haflich
Date: Tue, 10 Nov 1992 13:01
Date: Tue, 10 Nov 1992 13:01
58 lines
3020 bytes
3020 bytes
From: charest@Aig.Jpl.Nasa.Gov (Len Charest) STANDARD-CLASS has the interesting property that it is an instance of itself. Suppose I want to make a specilized metaclass that also has this property: Should this work in a correct implementation of CLOS? Should it matter whether MY-CLASS has been finalized before the call to CHANGE-CLASS? My intuition is that the above code should perform as expected--even in the absence of a MOP since the functions involved (DEFCLASS, CHANGE-CLASS and SLOT-VALUE) are all part of the 'regular' CLOS programmer interface. My experience shows otherwise: Allegro 4.1 Sparc2/SunOS 4.1.1 Throws into debugger during CHANGE-CLASS. "No methods applicable for gf: CLOS:CLASS-DIRECT- SLOTS with args (#<CLOS:FORWARD-REFERENCED-CLASS STANDARD-CLASS...> of classes (CLOS:FORWARD- REFERENCED-CLASS)" Same error occurs if attempt to finalize MY-CLASS before CHANGE-CLASS. Comments? I agree it should work, and that it should not matter whether the class has yet been finalized. So I tried to reproduce the failure, but it worked just fine for me: Allegro CL 4.1 [SPARC; R1] (4/13/92 21:39) ... (1): (defclass my-class (standard-class) ((arbitrary-slot :initform (gensym)))) #<STANDARD-CLASS MY-CLASS @ #x8977de> (2): (change-class (find-class 'my-class) (find-class 'my-class)) #<MY-CLASS MY-CLASS @ #x8977de> (3): (find-class 'my-class) #<MY-CLASS MY-CLASS @ #x8977de> (4): (slot-value (find-class 'my-class) 'arbitrary-slot) #:G42 Allegro CL 4.1 [SPARC; R1] (4/13/92 21:39) ... (1): (defclass my-class (standard-class) ((arbitrary-slot :initform (gensym)))) #<STANDARD-CLASS MY-CLASS @ #x8977de> (2): (defclass your-class () () (:metaclass my-class)) #<MY-CLASS YOUR-CLASS @ #x899dfe> ; finalizes inheritance (3): (change-class (find-class 'my-class) (find-class 'my-class)) #<MY-CLASS MY-CLASS @ #x8977de> (4): (slot-value (find-class 'my-class) 'arbitrary-slot) #:G43 These two examples were in fresh images with no patches loaded. I can't be sure why the example didn't work for you, but the appearance of STANDARD-CLASS as a FORWARD-REFERENCED-CLASS suggests a package problem -- that you were working in some package in which the symbol COMMON-LISP:STANDARD-CLASS is not present by inheritance. I'll contact you privately from bugs@franz.com to pursue this without bothering the entire common-loops list.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads