Traits - does a trait trigger any callback when used on a class?

Jason Johnson jason.johnson.081 at
Sat Jan 12 22:12:34 UTC 2008

My understand was that a trait simply stuffs it's methods into the
class it is a part of, so afterwards it looks like one just
implemented the methods in the class as normal.

I'm sure there must be a way of catching entry and exit of a specific
method, though I'm not sure what you would have to do.  Possibly some
byte code injection like how Aspects work in Java.

On Jan 8, 2008 11:31 PM, Tom Phoenix <rootbeer at> wrote:
> On Jan 8, 2008 1:16 PM, itsme213 <itsme213 at> wrote:
> > "Tom Phoenix" <rootbeer at> wrote in message
> > > Or do you mean that you want to do something when a trait is first
> > > applied to a class?
> >
> > First applied.
> You could install a hook somewhere around the time the class is first
> instantiated, I suppose. But wouldn't that break some of the rules of
> traits, if there's more processing going on than what shows in the
> code of the trait itself?
> Maybe what you want is to have your trait use a class trait that would
> do some initialization?
> Good luck with it!
> --Tom Phoenix

More information about the Squeak-dev mailing list