I am interested in taking some action whenever a particular trait is used on a class. Is there a hook available?
Thanks - Sophie
On Jan 8, 2008 2:20 AM, itsme213 itsme213@hotmail.com wrote:
I am interested in taking some action whenever a particular trait is used on a class. Is there a hook available?
When is a trait "used" on a class? I think it's used whenever a method of that class is compiled. Do you want to change what the compiler is doing?
Or do you mean that you want to do something when a trait is first applied to a class?
What are you trying to accomplish? What problem are you trying to solve?
Cheers!
--Tom Phoenix
"Tom Phoenix" rootbeer@redcat.com wrote in message
Or do you mean that you want to do something when a trait is first applied to a class?
First applied. I am looking for callback / hooks similar to what Ruby has so I can do some extra processing.
Sophie
On Jan 8, 2008 1:16 PM, itsme213 itsme213@hotmail.com wrote:
"Tom Phoenix" rootbeer@redcat.com 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
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@redcat.com wrote:
On Jan 8, 2008 1:16 PM, itsme213 itsme213@hotmail.com wrote:
"Tom Phoenix" rootbeer@redcat.com 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
squeak-dev@lists.squeakfoundation.org