[Q] mixin pattern - how to use an alternate Behavior for Class

Rob Withers rwithers12 at mediaone.net
Mon Jan 28 12:40:11 UTC 2002


Hi Stef,

Actually, mine is much more special case than MixinClass.  It is called 
RedirectorMixin.  I intercept method lookup, in the vm, and redirect into 
the image so I can manipulate this lookup.  I am writing the Mixin in order 
to have class-based methods to dispatch through.  The reason for creating a 
special class was to allow this class to be manipulated in the browsing tools.

I'm quite sure there are other aspects of mixin that I am not addressing in 
my special case.  ;)    I look forward to hearing about them and from 
Nathanael.

Cheers,
Rob

At 02:06 AM 1/28/2002, you wrote:
>Hi Rob
>
>we are working on mixin (not like yours in fact) mixin are not only about
>compiling in a different scope ;)
>
>I think that we have kind of similar questions ;)
>Nathanael will certainly get ion contact with you.
>
>Stef
>
> > I am trying to create a mixin class which compiles it's methods 'in' the
> > scope of a different class.  One way to go would be to have class side
> > #compile methods which switches the class used to compile the method in.  I
> > would need a classVariable to hold this contextClass and off we go.
> >
> > An alternative mechanism that I am exploring, is to have a different
> > subclass of ClassDescription (or Class), which has an instance method
> > contextClass, and the compile methods are overridden on the instance side
> > of this MixinClass.
> >
> > So I have a MixinClass, which has roughly identical protocol to Class and I
> > am now adding a set of methods to ClassBuilder to create this class
> > (instance of MixinClass).  The problem is that I am not sure what to set
> > the superclass of the Metaclass instance too.  (1b) If I leave it alone, my
> > class is an instance of Class.  (1a) If I force it to MixinClass, then my
> > class is an instance of MixinClass and my instance methods are ok, but the
> > class-side confuses me a little - I have broken the metaclass superclass
> > inheritence.  Do I really need to have a MixinProtoObject to root
> > everything with MixinClass class as the first metaclass superclass, or can
> > I stitch myself into a different point in the hierarchy and still have my
> > class be an instance of MixinClass, rather than Class, but maintain the
> > correct metaclass inheritence?  I believe it all relies on the
> > implementation of 'meta new', especially with Interpreter>>formatOfClass:
> > aClass, where aClass is a metaclass instance.
> >
> > Cheers,
> > Rob
> >
> >
> >
> > 1a) meta _ Metaclass new.
> > meta
> > superclass: MixinClass
> > methodDictionary: MethodDictionary new
> > format: MixinClass format.
> > newClass _ meta new.
> >
> >
> > 1b) meta _ Metaclass new.
> > meta
> > superclass: newSuper class
> > methodDictionary: MethodDictionary new
> > format: MixinClass format.
> > newClass _ meta new.
> >
> >
> >
> > 2) newClass
> > superclass: newSuper
> > methodDictionary: MethodDictionary new
> > format: newFormat;
> > contextClass: aContextClass;
> > setInstVarNames: instVars;
> > organization: nil.
> > ^newClass
> >
> >




More information about the Squeak-dev mailing list