#doOnlyOnce (was Re: [BUG] '3 + 4' crashes Squeak ...)

Doug Way dway at riskmetrics.com
Fri Oct 5 00:06:43 UTC 2001


"Randal L. Schwartz" wrote:
> 
> 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"

Looking at this (and our earlier exchanges), and noticing that we're trying to find a place to hang a method which is always passed a block... now I'm thinking that the best way to handle it would be to add an instance method to BlockContext, so that the usage becomes simply:

[self halt] doOnlyOnce.

(Or, in keeping with other BlockContext methods, maybe #valueOnlyOnce.  But somehow #doOnlyOnce seems better.)

The #rearmOneShot method would become a class method for BlockContext.

> ...
> I know.  "Changesets welcome" :)

Yes.  Not that it would be hard to make this changeset, but I'd rather wait until the violent disagreement subsides first... :)

- Doug Way
  dway at riskmetrics.com




More information about the Squeak-dev mailing list