[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Accessor names for flavor instance variables

    Date: Fri, 2 Jun 89 07:24:09 mdt
    From: intvax!drstrip@unmvax.cs.unm.edu

    Consider the following two (trivial) flavors:

    (defflavor f 
       (a b c)

    (defflavor g

    I would like the accessor functions for the instance
    variables of g to be g-a, g-b, ... Unfortunately, it seems
    that the accessor function name is based on the accessor
    name of the mixin.

There doesn't seem to be a way to get what you want automatically.  The
assumption in this design is that anyone trying to access the slots A,
B, or C is thinking of the object as an F, not as a G.  This is part of
the modularity of Flavors; G-specific interfaces should be independent
of the internal structure of its components.  Suppose you were to
redesign F, and get rid of its instance variable C.  You would then look
for all the callers of F-C and fix them, or you would define a method
F-C that computes the value.  But if you got methods defined in the
dependent flavors, too, then you'd have to fix all the callers of those,

If you really want G-A, G-B, etc., for the sake of modularity, I
suggest you do:

(defmethod (g-a g) ()
  (f-a self))

You can also define them as:

(defmethod (g-a g) ()

although in this case you should put a :REQUIRED-INSTANCE-VARIABLES
clause in G's defflavor.