On 08.06.2015 00:10, Ed Morton wrote:
> On 6/7/2015 2:02 PM, Kenny McCormack wrote:
>> In article <ml1k3h$ns1$
1...@news.m-online.net>,
>> Janis Papanagnou <
janis_pa...@hotmail.com> wrote:
>>>> In article <ml1iv2$e5o$
1...@news.m-online.net>,
>>>> Janis Papanagnou <
janis_pa...@hotmail.com> wrote:
>>>> ...
>>>>> You are talking about a "sequence of strings (stored in array) to single
>>>>> string" concatenation, right? - So why not the straightforward design to
>>>>> just concatenate the strings, and if one wants a separator to specify it
>>>>> explicitly using that optional 'sep' argument.
>>>>
>>> My question was: Why a space as default? - I always find it a bit strange
>>> if the [presumed] intent - to do a plain concatenation - would be a special
>>> case where one needs to write: array_join(f, "") while array_join(f)
>>> would silently add some separator. - Yes, that's just a detail, but since
>>> we've been asked to discuss design I'd have liked to hear the rationale for
>>> Andrew's suggestion.
>>
>> Yes, I get it now.
>> Good point - there should not be any default separator.
>>
>> But, conversely, Ed actually makes a pretty good point that the default
>> should be OFS - as it is in most other similar situations.
I considered that point as well, but...
> ... and for symmetry with split() which splits using FS by default. In case
> it's not obvious, I think symmetry with split() is key to a successful join()
> function.
...in my book, the intent of such a definition would be to have some
semantically inverse function; but that isn't the case. We could have
strings a[1]="Hello world" and a[2]="Hi there" in the array and after
join and split it would be "Hello", "world", "Hi", "there" instead.
It certainly depends on from which function set context we look at it.
Do we want (as the original posting asks for) a string concatenation?
Or do we want some flattening/unflattening function - note my question
about the implementation provided multi-dimensional arrays - where we'd
have a set of complmentary functions. Or this (space or FS) suggestion
which is somewhere in between.
I have no strong opinion against the FS variant, but, all that said, I
can't really say I'd consider it a neat design.
Janis