On Mon, Apr 27 2015, François Fayard <[email protected]> wrote:
> While I agree that * for strings is unfortunate (in fact, I don't think
>> that strinng concatenation warrants infix syntax), IMO this whole issue
>> is a red herring: all languages have quirks like this, and while
>> minimizing the number of them is a worthy goal, I wouldn't think that
>> these pose the greatest conceptual difficulty when learning Julia.
>>
>
> It did not know the * convention. It is more than unfortunate. I think it
> is a major mistake. I have seen Stefan Kaprinski talking about a ring of
> strings. It does not make any sense as a ring needs 2 operations + and *.
> If one want to go into mathematics, the set of strings looks more like a
> Z-module (a kind of vector space over the ring Z).
>
> 1) "ab" + "" = "ab"
> 2) "abc" + "def" = "abcdef"
> 3) 3 * "abc" = "abcabcabc"
>
> Well it not even true as 2 * ("ab" + "cd") = 2 * "abcd" = "abcdabcd" which
> is different from 2 * "ab" + 2 * "cd" = "ababcdcd". And there is no string
> s such that "ab" + s = "". So this all story of "math" is just wrong.
>
> Isn't there a way to fix it ?
I guess that the fix itself is trivial (simply remove the method
definition or change its name), but the associated costs may not be
(breaking code), and from the discussion in the issues it looks like the
decision has not been made yet.
Again, I do think that * and ^ for strings is not an ideal choice, but I
am still surprised how often this issue crops up and how strongly people
feel about these infix ops. Its not like one has to use them, if you
don't like * or ^ for strings, there are `string` and `repeat` and a few
other alternatives which may be more suitable in certain cases. This is
what I do at the moment.
Perhaps limiting the number of discussion threads about
*(s::AbstractString...) to 1/month would not be a bad idea :P
Best,
Tamas