I found the explanation by Stefan Karpinski and Tim in one of the above links. Thank you Ivar, for pointing me the right direction.
*I believe Stephan can tell you more, but I think the main reason is that algebras over fields are commutative with respect to + but not necessarily for *. String concatenation is definitely not commutative. I can't remember whether this was part of the original motivation, but I also tend to think of this in the terms that string concatenation is a lot like taking the outer product, you're getting an object with the combined dimensionality of both factors. So in a language designed to appeal to people who know math, * and ^ seem more correct. --Tim * *Yes. I also did some literature review of math papers about strings and string concatenation and they all use multiplication – typically expressed as juxtaposition – to express string concatenation. None of them use + for this. And if you think about repetition, it has always struck me as unclear whether to write n*str or str*n, whereas it's perfectly clear that you need to write str^n rather than n^str.* *Another thing that could be added as an extension is having str1+str2 produce a pattern matching r"(str1|str2)", which dovetails with using fast boolean matrix multiplication for CFG parsing, as in http://www.cs.cornell.edu/home/llee/talks/bmmtalk.pdf <http://www.cs.cornell.edu/home/llee/talks/bmmtalk.pdf>. * *--Stefan* *https://groups.google.com/forum/#!searchin/julia-dev/string$20concatenation/julia-dev/4K6S7tWnuEs/bydIMsdvo-sJ <https://groups.google.com/forum/#!searchin/julia-dev/string$20concatenation/julia-dev/4K6S7tWnuEs/bydIMsdvo-sJ> * Now it makes sense why we use '*' instead of '+' and it is apt. Since Julia is a language for technical computing,it pays to use notations that are closer to the usage patterns of researchers and scientists. On Mon, Jan 20, 2014 at 8:49 PM, Ivar Nesje <[email protected]> wrote: > I did not find any FAQ entry for this topic (yet), but I think it has been > asked frequently enough now that it deserves an entry. > > Searching the archives is often usefull: > https://groups.google.com/forum/#!searchin/julia-dev/string$20concatenation > > https://github.com/JuliaLang/julia/search?q=string+concatenation&ref=cmdform&type=Issues > > The argument is (basically) that it is more mathematically correct, but I > have never really cared because * is equally good as + for me. > > kl. 13:56:26 UTC+1 mandag 20. januar 2014 skrev Sharmila Gopirajan > Sivakumar følgende: > >> Hi Ivar and Keno, >> Thank you. that worked. I'm sorry to bother you on something >> that has been documented but i just went with what i used to. May I know >> the reason behind using '*' for concatenation instead of '+' which is the >> norm? >> >> Thank you, >> >> Regards, >> Sharmila >> >> On Sunday, January 19, 2014 1:25:54 AM UTC+5:30, Ivar Nesje wrote: >>> >>> As Keno says, you should use * for string concatenation in Julia, not + >>> as in Python. >>> >>> If you really, really want, you can "fix" it by adding a new method to >>> +, but that might cause other problems, and I think that would be >>> inadvisable if you want do distribute a package with your code. >>> >>> +(a::String, b::String) = a*b >>> >>> Ivar >>> >>> kl. 20:12:56 UTC+1 lørdag 18. januar 2014 skrev Keno Fischer følgende: >>>> >>>> String concat uses `*` rather than `+` >>>> >>>> >>>> On Sat, Jan 18, 2014 at 2:04 PM, Sharmila Gopirajan Sivakumar < >>>> [email protected]> wrote: >>>> >>>>> Hi, >>>>> This is about some odd issues I'm experiencing with Julia. When I >>>>> try to add 2 strings, >>>>> >>>>> url = "http://" + domain >>>>> >>>>> (Here domain is a variable whose value is read from the csv file using >>>>> readtable.) >>>>> >>>>> I get the error "ERROR: no method +(ASCIIString, UTF8String)". But >>>>> in julia's Base/strings.jl, there are promote rules to promote asciistring >>>>> to utf8string. So why do we get this error? how do I fix it? I would be >>>>> quite willing to fix it in Julia. >>>>> >>>>> Regards, >>>>> Sharmila >>>>> >>>> >>>>
