From: Raul Jara on
> Robert(a)babelfish ~
> $
>
> There is no way the parser can disambiguate concatenation of strings
> referenced through variables and method invocations whereas a
> concatenation of string literals is easily detectable.
>
> Apart from that, I believe it is quite common in programming languages
> to allow concatenation of string literals although that feature might be
> rarely used.
>
> Kind regards
>
> robert


I think you misunderstand what I was saying. I was not asking what the
differences between the parser and the runtime are. I was asking for a
rationale. If Matz believed that strings, when placed together without
any punctuation between them should be concatenated, why didn't he make
it standard operating behavior? I can't imagine it would have been so
difficult for when the parser sees two variables in a row to treat it as
equivalent to a concatenation call on the first variable with the second
variable as an argument. If Matz didn't think that two strings should
be concatenated, why program that behavior into the parser?

It seems to me like the rationale behind not having a standard method
call (like concatenation) for two variables appearing next to each other
is that you feel there is some value in having the parser register that
syntax as an error (as opposed to having the runtime display a no method
error). But if you feel that two things next to each other should
trigger alarm bells, why not also with two strings.

["one" "two", "three"]

seems like it should really throw an error to me. If I really wanted
["onetwo", "three"] I would have written "onetwo" as a single string.

I have a really hard time coming up with cases where writing two strings
next to each other in code is preferable to writing a single longer
string. The single string uses fewer characters, even. I have a
remarkably easy time coming up with cases where someone forgets to type
a comma.
--
Posted via http://www.ruby-forum.com/.

From: Roger Pack on

> I think you misunderstand what I was saying. I was not asking what the
> differences between the parser and the runtime are. I was asking for a
> rationale. If Matz believed that strings, when placed together without
> any punctuation between them should be concatenated, why didn't he make
> it standard operating behavior? I can't imagine it would have been so
> difficult for when the parser sees two variables in a row to treat it as
> equivalent to a concatenation call on the first variable with the second
> variable as an argument. If Matz didn't think that two strings should
> be concatenated, why program that behavior into the parser?

Yeah it ends up being pretty hard to generate a parser that will do
both.
-rp
--
Posted via http://www.ruby-forum.com/.

From: Raul Jara on
Roger Pack wrote:
>
>> I think you misunderstand what I was saying. I was not asking what the
>> differences between the parser and the runtime are. I was asking for a
>> rationale. If Matz believed that strings, when placed together without
>> any punctuation between them should be concatenated, why didn't he make
>> it standard operating behavior? I can't imagine it would have been so
>> difficult for when the parser sees two variables in a row to treat it as
>> equivalent to a concatenation call on the first variable with the second
>> variable as an argument. If Matz didn't think that two strings should
>> be concatenated, why program that behavior into the parser?
>
> Yeah it ends up being pretty hard to generate a parser that will do
> both.
> -rp

I'm not sure why, though. The parser is able to turn

x + y

into

x.+(y)


What would be so hard about having the parser turn:

x y

into

x.+(y)

?

Or if you only think strings should work that way, and not numbers:

x.concat(y)

--
Posted via http://www.ruby-forum.com/.

From: Justin Collins on
Raul Jara wrote:
> Roger Pack wrote:
>
>>> I think you misunderstand what I was saying. I was not asking what the
>>> differences between the parser and the runtime are. I was asking for a
>>> rationale. If Matz believed that strings, when placed together without
>>> any punctuation between them should be concatenated, why didn't he make
>>> it standard operating behavior? I can't imagine it would have been so
>>> difficult for when the parser sees two variables in a row to treat it as
>>> equivalent to a concatenation call on the first variable with the second
>>> variable as an argument. If Matz didn't think that two strings should
>>> be concatenated, why program that behavior into the parser?
>>>
>> Yeah it ends up being pretty hard to generate a parser that will do
>> both.
>> -rp
>>
>
> I'm not sure why, though. The parser is able to turn
>
> x + y
>
> into
>
> x.+(y)
>
>
> What would be so hard about having the parser turn:
>
> x y
>
> into
>
> x.+(y)
>
> ?
>
> Or if you only think strings should work that way, and not numbers:
>
> x.concat(y)
>

Because

x y

already means

x(y)


-Justin

From: Benoit Daloze on
[Note: parts of this message were removed to make it a legal post.]

On 19 February 2010, Raul Jara wrote:

> ["one" "two", "three"]
>
> seems like it should really throw an error to me.
>

+1, it should at least raise a warning. I never saw any use case of this.
Better to probably remove it, no?

Regards,
B.D.

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Help : Error in scrubyt
Next: DXF Writer?