join

Keith Hodges keith_hodges at yahoo.co.uk
Sat Sep 16 00:54:50 UTC 2006


I think that join: should be more than a simple string generator. Using 
the power of Smalltalk collections you will find all sorts of wierd and 
wonderful operators that work on all manner of collections, and I think 
that join: should demonstrate some of this power.

avi's joinTokens: aStringToken does just what it say it does, it just 
creates a string. Simple and unambiguous.

My proposed join: implementation is able to do much more, but there are 
some ambiguities as to what behaviour is desired/obtained. I have no 
idea what other Smalltalks do but here are my ideas so far:

Character-useTojoin: result will be a string.
String-useToJoin: result will be a string.
$/ useToJoin: #('hello' 'my' 'world')   -> 'hello/my/world'
', ' useToJoin: #('hello' my' 'world') -> 'hello, my, world'

SequencableCollection-useToJoin result will be a SequencableCollection.
#(1 2) useToJoin: #(3 4 5) ->  #(3 1 2 4 1 2 5)

The double dispatch approach can be used.

#('hello' 'my' world') joinUsing: $/

SequenceableCollestion>>joinUsing: joiner
^ joiner useToJoin: self

----
ideas:

useToJoin:  <-> joinUsing:
join: <-> joinWith:

Keith










		
___________________________________________________________ 
NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/



More information about the Squeak-dev mailing list