[squeak-dev] The Inbox: Collections-ct.827.mcz

Chris Muller asqueaker at gmail.com
Sat Jun 1 18:55:48 UTC 2019


> > On 31/05/19 6:04 PM, Christoph Thiede wrote:
> >> #(1 2 3) asSet joinSeparatedBy: '-
> > What is the expected answer for joining set members by '-'?
> >
> > If I have a set with members #daa, #dee, #dum, the output could be any of 'daa-dee-dum', 'daa-dum-dee', 'dum-dee-daa', ....
> >
> > Squeak 5.2alpha shows the order as 'dee-daa-dum'
>
> I think that's why #joinSeparatedBy: was initially only on sequenceable collection.

It can be good to start out behaviors in the most-restrictive place
possible, because it's easier to relax something later if necessary,
than to tighten it.

> I mean, it is also unclear what joinSeparatedBy: would mean on a Bag with multiple occurrences, or a Matrix, or a Bitset…

The method only uses #do:, which is required of all Collections, so
it's not any less clear than #do: on those objects.

> On the other hand, you can always do things like
>         myCollection asArray joinSeparatedBy: 'fnord'
> or
>         myBag cumulativeCounts joinSeparatedBy: ', '
> or
>         (mySet sorted: [:a :b | a >= b])  joinSeparatedBy: ' is more than '
>
> and be explicit on what you expect to establish the sequence.

It sounds like Christoph has a use case to join objects without caring
about the order.  I don't find that surprising, the method is a very
abstract behavior, with many different uses across different domains.
The existing implementation works in the context of any Collection,
and those things you mentioned above can all still be done.

Regards,
  Chris


More information about the Squeak-dev mailing list