[Interval Problem] 2 cents
Marcel Weiher
marcel at system.de
Thu Aug 5 21:14:20 UTC 1999
> From: Hans-Martin Mosner <hm.mosner at cityweb.de>
> "Jarvis, Robert P." wrote:
>
> > Perhaps there should be an IntervalIterator class which holds
the progress
> > of an iteration across an Interval.
>
> Smalltalk had iterators since ever: They're called Streams, and a
ReadStream on
> an Interval should do just the right thing. Why not use it?
> I would especially like to have Squeak adopt the ParcPlace way of
creating
> ReadStreams on collections by sending #readStream to the
collection (and so one
> for other kinds of streams). That way, a collection could have a
specialized
> iterator that knows best how the values are generated, or it could
fall back to
> the default implementation, which just uses #size and #at: to
produce the
> values.
Next, take iteration away from the collections and turn it over to
the streams, or better yet, special iteration classes that know how
to apply a message to mixes of constant and streaming elements, or
even farther out ( see www.fscript.org ) to message patterns with
potentially nested collections etc. and expressive power similar to
APL or relational algebra.
Of course, iterators can also be usefully thought of as
generator-functions/co-routines, especially when they traverse
complex structures, which brings us back to methods as objects with
instance variables and/or co-routines + asynchronous messaging.
Marcel
More information about the Squeak-dev
mailing list
|