Intervals

Randal L. Schwartz merlyn at stonehenge.com
Tue Nov 30 00:05:52 UTC 1999


>>>>> "David" == David N Smith \(IBM\) <David> writes:

David> I can't believe it will always work identically, but I've not been 
David> able to come up with a test case that fails. (I implemented a version 
David> if #includes: that is simply:

David>     includesP: aValue
David>        ^ self asArray includes: aValue

David> and used it for comparison. This IS a precise and accurate solution, 
David> though it might run out of memory at inconvenient times and otherwise 
David> misbehave when the interval has lots of elements.

You could even do this:

  includesP: aValue
    self do: [:each | each = aValue ifTrue: [^true]].
    ^false

That won't ever run out of memory.   Unless you got one of those
open-ended Interval's. :)

Hey wait, that's the definition in Collection!

Geez, didn't I say this a few months ago?

Interval|includes: is broken, and should simply be removed.
If you want an optimization for integer step classes, be sure to call
super|includes: when it's not one of those.  Otherwise, just delete
the message entirely, and let it fall from Collection.

It all comes full circle. :)

-- 
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