I'm trying to overwrite the #new
message in MyObject
. The problem is that when the text gets compiled, the local variables, disp
and oldNew
are changed to t1
and t2
respectively (I'm using Squeak 4.3) and then it can't send oldNew
to self
.
I could change their names but I'm not sure that's a good idea.
Here's a basic outline of what I have:
MyObject class methodDict at: #new put:
(Object compilerClass new
compile: 'new
| disp oldNew |
oldNew := MyObject class methodDict at: #new.
disp := Dispatcher new.
^disp xxxViewedObject: self oldNew'
in: MyObject
notifying: nil
ifFail: []) generate
I'm not 100% sure if what I'm doing is the right way to do it so other ideas are welcome.
Edit: OK so I realise now it was looking for oldNew
as a message in MyObject
, but then how do I run the compiled method?