Re[2]: [julia-users] Re: Why is string concatenation done with * not +

2014-07-05 Thread Laszlo Hars
ot be portable.) -- Original Message -- From: "Gunnar Farnebäck" To: julia-users@googlegroups.com Sent: 7/5/2014 11:40:27 AM Subject: Re: [julia-users] Re: Why is string concatenation done with * not + Here's an example of a language that does a bit more with string operations. % pike

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-05 Thread Gunnar Farnebäck
Here's an example of a language that does a bit more with string operations. % pike Pike v7.8 release 700 running Hilfe v3.5 (Incremental Pike Frontend) > "ab" + "c"; (1) Result: "abc" > "abc" * 2; (2) Result: "abcabc" > "abcabc" - "ca"; (3) Result: "abbc" > "abcabc" / "b"; (4) Result: ({ /* 3 ele

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Laszlo Hars
Of course, 2str, 2*str and str*2 could be equivalent, as they are for other data types. For me two (copies of) str is just more natural than str1 times str2. Similarly, "add" str2 to str1 for concatenation follows the natural language better. Also, you could define str1-str2 as deleting str2 fro

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Pierre-Yves Gérardy
On Thursday, July 3, 2014 6:12:47 PM UTC+2, Stefan Karpinski wrote: > > On Thu, Jul 3, 2014 at 12:09 PM, Patrick O'Leary > wrote: > >> I do find the generalization to string exponentiation -> repetition is >> pretty beautiful. > > > This is my favorite part about the * choice. From str+str it's n

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Stefan Karpinski
On Thu, Jul 3, 2014 at 12:09 PM, Patrick O'Leary wrote: > I do find the generalization to string exponentiation -> repetition is > pretty beautiful. This is my favorite part about the * choice. From str+str it's not at all obvious whether 2str or str*2 is the right choice for string repetition.

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread yi lu
What a beautiful comment. :) On Thu, Jul 3, 2014 at 11:48 PM, Gregg Reynolds wrote: > On Thu, Jul 3, 2014 at 9:45 AM, Stefan Karpinski > wrote: > >> On Thu, Jul 3, 2014 at 9:42 AM, Ivar Nesje wrote: >> >>> We should really create a simple system where you can get those hints >>> printed in th

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Patrick O'Leary
On Thursday, July 3, 2014 9:46:12 AM UTC-5, Stefan Karpinski wrote: > > For what it's worth – and perhaps something since I'm the original > perpetrator of the str*str concatenation syntax – I've come to regret this > operator choice. > Since everyone else likes to disagree with this operator ch

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Gregg Reynolds
On Thu, Jul 3, 2014 at 9:45 AM, Stefan Karpinski wrote: > On Thu, Jul 3, 2014 at 9:42 AM, Ivar Nesje wrote: > >> We should really create a simple system where you can get those hints >> printed in the REPL, without defining more methods. > > > Yes, I think we should really pursue this avenue. >

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread John Myles White
Because Julia uses multiple dispatch, an effort is being made to ensure that all functions always mean the same thing. So the mathematical case affects the non-mathematical case. I'm checking out of this conversation now so that I can get back to my actual job. I'm confident Stefan will make a

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread yi lu
However, to be honest, I don't need much of the string functions. I only need functions that operate vectors or matrices. On Thu, Jul 3, 2014 at 11:34 PM, yi lu wrote: > When you talk about convention, you regard julia language as a programming > language like MATLAB or a more general purpose l

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread yi lu
When you talk about convention, you regard julia language as a programming language like MATLAB or a more general purpose language? Again, it is all about string concatenation, not operations on a ring. On Thu, Jul 3, 2014 at 11:13 PM, John Myles White wrote: > That is true, but the convention

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread John Myles White
That is true, but the convention exists nonetheless. Consider, for example, this branch of the combinatorics literature: http://en.wikipedia.org/wiki/Square-free_word -- John On Jul 3, 2014, at 8:09 AM, yi lu wrote: > I know abstract algebra. When talking about string concatenation, a monoid

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Stefan Karpinski
Please read my email about why * is not good for string concatenation. Then reread the same email replacing * with +. On Thu, Jul 3, 2014 at 11:09 AM, yi lu wrote: > I know abstract algebra. When talking about string concatenation, a monoid > is enough. It

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread yi lu
I know abstract algebra. When talking about string concatenation, a monoid is enough. It is true that in a ring, "+" is a commutative operator, and "*" no commutative required, however, a ring is far beyond what needed to do a string concatenation job. On Thu

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread John Myles White
This is just the standard convention in mathematics. See just about any textbook on abstract algebra for a discussion of the reasons. I think it's safe to say that `+` will never be string concatenation, so it's better to focus energy on other proposals. -- John On Jul 3, 2014, at 7:57 AM, yi

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread yi lu
@John I know that "*" means no commutative, but I see no reason "+" has a meaning of commutative. On Thu, Jul 3, 2014 at 10:53 PM, Stefan Karpinski wrote: > That's even worse. > > > On Thu, Jul 3, 2014 at 10:52 AM, yi lu > wrote: > >> I will vote for "+", although I learn mathematics. Maybe th

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Stefan Karpinski
That's even worse. On Thu, Jul 3, 2014 at 10:52 AM, yi lu wrote: > I will vote for "+", although I learn mathematics. Maybe that is why I am > not a mathematician. > > Yi > > > On Thu, Jul 3, 2014 at 10:45 PM, Stefan Karpinski > wrote: > >> On Thu, Jul 3, 2014 at 9:42 AM, Ivar Nesje wrote: >>

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread yi lu
I will vote for "+", although I learn mathematics. Maybe that is why I am not a mathematician. Yi On Thu, Jul 3, 2014 at 10:45 PM, Stefan Karpinski wrote: > On Thu, Jul 3, 2014 at 9:42 AM, Ivar Nesje wrote: > >> We should really create a simple system where you can get those hints >> printed

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Stefan Karpinski
On Thu, Jul 3, 2014 at 9:42 AM, Ivar Nesje wrote: > We should really create a simple system where you can get those hints > printed in the REPL, without defining more methods. Yes, I think we should really pursue this avenue. For what it's worth – and perhaps something since I'm the original p

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Ivar Nesje
Of course, Here is the link: https://github.com/JuliaLang/julia/issues/7512 kl. 16:32:00 UTC+2 torsdag 3. juli 2014 skrev Samuel Colvin følgende: > > Larger scope makes a lot of sense. > > Please give a link to the issue here once it's created. > > On Thursday, 3 July 2014 15:17:22 UTC+1, Tobias K

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Samuel Colvin
Larger scope makes a lot of sense. Please give a link to the issue here once it's created. On Thursday, 3 July 2014 15:17:22 UTC+1, Tobias Knopp wrote: > > Great, thanks! > > Am Donnerstag, 3. Juli 2014 16:10:08 UTC+2 schrieb Ivar Nesje: >> >> I don't think so. I'll open one. >> >> kl. 16:06:42 U

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Tobias Knopp
Great, thanks! Am Donnerstag, 3. Juli 2014 16:10:08 UTC+2 schrieb Ivar Nesje: > > I don't think so. I'll open one. > > kl. 16:06:42 UTC+2 torsdag 3. juli 2014 skrev Tobias Knopp følgende: >> >> Ivar, I absolutely agree with you. This should be handled in a larger >> scope. Do we have an issue for

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Ivar Nesje
I don't think so. I'll open one. kl. 16:06:42 UTC+2 torsdag 3. juli 2014 skrev Tobias Knopp følgende: > > Ivar, I absolutely agree with you. This should be handled in a larger > scope. Do we have an issue for this yet? > > Am Donnerstag, 3. Juli 2014 15:42:09 UTC+2 schrieb Ivar Nesje: >> >> I wou

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Tobias Knopp
Ivar, I absolutely agree with you. This should be handled in a larger scope. Do we have an issue for this yet? Am Donnerstag, 3. Juli 2014 15:42:09 UTC+2 schrieb Ivar Nesje: > > I would strongly argue against > > +(a::String, b::String) == Error("Use * for string concatenation") > > We have plent

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Ivar Nesje
I would strongly argue against +(a::String, b::String) == Error("Use * for string concatenation") We have plenty of cases where we want to give a more helpful `MethodError`. We should really create a simple system where you can get those hints printed in the REPL, without defining more methods.

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Eric Davies
I think the '+' is not as prevalent as you might think. MATLAB: ['foo' 'bar'] R: paste('foo', 'bar', sep="") Python/C++/Ruby: "foo" + "bar" Perl/PHP: "foo" . "bar" C: strcat(bufcontainingfoo, "bar") Mathematica: "foo" <> "bar" People coming from MATLAB and R (probably a very large portion of tho

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Samuel Colvin
Fundamentally I don't think it matters which mathematical operator we use for an operation that's not strictly mathematical (or at least most users don't think of as mathematical), everyone is quite happy with "x = 4" not having it's rigorous meaning of "x == 4". As long as there's a compact and

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Patrick O'Leary
On Thursday, July 3, 2014 6:59:54 AM UTC-5, Francesco Bonazzi wrote: > > On Wednesday, July 2, 2014 9:48:26 PM UTC+2, John Myles White wrote: >> >> String concatenation is not commutative. Addition is generally used for >> commutative operations. So if you're a mathematician, using addition for >

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Francesco Bonazzi
On Wednesday, July 2, 2014 9:48:26 PM UTC+2, John Myles White wrote: > > String concatenation is not commutative. Addition is generally used for > commutative operations. So if you're a mathematician, using addition for > string concatentation seems very wrong. > In Wolfram Mathematica there i

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Tobias Knopp
I am absolutely ok that string concatenation is done with * One just as to get used to it. The issue seems that some popular languages use + instead. I kind of like Samuels suggestion to give better error messages but this would essentially mean to implement + and throw an error. This would be n

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-03 Thread Stefan Schwarz
@John. Never agreed more. Perfect reasoning.

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-02 Thread John Myles White
Matrix multiplication is almost never commutative. -- John On Jul 2, 2014, at 1:16 PM, Samuel Colvin wrote: > humm, I'm tempted to say multiplication is generally (if not always) > commutative too. > > Anyway, some very interesting discussions, surely the point is that there > should be a c

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-02 Thread Samuel Colvin
humm, I'm tempted to say multiplication is generally (if not always) commutative too. Anyway, some very interesting discussions, surely the point is that there should be a concise explanation about string concatenation in the docs somewhere, something like: "you can do "hello"*"world" which is

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-02 Thread John Myles White
String concatenation is not commutative. Addition is generally used for commutative operations. So if you're a mathematician, using addition for string concatentation seems very wrong. -- John On Jul 2, 2014, at 12:45 PM, Ivar Nesje wrote: > Not everybody is convinced there is a good reason.

[julia-users] Re: Why is string concatenation done with * not +

2014-07-02 Thread Ivar Nesje
Not everybody is convinced there is a good reason. See some discussion about it in https://github.com/JuliaLang/julia/issues/1771 kl. 21:17:25 UTC+2 onsdag 2. juli 2014 skrev Samuel Colvin følgende: > > There's no method +(s1::String, s2::String) instead string concatenation > has to be done wit

Re: [julia-users] Re: Why is string concatenation done with * not +

2014-07-02 Thread Spencer Russell
It's a bit tricky to track down the relevant discussions, but this one seems like one of the most to-the-point: https://groups.google.com/forum/#!msg/julia-dev/4K6S7tWnuEs/RF6x-f59IaoJ peace, s On Wed, Jul 2, 2014 at 3:40 PM, Patrick O'Leary wrote: > On Wednesday, July 2, 2014 2:17:25 PM UTC-

[julia-users] Re: Why is string concatenation done with * not +

2014-07-02 Thread Patrick O'Leary
On Wednesday, July 2, 2014 2:17:25 PM UTC-5, Samuel Colvin wrote: > > There's no method +(s1::String, s2::String) instead string concatenation > has to be done with > > a="hello "*"world > > This is pretty unusual and unintuitive, so I'm guessing there a really > good reason for it? > There's