[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Art of MOP
- To: Jim Hurd <71501.1347@CompuServe.COM>
- Subject: Re: Art of MOP
- From: bill@cambridge.apple.com (Bill St. Clair)
- Date: Tue, 23 Jun 1992 10:24:57 -0500
- Cc: info-mcl
>Questions about MCL and MOP:
>1. Is there an available document describing MCL p3 and final implementations
>of MOP?
Enclosed is documentation for the subset of the Introspective MOP
that is part of 2.0 final. 2.0b1 has most of this. The most conspicuous
difference is that the CLASS-xxx-SLOTS functions are missing. You can
define them as follows:
(defmethod class-direct-instance-slots ((class standard-class))
(ccl::%class-local-instance-slotds class))
(defmethod class-direct-class-slots ((class standard-class))
(ccl::%class-local-shared-slotds class))
(defmethod class-instance-slots ((class standard-class))
(ccl::%class-instance-slotds class))
(defmethod class-class-slots ((class standard-class))
(ccl::%class-shared-slotds class))
MCL 2.0 does not contain a complete MOP.
>2. Does PCL run on MCL? Any tips for getting it running?
It will not run without some work. I remember someone trying to bring
it up over a year ago, but don't remember his name, nor do I remember
if he succeeded. Bringing up PCL in 2.0 final will be difficult because
MCL no longer includes built-in support for funcallable instances. We
do our generic functions a different way.
>3. Does Art of MOP represent current MOP design, or has the "standard" changed
>since that publication?
I hesitate to say too much about this. The AMOP is the only sensible
description of a MOP that I know about. I found the earlier MOP writeups
to be reasonable descriptions of the PCL implementation, but they would
have been difficult to use as a basis for a new implementation. If I were
to write a MOP for MCL today, I would base it on The Art of the MOP.
I remember seeing a writeup from Gregor about more recent work at PARC in
meta-level languages, but don't remember the details.
------------------------------------------------------------------------
MCL's Metaobject Protocol
-------------------------
Macintosh Common Lisp version 2 implements CLOS as documented in the
second edition of Common Lisp: The Language. It also contains some
informational functions that are part of the Metaobject Protocol (MOP) as
described in The Art of the Metaobject Protocol (AMOP) by Gregor Kiczales
and others (MIT Press, 1991).
Metaobject classes defined in Macintosh Common Lisp
---------------------------------------------------
Table A-1 shows the class structure of the metaobject classes defined in
Macintosh Common Lisp version 2. All the metaobject classes are instances
of standard-class except generic-function and standard-generic-function,
which are instances of funcallable-standard-class. They are not documented
in Common Lisp: The Language, but some of them are documented in The Art
of the Metaobject Protocol.
Structure of metaobject classes defined in Macintosh Common Lisp version 2
--------------------------------------------------------------------------
Class Direct superclasses
----- -------------------
standard-object t
structure-object t
metaobject standard-object
method-combination metaobject
long-method-combination method-combination
short-method-combination method-combination
standard-method-combination method-combination
method metaobject
standard-method method
standard-accessor-method standard-method
standard-writer-method standard-accessor-method
standard-reader-method standard-accessor-method
generic-function metaobject ccl::funcallable-standard-object
standard-generic-function generic-function
specializer metaobject
class specializer
ccl::compile-time-class class
structure-class class
built-in-class class
ccl::std-class class
funcallable-standard-class std-class
standard-class std-class
During compilation, if a class definition is encountered for a previously
unknown class, an instance of the class named ccl::compile-time-class is
added to the compilation environment. This instance is a stub only. The
Common Lisp generic function class-name returns its name and find-class
finds it if given the compile- time environment as its third argument, but
none of the other MOP functions returns any kind of useful information.
For example, class-precedence-list signals an error when called with an
instance of ccl::compile-time-class. This way of handling defclass at
compile time is very likely to change in future versions of Macintosh
Common Lisp.
The class named ccl::std-class is an implementation detail that may change
in future versions of Macintosh Common Lisp; hence its name is not
exported. It is included in the above table for completeness.
Unsupported metaobject classes
------------------------------
The following metaobject classes do not exist in Macintosh Common Lisp
version 2.0:
eql-specializer
forward-referenced-class
slot-definition
standard-slot-definition
standard-direct-slot-definition
standard-effective-slot-definition
Unsupported Introspective MOP functions
---------------------------------------
The following functions, which are part of the de facto introspective MOP
standard, are not supported by Macintosh Common Lisp verson 2.0:
class-default-initargs
class-direct-default-initargs
generic-function-argument-precedence-order
generic-function-declarations
generic-function-initial-methods
generic-function-lambda-list
method-lambda-list
slot-boundp-using-class
slot-definition-class
slot-definition-allocation
slot-definition-initargs
slot-definition-initform
slot-definition-initfunction
slot-definition-name
slot-definition-readers
slot-definition-type
slot-definition-writers
slot-exists-p-using-class
slot-makunbound-using-class
slot-value-using-class
MCL functions relating to the Metaobject Protocol
-------------------------------------------------
The following MOP functions are supported in Macintosh Common Lisp.
CLASS-DIRECT-SUBCLASSES [Generic function]
Syntax class-direct-subclasses (class class)
Description
The class-direct-subclasses generic function returns a list of
the direct subclasses of the given class, that is, all classes that
mention this class in their defclass forms.
Arguments class A class.
Example
-------
? (defclass foo () ())
#<STANDARD-CLASS FOO>
? (defclass bratch (foo) ())
#<STANDARD-CLASS BRATCH>
? (defclass gronk (foo) ())
#<STANDARD-CLASS GRONK>
? (class-direct-subclasses (find-class 'foo))
(#<STANDARD-CLASS GRONK> #<STANDARD-CLASS BRATCH>)
? ? (class-direct-subclasses (find-class 'standard-object))
(#<STANDARD-CLASS FOO>
#<STANDARD-CLASS INSPECTOR::ERROR-FRAME>
#<STANDARD-CLASS INSPECTOR::UNDO-VIEW-MIXIN>
#<STANDARD-CLASS INSPECTOR::BOTTOM-LINE-MIXIN>
#<STANDARD-CLASS INSPECTOR::CACHE-ENTRY>
#<STANDARD-CLASS INSPECTOR::BASICS-FIRST-MIXIN>
#<STANDARD-CLASS INSPECTOR::OBJECT-FIRST-MIXIN>
#<STANDARD-CLASS INSPECTOR::UNBOUND-MARKER>
#<STANDARD-CLASS INSPECTOR::INSPECTOR> #<STANDARD-CLASS MENUBAR>
#<STANDARD-CLASS KEY-HANDLER-MIXIN> #<STANDARD-CLASS APPLICATION>
#<STANDARD-CLASS CONDITION> #<STANDARD-CLASS SCRAP-HANDLER>
#<STANDARD-CLASS CCL::LISP-WDEF-MIXIN>
#<STANDARD-CLASS CCL::INSTANCE-INITIALIZE-MIXIN>
#<STANDARD-CLASS FUNCALLABLE-STANDARD-OBJECT>
#<STANDARD-CLASS METAOBJECT>)
The file grapher.lisp, in your MCL Examples folder, contains a good example of
the use of class-direct-subclasses.
CLASS-DIRECT-SUPERCLASSES [Generic function]
Syntax class-direct-superclasses (class class)
Description
The class-direct-superclasses generic function returns a list of the
direct superclasses of the given class, that is, all classes that are
specified in the class's defclass form.
Arguments class A class.
Example
-------
? (defclass my-io-stream (input-stream output-stream) ())
#<STANDARD-CLASS MY-IO-STREAM>
? (class-direct-superclasses *)
(#<STANDARD-CLASS INPUT-STREAM> #<STANDARD-CLASS OUTPUT-STREAM>)
class-precedence-list [Generic function]
Syntax class-precedence-list (class class)
class-precedence-list (class standard-class)
Description The class-precedence-list generic function returns the class
precedence list for the given class. This list is used by compute-
applicable-methods to determine the order of precedence of
methods specialized on the class..i.CLASS-PRECEDENCE-LIST
generic function;.i.classes:precedence list of methods specialized on
class;
Arguments class A class.
Example
? (defclass foo () ())
#<STANDARD-CLASS FOO>
? (class-precedence-list *)
(#<STANDARD-CLASS FOO> #<STANDARD-CLASS STANDARD-OBJECT> #<BUILT-IN-
CLASS T>)
? (defclass bar () ())
#<STANDARD-CLASS BAR>
? (class-precedence-list *)
(#<STANDARD-CLASS BAR> #<STANDARD-CLASS STANDARD-OBJECT> #<BUILT-IN-
CLASS T>)
? (defclass gronk (foo bar) ())
#<STANDARD-CLASS GRONK>
? (class-precedence-list *)
(#<STANDARD-CLASS GRONK> #<STANDARD-CLASS FOO> #<STANDARD-CLASS BAR>
#<STANDARD-CLASS STANDARD-OBJECT> #<BUILT-IN-CLASS T>)
CLASS-PROTOTYPE [Generic function]
Syntax class-prototype (class ccl::std-class)
class-prototype (class structure-class)
Description
The class-prototype generic function returns a prototype instance of the
given class. The contents of the instance are undefined, though it has the
same number of instance slots as an instance created with make-instance
(or a structure creator function), and all class slots are accessible.
Arguments class A class.
Example
-------
In this example, y is bound only because of :allocation :class.
? (defclass foo ()
((x :initform 1 :accessor foo-x)
(y :allocation :class
:initform 2 :accessor foo-y)))
#<STANDARD-CLASS FOO>
? (foo-y (class-prototype (find-class 'foo)))
2
CLASS-DIRECT-INSTANCE-SLOTS [Generic function]
Syntax class-direct-instance-slots (class ccl::std-class)
Description
The class-direct-instance-slots generic function returns a list of slot
definition objects describing the instance slots that were declared in the
class's defclass forms. MCL slot definitions are represented as lists. The
only supported accessor for a slot definition object is
slot-definition-name.
Arguments class A class.
Example
-------
See the example in the definition of slot-definition-name.
CLASS-DIRECT-CLASS-SLOTS [Generic function]
Syntax class-direct-class-slots (class ccl::std-class)
Description
The class-direct-class-slots generic function returns a list of slot
definition objects describing the class slots that were declared in the
class's defclass forms. MCL slot definitions are represented as lists. The
only supported accessor for a slot definition object is
slot-definition-name.
Arguments class A class.
CLASS-INSTANCE-SLOTS [Generic function]
Syntax class-instance-slots (class ccl::std-class)
Description
The class-instance-slots generic function returns a list of slot
definition objects describing all the instance slots, direct and
inherited, that were declared in the defclass for the class. MCL slot
definitions are represented as lists. The only supported accessor for a
slot definition object is slot-definition-name.
Arguments class A class.
CLASS-CLASS-SLOTS [Generic function]
Syntax class-class-slots (class ccl::std-class)
Description
The class-class-slots generic function returns a list of slot definition
objects describing all the class slots, direct and inherited, that were
declared in the defclass for the class. MCL slot definitions are
represented as lists. The only supported accessor for a slot definition
object is slot-definition-name.
Arguments class A class.
Example
-------
? (defclass foo ()
((x :accessor foo-x
:initarg :x
:initform 1)
(y :allocation :class
:accessor foo-y
:initarg :y
:initform 2)))
#<STANDARD-CLASS FOO>
? (defclass bar (foo)
((m :accessor bar-m
:initarg :m
:initform 3)
(n :allocation :class
:accessor bar-n
:initarg :n
:initform (log 4))))
#<STANDARD-CLASS BAR>
? (class-direct-instance-slots (find-class 'bar))
((M (3) (:M)))
? (class-direct-class-slots (find-class 'bar))
((N #<Anonymous Function #xDF2EA6> (:N)))
? (class-instance-slots (find-class 'bar))
((M (3) (:M)) (X (1) (:X)))
? (class-class-slots (find-class 'bar))
((N (1.3862943611198906) (:N)) (Y (2) (:Y)))
SPECIALIZER-DIRECT-METHODS [Generic function]
Syntax specializer-direct-methods (specializer class)
specializer-direct-methods (specializer list)