November 29, 2010
On 11/29/10 3:38 PM, Bruno Medeiros wrote:
> On 20/11/2010 05:31, Walter Bright wrote:
>> Stewart Gordon wrote:
>>> On 12/11/2010 09:53, Andrei Alexandrescu wrote:
>>> <snip>
>>>> Well put me on board then. Walter, please don't forget to tweak the
>>>> associativity rules: var ~ " literal " ~ " literal " concatenates
>>>> literals first.
>>>
>>> You mean make ~ right-associative? I think this'll break more code
>>> than it fixes.
>>>
>>> But implementing a compiler optimisation so that var ~ ctc ~ ctc is
>>> processed as var ~ (ctc ~ ctc), _in those cases where they're
>>> equivalent_, would be sensible.
>>
>> Andrei's right. This is not about making it right-associative. It is
>> about defining in the language that:
>>
>> ((a ~ b) ~ c)
>>
>> is guaranteed to produce the same result as:
>>
>> (a ~ (b ~ c))
>>
>> Unfortunately, the language cannot make such a guarantee in the face of
>> operator overloading. But it can do it for cases where operator
>> overloading is not in play.
>
> So if you have the code:
> (a ~ b ~ c)
> and b and c are strings, but a is not a string (nor has a toString
> method, nor implicit convertion), but has a overload of the append
> operator, then b and c will not be joined in compile-time, according to
> that?

That is correct. The compiler cannot infer that user-defined ~ is in fact associative.

Andrei
November 29, 2010
On 11/11/2010 23:33, bearophile wrote:
> Now this discussion seems settled enough, so I may summarize its results a little (please fix this list if you see an error):
>
> - Andrei Alexandrescu has said this idea doesn't harm but he sees not much evidence this is a problem in C/C++.
> - Don has not said how much he likes the idea, but he has shown no technical opposition against it, and I think he may accept it.
> - Sean Kelly sees no technical problems in the idea, and I think he accepts it.
> - Steven Schveighoffer likes the idea.
> - Vladimir Panteleev likes the idea.
> - Manfred Nowak seems to like the idea.
> - Michel Fortin seems to like this idea.
> - Yao G. is opposed (but he has shown to not consider the usage of ~ to concat lines).
> - dennis luehring likes the idea.
> - klickverbot agrees with the idea.
> - Jonathan M Davis agrees with the idea.
> - Rainer Deyke has suggested a problem that may be solved or doesn't exists.
> - spir seems now more or less OK with the idea, but I am not sure.
> - so seems a OK with the idea now, but I am not sure.
> - I like this idea.
> - Brad Roberts has expressed no opinion on the topic.
>
> On average the answers seem positive. So, Walter are you willing to deprecate automatic joining of adjacent strings (and later turn it into a syntax error, the error message may suggest to add a ~)?
>
> Bye,
> bearophile

For the record, I am also okay with the idea. (mostly because it simplifies the language). But like Andrei mentioned, the importance of this is so, so minor. Fortunately the implementation effort is also very low, so let's just check there is no unintended consequences, and move on.

-- 
Bruno Medeiros - Software Engineer
1 2 3
Next ›   Last »