Understanding ClassModifiedClassDefinition announcement
Hi, I did this small experiment class := Object subclass: #SomeClass. SystemAnnouncer uniqueInstance when: ClassModifiedClassDefinition do: [ :ann | Transcript cr; crShow: class == ann oldClassDefinition; crShow: class == ann newClassDefinition ]. Transcript crShow: class == (Object subclass: #SomeClass instanceVariableNames: 'one' ). and got true false true I could understand getting true, false, false, and so having a new object for a new class, or getting false, true, true e.i getting the same object and oldClassDefinition would be a mock that can be used for consistency. How is all this thing working? Because Iâm tracking classes and I need to switch to another object if itâs changed and evaluate some methods. But I canât evaluate them on newClassDefinition because itâs a different object, and I canât do it on oldClassDefinition because itâs old⦠I would be very grateful. Uko
during Object subclass: #SomeClass instanceVariableNames: 'one' the announcement is send and your class var points to the old class definition. after Object subclass: #SomeClass instanceVariableNames: 'one' is done, your class var points to the new class definition. And yes, I think it is the wrong behavior. The announcement is not useful if it announces this change before the class has changed. There is a bug report for this: 13020 <https://pharo.fogbugz.com/default.asp?13020> ClassModifiedClassDefinition should be announced AFTER the class is changed 2014-07-21 20:09 GMT+02:00 Yuriy Tymchuk <yuriy.tymchuk@me.com>:
Hi, I did this small experiment
class := Object subclass: #SomeClass. SystemAnnouncer uniqueInstance when: ClassModifiedClassDefinition do: [ :ann | Transcript cr; crShow: class == ann oldClassDefinition; crShow: class == ann newClassDefinition ]. Transcript crShow: class == (Object subclass: #SomeClass instanceVariableNames: 'one' ).
and got
true false true
I could understand getting true, false, false, and so having a new object for a new class, or getting false, true, true e.i getting the same object and oldClassDefinition would be a mock that can be used for consistency.
How is all this thing working? Because Iâm tracking classes and I need to switch to another object if itâs changed and evaluate some methods. But I canât evaluate them on newClassDefinition because itâs a different object, and I canât do it on oldClassDefinition because itâs oldâ¦
I would be very grateful. Uko
Oh, thanks. This was useful! On 21 Jul 2014, at 21:02, Nicolai Hess <nicolaihess@web.de> wrote:
during Object subclass: #SomeClass instanceVariableNames: 'one' the announcement is send and your class var points to the old class definition. after Object subclass: #SomeClass instanceVariableNames: 'one' is done, your class var points to the new class definition. And yes, I think it is the wrong behavior. The announcement is not useful if it announces this change before the class has changed.
There is a bug report for this:
13020 ClassModifiedClassDefinition should be announced AFTER the class is changed
2014-07-21 20:09 GMT+02:00 Yuriy Tymchuk <yuriy.tymchuk@me.com>: Hi, I did this small experiment
class := Object subclass: #SomeClass. SystemAnnouncer uniqueInstance when: ClassModifiedClassDefinition do: [ :ann | Transcript cr; crShow: class == ann oldClassDefinition; crShow: class == ann newClassDefinition ]. Transcript crShow: class == (Object subclass: #SomeClass instanceVariableNames: 'one' ).
and got
true false true
I could understand getting true, false, false, and so having a new object for a new class, or getting false, true, true e.i getting the same object and oldClassDefinition would be a mock that can be used for consistency.
How is all this thing working? Because Iâm tracking classes and I need to switch to another object if itâs changed and evaluate some methods. But I canât evaluate them on newClassDefinition because itâs a different object, and I canât do it on oldClassDefinition because itâs oldâ¦
I would be very grateful. Uko
participants (2)
-
Nicolai Hess -
Yuriy Tymchuk