Hi,
In message "[ruby-talk:17844] Re: Specialised data structures - good or bad?"
on 01/07/14, Dave Thomas <Dave / PragmaticProgrammer.com> writes:
|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 think you meant my words:
>There's no reason to make "-" to remove duplication (other than
>performance), so that if someone persuade me, it might be change in
>the future. In that case, it would be useful to define new operation
>for set subtraction, maybe.
but don't take my words too seriously, especially when I said
"maybe".
I want Array intersectin(&), union(|) and subtraction (-). I don't
really care preserving order and duplication, since they don't matter
most of the cases. So if they can be preserved effeciently, it's OK
for me. And if they can't, I go Set-like behavior (using Hash).
matz.