[Pharo-project] Late binding class names
How would I hook into the system, let's say during the execution of one particular method (and whatever methods it calls recursively), and substitute one Class for another, without effecting the rest of the system? For example: myMethod "Until I return, use MyOtherClass instead of MyClass, but only in this thread" MyClass doSomething. ThirdClass doSomethingElse. ThirdClass>>doSomethingElse "This use of MyClass will also be replaced with MyOtherClass" MyClass doAnotherThing. Thanks. Sean -- View this message in context: http://forum.world.st/Late-binding-class-names-tp4575026p4575026.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Hi, I'm pretty sure it is not possibe to do that on classes without VM modifications. But you may look at WADynamicVariable from Seaside how to process such context specific globals. -- Pavel On Fri, Apr 20, 2012 at 9:27 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
How would I hook into the system, let's say during the execution of one particular method (and whatever methods it calls recursively), and substitute one Class for another, without effecting the rest of the system?
For example: myMethod   "Until I return, use MyOtherClass instead of MyClass, but only in this thread"
  MyClass doSomething.   ThirdClass doSomethingElse.
ThirdClass>>doSomethingElse   "This use of MyClass will also be replaced with MyOtherClass"
  MyClass doAnotherThing.
Thanks. Sean
-- View this message in context: http://forum.world.st/Late-binding-class-names-tp4575026p4575026.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
Pavel Krivanek-3 wrote
you may look at WADynamicVariable from Seaside how to process such context specific globals.
Thanks for the pointer... I checked it out, but Seaside is actually not doing anything with the binding there. Sean -- View this message in context: http://forum.world.st/Late-binding-class-names-tp4575026p4576741.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
On Sat, Apr 21, 2012 at 7:01 PM, Sean P. DeNigris <sean@clipperadams.com> wrote:
Pavel Krivanek-3 wrote
you may look at WADynamicVariable from Seaside how to process such context specific globals.
Thanks for the pointer... I checked it out, but Seaside is actually not doing anything with the binding there.
Sean
It does nothing with class bindings directly but it is maybe the cleanest way how to solve this kind of problem. However if you really need to switch classes, you may try to sent becameForward: during context switching in ProcessorSheduller. -- Pavel
Without knowing what you are trying to accomplish, I have to bee too critical, but have you though about doing something much simpler, using say the state patterns, and delegating this method to another "state" object. I'm particularly scared by the idea that the same object will have two different classes in two different threads. Andrew On 20 Apr 2012, at 12:27 , Sean P. DeNigris wrote:
How would I hook into the system, let's say during the execution of one particular method (and whatever methods it calls recursively), and substitute one Class for another, without effecting the rest of the system?
Andrew P. Black wrote
Without knowing what you are trying to accomplish, I have to bee too critical
Thank you for your concern, Andrew ;-) Of course, in normal programming, your point would be well-justified, but in this case, I'm implementing a test double library, so I specifically want to protect the rest of the system while a TestCase partially stubs out the functionality of a class (e.g. return a canned value for DateAndTime>>now). But it seems that this would be too difficult, so I'll probably resort to method wrappers. It's not as sandboxed, but it's much simpler. Sean -- View this message in context: http://forum.world.st/Late-binding-class-names-tp4575026p4600091.html Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
participants (3)
-
Andrew P. Black -
Pavel Krivanek -
Sean P. DeNigris