Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!news.kei.com!newsfeed.internetmci.com!howland.reston.ans.net!torn!nott!cunews!dbuck
From: dbuck@superior.carleton.ca (Dave Buck)
Subject: Re: [VW} Set concatenation
X-Nntp-Posting-Host: superior.carleton.ca
Message-ID: <DIvH9K.M3J@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: Carleton University, Ottawa, Canada
References: <n1394554436.90705@smtpgwprod.ny.jpmorgan.com> <49iokq$18lt@watnews2.watson.ibm.com> <49ju6g$115q@grimsel.zurich.ibm.com> <95Nov30.094955est.205322@twist.db.toronto.edu>
Date: Thu, 30 Nov 1995 20:08:08 GMT
Lines: 55

In article <95Nov30.094955est.205322@twist.db.toronto.edu>,
Gene Golovchinsky <golovch@db.toronto.edu> wrote:
>Paul_Gover@uk.ibm.com writes:
>
>>One of the problems of implementing #, as Set union is that there's a number
>>of other useful set operations which don't have existing method selectors.
>>I prefer to implement #+, #- and #& as Set union, difference and intersection,
>>though (a) it's inefficient to use aSet := aSet + bSet. since aSet addAll: bSet.
>>saves copying all aSet, and (b) perhaps #| is better as the counterpart of #&.
>
>Yeah, but why can't you have #, when you need it too? The reason I added
>it to my image is that in some cases I was combining collections in a method
>where I didn't know (or care) what those collections were. 

My objection here is a bit subtle.  The semantics of the "," operator
are to not only combine two collections but to do so in such a way
that all the elements of the second follow the elements of the first.
This means that I'm allowed to have code that says:

longCollection := shortCollection1 , shortCollection2.
index := longCollection indexOfCollection: shortCollection2.
...

If I stream over longCollection, I'll get all the elements in the
proper order.  If I've coded a method that does this and I want to use
it polymorphicly not caring about the classes of shortCollection1 and
shortCollection2, I must be assured that both shortCollection1 and
shortCollection2 are at least indexable collections.

In an ideal world, we would have another operator, perhaps "|" which
merges two collections together to include all elements of the first
and all elements of the second but not caring about the ordering of
the elements.  Then, the indexable collections could implement it to
be the same as "," and the non-indexable collections could do
something different.  (Dictionaries are a pain here).

My point is that even if you happen to use "," to merge two
collections not caring about the order, this is not necessarily the
way everybody else uses ",". This means that Sets are only usable by
your code that uses "," and not necessarily by everyone else's because
some code may actually care about the order.

David Buck
dbuck@ccs.carleton.ca

_________________________________
| David K. Buck                 |
| dbuck@ccs.carleton.ca         |
| The Object People             |
|_______________________________|





