[Pharo-project] Issue 4036 in pharo: Please update Help> Announcements tutorial
Status: Accepted Owner: marcus.d...@gmail.com New issue 4036 by marcus.d...@gmail.com: Please update Help> Announcements tutorial http://code.google.com/p/pharo/issues/detail?id=4036 1. Not understanding how announcements work, I tried the tutorial information found under World menu > Help> Help Browser > Announcements framework 2. Under Tutorial - Step 3, there is this line: "Transcript open." That crashes, because apparently Transcript no longer understands 'open'. How do you open a Transcript from a workspace under 1.3? 3. I created a category 'Sandbox', and a class 'MyStuff'. I put the code from Tutorial -Step 3 into a method called anno1 Object subclass: #MyStuff instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Sandbox'! !MyStuff methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/14/2011 16:27'! anno1 | announcer | World announcer on: WindowOpened send: #value to: [ Transcript show: 'A new window was opened';cr].! ! I ran "MyStuff new anno1." in a workspace. Now every time I open a window, the Transcript shows. "A new window was opened." 4. I removed the MyStuff class. But every time I open a window, the Transcript still shows "A new window was opened." I return to the Announcements Tutorial, and there is NO EXPLANATION how to get rid of this 'announcement' or whatever I should call the line that appears in the Transcript. 6. So, please whoever wrote the Tutorial, update it. 7. And the more immediate question: how do I stop automatically printing 'A new window was opened' in the Transcript every time I open a window?
To remove the subscription you can evaluate: World announcer initialize. Maybe the tutorial should add (pesudo code): MyStuff>>initialize World announcer         on: WindowOpened         send: #showOnTranscript         to: self SystemAnnouncer on:#classremove send:#release: to: self. MyStuff>>release: anAnn World announcer unsuscribe: self. MyStuff>>showOnTranscript Transcript show: 'A new window was opened';cr I can update the tutorial if people agrees on the pseudo code. To open a transcript evaluate: TranscriptMorph openWindow (decoupled Transcript from Morphic, so directly ask the view to open itself) Fernando On Sun, Apr 17, 2011 at 12:41 PM, <pharo@googlecode.com> wrote:
Status: Accepted Owner: marcus.d...@gmail.com
New issue 4036 by marcus.d...@gmail.com: Please update Help> Announcements tutorial http://code.google.com/p/pharo/issues/detail?id=4036
1. Not understanding how announcements work, I tried the tutorial information found under World menu > Help> Help Browser > Announcements framework
2. Under Tutorial - Step 3, there is this line:
 "Transcript open."  That crashes, because apparently Transcript no longer understands 'open'.  How do you open a Transcript from a workspace under 1.3?
3. Â I created a category 'Sandbox', and a class 'MyStuff'. Â I put the code from Tutorial -Step 3 into a method called anno1
Object subclass: #MyStuff     instanceVariableNames: ''     classVariableNames: ''     poolDictionaries: ''     category: 'Sandbox'!
!MyStuff methodsFor: 'as yet unclassified' stamp: 'DougEdmunds 4/14/2011 16:27'! anno1     | announcer |     World announcer         on: WindowOpened         send: #value         to: [ Transcript show: 'A new window was opened';cr].! !
I ran "MyStuff new anno1." in a workspace. Now every time I open a window, the Transcript shows. Â "A new window was opened."
4. Â I removed the MyStuff class. Â But every time I open a window, the Transcript still shows "A new window was opened."
I return to the Announcements Tutorial, and there is NO EXPLANATION how to get rid of this 'announcement' or whatever I should call the line that appears in the Transcript.
6. So, please whoever wrote the Tutorial, update it.
7. And the more immediate question: how do I stop automatically printing  'A new window was opened'  in the Transcript every time I open a window?
On 18.04.2011 10:47, Fernando Olivero wrote:
To remove the subscription you can evaluate: World announcer initialize.
Maybe the tutorial should add (pesudo code):
MyStuff>>initialize World announcer on: WindowOpened send: #showOnTranscript to: self SystemAnnouncer on:#classremove send:#release: to: self.
MyStuff>>release: anAnn World announcer unsuscribe: self.
MyStuff>>showOnTranscript Transcript show: 'A new window was opened';cr
I can update the tutorial if people agrees on the pseudo code.
To open a transcript evaluate: TranscriptMorph openWindow (decoupled Transcript from Morphic, so directly ask the view to open itself)
Fernando
The old tutorial was weak mainly because it didn't tell you how to unsubscribe. Here's a few examples of that: "Unsubscribe automatically with weak announcements." World announcer weak on: WindowOpened send: #shownOnTranscript to: self. Then example in Workspace obj := self new. "Open a window, and see Transcript printing" obj := nil. "Open a window, you may see Transcript printing (depending on finalization)" "Now force finalization" Smalltalk garbageCollect. "Open a window, now see no transcript prints." "Automatically unregister after handling one announcement" initialize World announcer on: WindowOpened do: [:ann: announcer | self shownOnTranscript. announcer unsubscribe: self.] "Unregister specifically after some time" initialize World announcer on: WindowOpened send: #shownOnTranscript to: self. release World announcer unsubscribe: self. "Using same action block registered for multiple announcers, unregister specifially at a specific time" initialize handlesAnnoucements := true. actionBlock:= [:ann :announcer | handlesAnnouncement ifTrue: [self shownOnTranscript] ifFalse: [announcer unsubscribe: self]]. World announcer on: WindowOpened do: actionBlock. AnnouncerTest announcer on: TestCaseEnded do: actionBlock. release handlesAnnouncements := false.
This section should probably also explain the concept of the subscriber, ie. the thing you need to unregister for the announcement to stop being sent. For message sends (on:send:to:) it is the receiver (to: argument), for blocks (on: do:) it's the object where block is defined. #on:do:for:/#when:do:for, which lets you specify another object as subscriber for block actions, is currently not implemented. It's also a difference from the VW implementation, where when:do: uses the action block itself as subscriber, so you're much more likely to need on:do:for:. Cheers, Henry On 18.04.2011 11:13, Henrik Sperre Johansen wrote:
On 18.04.2011 10:47, Fernando Olivero wrote:
To remove the subscription you can evaluate: World announcer initialize.
Maybe the tutorial should add (pesudo code):
MyStuff>>initialize World announcer on: WindowOpened send: #showOnTranscript to: self SystemAnnouncer on:#classremove send:#release: to: self.
MyStuff>>release: anAnn World announcer unsuscribe: self.
MyStuff>>showOnTranscript Transcript show: 'A new window was opened';cr
I can update the tutorial if people agrees on the pseudo code.
To open a transcript evaluate: TranscriptMorph openWindow (decoupled Transcript from Morphic, so directly ask the view to open itself)
Fernando
The old tutorial was weak mainly because it didn't tell you how to unsubscribe.
Here's a few examples of that:
"Unsubscribe automatically with weak announcements." World announcer weak on: WindowOpened send: #shownOnTranscript to: self.
Then example in Workspace obj := self new. "Open a window, and see Transcript printing" obj := nil. "Open a window, you may see Transcript printing (depending on finalization)" "Now force finalization" Smalltalk garbageCollect. "Open a window, now see no transcript prints."
"Automatically unregister after handling one announcement" initialize World announcer on: WindowOpened do: [:ann: announcer | self shownOnTranscript. announcer unsubscribe: self.]
"Unregister specifically after some time" initialize World announcer on: WindowOpened send: #shownOnTranscript to: self.
release World announcer unsubscribe: self.
"Using same action block registered for multiple announcers, unregister specifially at a specific time" initialize handlesAnnoucements := true. actionBlock:= [:ann :announcer | handlesAnnouncement ifTrue: [self shownOnTranscript] ifFalse: [announcer unsubscribe: self]]. World announcer on: WindowOpened do: actionBlock. AnnouncerTest announcer on: TestCaseEnded do: actionBlock.
release handlesAnnouncements := false.
Great! I asked Ben and Igor to think about an announcement chapter for pharo by example vol 2. So this help will be a excellent start. Stef
This section should probably also explain the concept of the subscriber, ie. the thing you need to unregister for the announcement to stop being sent.
For message sends (on:send:to:) it is the receiver (to: argument), for blocks (on: do:) it's the object where block is defined. #on:do:for:/#when:do:for, which lets you specify another object as subscriber for block actions, is currently not implemented. It's also a difference from the VW implementation, where when:do: uses the action block itself as subscriber, so you're much more likely to need on:do:for:.
Cheers, Henry
On 18.04.2011 11:13, Henrik Sperre Johansen wrote:
On 18.04.2011 10:47, Fernando Olivero wrote:
To remove the subscription you can evaluate: World announcer initialize.
Maybe the tutorial should add (pesudo code):
MyStuff>>initialize World announcer on: WindowOpened send: #showOnTranscript to: self SystemAnnouncer on:#classremove send:#release: to: self.
MyStuff>>release: anAnn World announcer unsuscribe: self.
MyStuff>>showOnTranscript Transcript show: 'A new window was opened';cr
I can update the tutorial if people agrees on the pseudo code.
To open a transcript evaluate: TranscriptMorph openWindow (decoupled Transcript from Morphic, so directly ask the view to open itself)
Fernando
The old tutorial was weak mainly because it didn't tell you how to unsubscribe.
Here's a few examples of that:
"Unsubscribe automatically with weak announcements." World announcer weak on: WindowOpened send: #shownOnTranscript to: self.
Then example in Workspace obj := self new. "Open a window, and see Transcript printing" obj := nil. "Open a window, you may see Transcript printing (depending on finalization)" "Now force finalization" Smalltalk garbageCollect. "Open a window, now see no transcript prints."
"Automatically unregister after handling one announcement" initialize World announcer on: WindowOpened do: [:ann: announcer | self shownOnTranscript. announcer unsubscribe: self.]
"Unregister specifically after some time" initialize World announcer on: WindowOpened send: #shownOnTranscript to: self.
release World announcer unsubscribe: self.
"Using same action block registered for multiple announcers, unregister specifially at a specific time" initialize handlesAnnoucements := true. actionBlock:= [:ann :announcer | handlesAnnouncement ifTrue: [self shownOnTranscript] ifFalse: [announcer unsubscribe: self]]. World announcer on: WindowOpened do: actionBlock. AnnouncerTest announcer on: TestCaseEnded do: actionBlock.
release handlesAnnouncements := false.
participants (4)
-
Fernando Olivero -
Henrik Sperre Johansen -
pharo@googlecode.com -
Stéphane Ducasse