"Doug" == Doug Way dway@riskmetrics.com writes:
Doug> Well, you could do something like "1 doOnlyOnce: [1 halt]" to Doug> set a one-time halt in a non-Object.
Doug> #halt currently isn't in ProtoObject, so you won't be able to do Doug> a "self halt" there anyway. It kind of seems like the Doug> #doOnlyOnce:/#rearmOneShot code is related to #halt/etc and Doug> maybe belongs with that stuff in Object. Although I suppose one Doug> might have a reason to use doOnlyOnce: without doing a halt.
Doug> ProtoObject is pretty lean & mean with only 19 methods, so you Doug> don't want to add any more than is absolutely necessary there...
In that case, what you really want is a DoOnlyOnce class subclassed from Object, as a singleton, with the protocol:
DoOnlyOnce arm "in a do-it"
...
DoOnlyOnce once: [self halt] "in a method"
Then it would be useful even in proto objects, although we again run into the self-halt issue. :)
Or even just teach SystemDictionary to do that by moving the code in ProtoObject to SystemDictionary instance methods.
(Smalltalk) >> armOnce self at: #armOnce put: true (Smalltalk) >> doOnce: aBlock (self at: #armOnce) ifTrue: [self at: #armOnce put: false. aBlock value]
I know. "Changesets welcome" :)