MethodAnnouncements not fired on anonymous subclasses
Hi, I'm porting some of my code from P5, and it seems that MethodAnnouncements are no longer being fired on anonymous subclasses. Is this a bug or a feature? script: ~~~~~~~~~~~~~~~ normalCls := Object subclass: #Something. anonymousCls := normalCls newAnonymousSubclass. normalCls removeSelector: #meNormal. self logCr: ''. methodAdded := [ :method | self log: method; log: ' '; logCr: method method printString ]. methodModified := [ :method | self log: method; log: ' '; logCr: method method printString ]. SystemAnnouncer uniqueInstance weak when: MethodAdded send: #value: to: methodAdded; when: MethodModified send: #value: to: methodModified. anonymousCls compile: 'meAnn ^ ''add'''. anonymousCls compile: 'meAnn ^ ''change'''. normalCls compile: 'meNormal ^ ''add/change'''. SystemAnnouncer uniqueInstance unsubscribe: methodAdded. SystemAnnouncer uniqueInstance unsubscribe: methodModified. ~~~~~~~~~~~~~~~ P5 transcript: ~~~~~~~~~~~~~~~ a MethodAdded a subclass of Something>>#meAnn a MethodModified a subclass of Something>>#meAnn a MethodAdded Something>>#meNormal a MethodModified Something>>#meNormal ~~~~~~~~~~~~~~~ P6 + P7 transcript: ~~~~~~~~~~~~~~~ a MethodAdded Something>>#meNormal a MethodModified Something>>#meNormal ~~~~~~~~~~~~~~~ Thanks, Peter
Hi, Iâm not so much into the details of the issue, but I would guess this is a feature. I mean⦠is not very anonymous if it announces to the system its existence :) cheers, Esteban
On 6 Jul 2018, at 12:14, Peter Uhnák <i.uhnak@gmail.com> wrote:
Hi,
I'm porting some of my code from P5, and it seems that MethodAnnouncements are no longer being fired on anonymous subclasses.
Is this a bug or a feature?
script: ~~~~~~~~~~~~~~~ normalCls := Object subclass: #Something. anonymousCls := normalCls newAnonymousSubclass.
normalCls removeSelector: #meNormal.
self logCr: ''.
methodAdded := [ :method | self log: method; log: ' '; logCr: method method printString ]. methodModified := [ :method | self log: method; log: ' '; logCr: method method printString ].
SystemAnnouncer uniqueInstance weak when: MethodAdded send: #value: to: methodAdded; when: MethodModified send: #value: to: methodModified.
anonymousCls compile: 'meAnn ^ ''add'''. anonymousCls compile: 'meAnn ^ ''change'''.
normalCls compile: 'meNormal ^ ''add/change'''.
SystemAnnouncer uniqueInstance unsubscribe: methodAdded. SystemAnnouncer uniqueInstance unsubscribe: methodModified. ~~~~~~~~~~~~~~~
P5 transcript: ~~~~~~~~~~~~~~~ a MethodAdded a subclass of Something>>#meAnn a MethodModified a subclass of Something>>#meAnn a MethodAdded Something>>#meNormal a MethodModified Something>>#meNormal ~~~~~~~~~~~~~~~
P6 + P7 transcript: ~~~~~~~~~~~~~~~ a MethodAdded Something>>#meNormal a MethodModified Something>>#meNormal ~~~~~~~~~~~~~~~
Thanks, Peter
participants (2)
-
Esteban Lorenzano -
Peter Uhnák