Stephen White <spwhite / chariot.net.au> writes:

> There's been a move towards implementing sets, bags, red-black trees and
> other specialised data structures, like Smalltalk's extensive collection.
> 
> Before we go down this path, I would like to ask whether this is a good
> idea or not...

I agree with all that you say, with one possible exception. In
general, simply adding classes to build a library is a bad idea. When
I first came across Ruby I remember thinking "hmm. Arrays and
Hashes. is that all?" But they've always been enough, and that's
powerful.

However, there's also a need for the simple classes to communicate
clearly. For example, Array#+ and Array#- are not complementary,
because #- is a 'set' operation and #+ is not. This might not be
intuitive. We have one class that is overloaded to half do something
else. Right now, that's OK, but matz was talking about adding a new
group of set operations to Array. At that point, it seems to me that
we're in danger of adding more confusion. Splitting the operations out
into a separate class would make sense. Making it an extension would
make even more sense.

I'm not particularly advocating a data-structures package. It's not
something I personally feel the need for. But we already have half of
a Set in Array. Rather than adding more methods to an already
overloaded class, I'm suggesting making the natural split.


Dave