From: Vladimir Zolotykh
Subject: TWO MOP QUESTIONS
Date: 
Message-ID: <3CF34600.338D1935@eurocom.od.ua>
Could you explain me what purposes the following stands for ?

(defmethod validate-superclass ((class standard-class)
				(superclass foo-metaclass))
  t)

(defmethod validate-superclass ((class foo-metaclass)
				(class standard-class))
  t)

Roughly I could understand this as 'declare that foo-metaclass and
standard-class are compatible'. I'd like to know more about this,
consequences etc, if you don't mind.

Another MOP related question. Suppose I want to add my own class
option, for example FOO-OPTION. What arrangements should be done for
that in ACL61 ? Do you have some examples of such doings ?

-- 
Vladimir Zolotykh

From: Vladimir Zolotykh
Subject: Re: TWO MOP QUESTIONS
Date: 
Message-ID: <3CF3563F.8DCA7BD8@eurocom.od.ua>
Vladimir Zolotykh wrote:
> 
> Could you explain me what purposes the following stands for ?
> 
> (defmethod validate-superclass ((class standard-class)
>                                 (superclass foo-metaclass))
>   t)
> 
> (defmethod validate-superclass ((class foo-metaclass)
>                                 (class standard-class))
>   t)
> 
> Roughly I could understand this as 'declare that foo-metaclass and
> standard-class are compatible'. I'd like to know more about this,
> consequences etc, if you don't mind.
> 
> Another MOP related question. Suppose I want to add my own class
> option, for example FOO-OPTION. What arrangements should be done for
> that in ACL61 ? Do you have some examples of such doings ?

I think I shoul detalize this latter question. The intended use of
a new option like the following:

(defclass bar (standard-object)
  ((foo-slot
    :initform nil
    :initarg :view-database
    :foo-option :something)
   ;;
  (:metaclass foo-metaclass))

I'm not sure 'the class option' was the correct name. It better 
should be called 'class slot option'.

-- 
Vladimir Zolotykh
From: Kenny Tilton
Subject: Re: TWO MOP QUESTIONS
Date: 
Message-ID: <3CF3AAF2.D28F9B5@nyc.rr.com>
Vladimir Zolotykh wrote:
> 
> Vladimir Zolotykh wrote:
> >
> > Could you explain me what purposes the following stands for ?
> >
> > (defmethod validate-superclass ((class standard-class)
> >                                 (superclass foo-metaclass))
> >   t)
> >
> > (defmethod validate-superclass ((class foo-metaclass)
> >                                 (class standard-class))
> >   t)
> >
> > Roughly I could understand this as 'declare that foo-metaclass and
> > standard-class are compatible'. I'd like to know more about this,
> > consequences etc, if you don't mind.

From: http://www.alu.org/mop/dictionary.html

Generic Function validate-superclass 

Syntax: 

validate-superclass class superclass 

Arguments: 

The class argument is a class metaobject. 

The superclass argument is a class metaobject. 

Values: 

This generic function returns true or false. 

Purpose: 

This generic function is called to determine whether the class
superclass is suitable for use as a superclass of class. 

This generic function can be be called by the implementation or user
code. It is called during class metaobject initialization and
reinitialization, before the direct superclasses are stored. If this
generic function returns false, the initialization or reinitialization
will signal an error. 

Methods: 

Primary Method validate-superclass (class class) (superclass class) 

This method returns true in three situations: 

    (i) If the superclass argument is the class named t, 
    (ii) if the class of the class argument is the same as the class of
the superclass argument or 
    (iii) if the classes one of the arguments is standard-class and the
class of the other is funcallable-standard-class. 

In all other cases, this method returns false. 

This method can be overridden. 

Notes: 

Defining a method on validate-superclass requires detailed knowledge of
of the internal protocol followed by each of the two class metaobject
classes. A method on validate-superclass which returns true for two
different class metaobject classes declares that they are compatible. 

END OF EXCERPT

> >
> > Another MOP related question. Suppose I want to add my own class
> > option, for example FOO-OPTION. What arrangements should be done for
> > that in ACL61 ? Do you have some examples of such doings ?

The following (excerpted, I'm afraid--too much to dump it all here, but
get back to me by email if you like for more details) works under ACL5,
untried under ACL6. Note btw that this approach does not work as it
might under a pure AMOP implementation; I had to do things differently
because ACL's CLOS worked a little differently.

Overall, it's kinda hairy:

First, you need a custom DSD with slots itself with initargs for any
slot options you have in mind for METAFOO classes. The DSD slot initarg
becomes the FOO (or any METAFOO class) slot option. 

Second, specialize direct-slot-definition-class on your metaclass to
detect the options and tell CLOS to use your DSD. CLOS then makes an
instance of that DSD class with initargs from the slot options coded.

Third, specialize compute-effective-slot-definition to pick up info from
the DSD as necessary to your purposes. The ESD as its name "effective"
suggests is the operative guy, tho the DSDs are available at run-time
for code to work off.

(defclass Model ()
   ((mdValue :initform nil :accessor mdvalue :initarg :mdValue :semaphor
t))
   (:metaclass ModelClass))

;------------ Slot Def Classes ---------------------------

(defclass SemaphorDSD (standard-direct-slot-definition)
  (
   (semaphor :initarg :semaphor ;; type, inter alia [:normal t]
:ephemeral :delta :drifter :stream
             :initform nil
             :accessor semaphor)
   (smWhen :initarg :smWhen :initform nil :reader smWhen)
   ))

;--------------- ESDs ------------------------------------

(defclass SemaphorESD (standard-effective-slot-definition)
  (
   (smWhen :initarg :smWhen :initform nil :reader smWhen)
   (smindex :initform nil ;; cache offset of self in (class-slots
<theClass>)
            :accessor smIndex)))


;-------------- Linking / Producing Slot Defs  -----------------
;
; The keyword parameter semaphor lets you code up a slot option "...
:semaphor t ..."
; In this case I use a custom /direct/ slot definition for what I call
semaphoric slots.
; You might not need to do that.
;
(defmethod direct-slot-definition-class ((mClass ModelClass) &rest iargs
&key semaphor)
  ;;(trc "DSD-class ModelClass> iargs" iargs)
  (if semaphor
     (find-class 'SemaphorDSD)
     (call-next-method)))
;
; Later on we take all direct slot definitions ("dsds" below; they come
from any superclass explicitly listing this slot name)
; and cook up an effective slot definition. Note that I use the
:semaphor option value specified to decide which of several
; semaphor ESD subclasses to instantiate:
;
(defmethod compute-effective-slot-definition :around ((mClass
ModelClass) slot dsds)
  (declare (ignorable slot))

  (bIf (smd (find-if (lambda (dsd) (typep dsd 'SemaphorDSD)) dsds)) ;;
bind to 'smd closest 

     (apply #'make-instance (case (semaphor smd)
                              (:ephemeral 'SMEphemeralESD)
                              (:stream 'SMStreamESD)
                              (:delta 'SMDeltaESD)
                              (otherwise 'SemaphorESD))
            :smWhen (smWhen smd) ;another custom slot option which 
            (clos::compute-effective-slot-definition-initargs mClass
dsds))

     (call-next-method))) ;; punt to standard ESD

> 
> I'm not sure 'the class option' was the correct name. It better
> should be called 'class slot option'.

I would just say slot option since "class slot" might get read as
"class-allocated slot" by some (including me <g>).

There's a lot to explain and I have been too brief (and the code above
even has some private macros like "bIf")... I just wanted to find out
where you were on all this before undertaking a major essay. If you have
a specific purpose for the slot option lemme know and I'll cook up a
standalone example you can run under ACL6.

-- 

 kenny tilton
 clinisys, inc
 ---------------------------------------------------------------
"Harvey has overcome not only time and space but any objections."
                                                        Elwood P. Dowd
From: Vladimir Zolotykh
Subject: Re: TWO MOP QUESTIONS
Date: 
Message-ID: <3CF4E068.651000B7@eurocom.od.ua>
Kenny Tilton wrote:
> 
> There's a lot to explain and I have been too brief (and the code above
> even has some private macros like "bIf")... I just wanted to find out
> where you were on all this before undertaking a major essay. If you have
> a specific purpose for the slot option lemme know and I'll cook up a
> standalone example you can run under ACL6.

This is very kindly of you. I should understand thing myself. Now I'm
far from be familiar with MOP. But as I have found (particularly after reading
your posting ) some knowledge of it is necessary. I should learn it (I mean MOP)
more that I know it for now. Then I could ask if you don't mind.

-- 
Vladimir Zolotykh
From: Kenny Tilton
Subject: Re: TWO MOP QUESTIONS
Date: 
Message-ID: <3CF51547.E21B2D39@nyc.rr.com>
Vladimir Zolotykh wrote:
> I should learn it (I mean MOP)
> more that I know it for now. Then I could ask if you don't mind.

OK. You have AMOP, yes? But I have trouble getting the big picture from
most technical doc (including AMOP), so feel free to ask questions as
part of your MOP study.

-- 

 kenny tilton
 clinisys, inc
 ---------------------------------------------------------------
"Harvey has overcome not only time and space but any objections."
                                                        Elwood P. Dowd
From: Vladimir Zolotykh
Subject: Re: TWO MOP QUESTIONS
Date: 
Message-ID: <3CF5F432.276B60D1@eurocom.od.ua>
Kenny Tilton wrote:
> 
> Vladimir Zolotykh wrote:
> > I should learn it (I mean MOP)
> > more that I know it for now. Then I could ask if you don't mind.
> 
> OK. You have AMOP, yes? But I have trouble getting the big picture from
> most technical doc (including AMOP), so feel free to ask questions as
> part of your MOP study.

Yes, I have one and I'm learning it. Like you I can't say that this reading
or understanding is easy or fast but it advances...

-- 
Vladimir Zolotykh