Matrix, Array2D and SequenceableCollection

Brian T Rice water at tunes.org
Mon Dec 9 16:55:49 UTC 2002


On Mon, 9 Dec 2002, Daniel Joyce wrote:

>
> > I mentioned "SubSequence" because Slate implements those and renames
> > SequenceableCollection to Sequence. What I was suggesting was that
> > SequenceableCollection includes (sub-)sliceability or linearization
> > capability, and that SubSequence be the slices themselves.
>
> And again, I ask, how are those 'slices' any different than a
> sequencable collection anyways?

Because they aren't independent slices, they're objects which acts as
independent sequences by Delegating To an existing sequence and storing
the indices between which the slice takes its elements. If I wanted
independent slices, I'd just use methods in the sequence protocol which
already exist.

> NB, any array can be stored as a linear 1D array with the appropiate
> choice of computing addresses/offsets into it.... ( nevermind storing
> binary trees as arrays w/o using pointers in C )
>
> I still DON'T see the need?

Because N-dimensional arrays are NOT Sequences, only SequenceABLE, while
the other simply is a sequence... why am I the only person who thinks
classes should have some kind of concept behind them? Sorry, that's
unfair, but I could make the same case for directed acyclic graphs: that
since there's an externally-knowable sequentialization of them, that this
qualifies me to make them a subclass of Sequence.

The alternative here is to NOT make everything with a knowable linear
ordering a Sequence, but a SequenceableCollection, and make subclasses of
Sequence for the _different_ _kinds_ of orderings that can be imposed,
which would amount to a View on the original. Of course you're going to
react badly to that suggestion, so there's really no point in my bringing
it up.

> A Collection of Collections is a 2D array, that can return a collection
> as a slice. One can slice and dice any way you want ( with the
> necessary code of course )...
>
> Why add extra complexity where none is needed?

A collection of collections is NOT a 2D array, it merely takes on some of
the properties. The only reason you could be excused for saying that does
not exist in Smalltalk: a generic, parametrizable type sytem. Also,
sometimes you want a different view of a same collection, which
copying-slices or just straight copying will not give you.

> -Daniel

You can argue that collections themselves aren't needed, that we should
only use arrays, and just stuff all the useful operators onto those: after
all, isn't a Set an Array in Smalltalk? It's all just the same thing! :)

-- 
Brian T. Rice
LOGOS Research and Development
mailto:water at tunes.org
http://tunes.org/~water/




More information about the Squeak-dev mailing list