[Pharo-project] About announcements
Hi All! Im adding an announcer in my project, 'cause, in order to build a call graph, ill need to know about inferencer-stack movements. I was thinking, the meaning of it is to create an announcement object with it configuration for any push or pop of a stack that's similar to the runtime stack, these are a lots lots lots of objects proably with lesser optimization than BlockClosure. I was thinking in add extension methods that allow me something like self announce: [ StackPush new ] ifAnyIsInteresetedIn: StackPush. Well, i have two questions: a) Am i right? b) subscriptions variable at SubscriptionRegistry is an OrderedCollection, but is commonly accessed to get the subscriptors related with some concrete type, why not a Dictionary? is not faster than an OrderCollection in the tipical case of use? Ok, it could complicate calls like 'remove: subscriptor' but, commonly if you have the subscriptor, you have the Announcement type. Maybe the common ammount of subscriptors in a announcer is too little? Thanks!
Hi, On Jun 5, 2012, at 6:17 AM, Santiago Bragagnolo wrote:
Hi All!
Im adding an announcer in my project, 'cause, in order to build a call graph, ill need to know about inferencer-stack movements. I was thinking, the meaning of it is to create an announcement object with it configuration for any push or pop of a stack that's similar to the runtime stack, these are a lots lots lots of objects proably with lesser optimization than BlockClosure. I was thinking in add extension methods that allow me something like
self announce: [ StackPush new ] ifAnyIsInteresetedIn: StackPush.
Well, i have two questions:
a) Am i right?
No.. dispatch of events to those who are interested is already done. when you suscribe using #on: anAnnouncement do: ..., or #on: anAnnouncement send: ... to: ... you are already declaring "I'm interested on anAnnouncement", and the dispatcher delivers appropriately.
b) subscriptions variable at SubscriptionRegistry is an OrderedCollection, but is commonly accessed to get the subscriptors related with some concrete type, why not a Dictionary? is not faster than an OrderCollection in the tipical case of use? Ok, it could complicate calls like 'remove: subscriptor' but, commonly if you have the subscriptor, you have the Announcement type. Maybe the common ammount of subscriptors in a announcer is too little?
a dictionary of what? announcement->suscriptions? Esteban
Thanks!
yes yes, the dispatching is done :3, i used it at least in 3 times, and works great! the meaning of the self announce: [ StackPush new ] ifAnyIsInteresetedIn: StackPush. is something like, self announce: aBlock ifAnyIsInteresetedIn: anAnnouncementSubtype. then sub := subscriptors interestedIn: anAnnouncementSubype sub size > 0 ifTrue: [ realAnnounce := aBlock value. ] The thing is, with stack announcements i'll have at least the double of announcement instantiation than message sents. (push & pop). There are a lot of announcements in a simple expression. It could be useful to get lazy instantiation of the announcement? Yep, announcement -> subscriptions 2012/6/5 Esteban Lorenzano <estebanlm@gmail.com>
Hi,
On Jun 5, 2012, at 6:17 AM, Santiago Bragagnolo wrote:
Hi All!
Im adding an announcer in my project, 'cause, in order to build a call graph, ill need to know about inferencer-stack movements. I was thinking, the meaning of it is to create an announcement object with it configuration for any push or pop of a stack that's similar to the runtime stack, these are a lots lots lots of objects proably with lesser optimization than BlockClosure. I was thinking in add extension methods that allow me something like
self announce: [ StackPush new ] ifAnyIsInteresetedIn: StackPush.
Well, i have two questions:
a) Am i right?
No.. dispatch of events to those who are interested is already done. when you suscribe using #on: anAnnouncement do: ..., or #on: anAnnouncement send: ... to: ... you are already declaring "I'm interested on anAnnouncement", and the dispatcher delivers appropriately.
b) subscriptions variable at SubscriptionRegistry is an OrderedCollection, but is commonly accessed to get the subscriptors related with some concrete type, why not a Dictionary? is not faster than an OrderCollection in the tipical case of use? Ok, it could complicate calls like 'remove: subscriptor' but, commonly if you have the subscriptor, you have the Announcement type. Maybe the common ammount of subscriptors in a announcer is too little?
a dictionary of what? announcement->suscriptions?
Esteban
Thanks!
On 5 June 2012 06:17, Santiago Bragagnolo <santiagobragagnolo@gmail.com> wrote:
 Hi All!
 Im adding an announcer in my project, 'cause, in order to build a call graph, ill need to know about inferencer-stack movements. I was thinking, the meaning of it is to create an announcement object with it configuration for any push or pop of a stack that's similar to the runtime stack, these are a lots lots lots of objects proably with lesser optimization than BlockClosure. I was thinking in add extension methods that allow me something like
i am not sure you using right thing for your task. an announcement is an event which you broadcast to subscribers. you can announce any object as announcement.. just make sure your subscription handles it.. i.e. you can use: announcer on: BlockAnnouncement send: #doBlock: to: self if you write: BlockAnnouncement class>>handles: announcement ^ announcement class == BlockClosure Myclass>>doBlock: closure .... do anything you like... x := closure value .. etc So, you can announce like: announcer announce: [ Stack push ]
self announce: [ StackPush new ] ifAnyIsInteresetedIn: StackPush.
Well, i have two questions:
a) Am i right? b) subscriptions variable at SubscriptionRegistry is an OrderedCollection, but is commonly accessed to get the subscriptors related with some concrete type, why not a Dictionary? is not faster than an OrderCollection in the tipical case of use? Ok, it could complicate calls like 'remove: subscriptor' but, commonly if you have the subscriptor, you have the Announcement type. Maybe the common ammount of subscriptors in a announcer is too little?
Thanks!
-- Best regards, Igor Stasenko.
participants (3)
-
Esteban Lorenzano -
Igor Stasenko -
Santiago Bragagnolo