[BUG] '3 + 4' crashes Squeak ...

Randal L. Schwartz merlyn at stonehenge.com
Thu Oct 4 23:25:32 UTC 2001


>>>>> "Doug" == Doug Way <dway at 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" :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!




More information about the Squeak-dev mailing list