November 12, 2010
On 11/12/10 1:06 AM, Don wrote:
> Andrei Alexandrescu wrote:
>> On 11/11/10 5:59 PM, Walter Bright wrote:
>>> Andrei Alexandrescu wrote:
>>>> Let me ask a related question: if there were a priority list of things
>>>> that Walter should be busy with, where would this feature be on that
>>>> list?
>>>
>>> For once, I agree with Bearophile. The adjacent string concatenation was
>>> a very very early feature, and the ~ completely supplants it. While I
>>> don't think it causes many problems, it's a pointless redundancy and
>>> should be removed.
>>
>> I agree too but there are many similarly good ideas (some of which
>> from himself) that are older.
>>
>> Andrei
>
> This isn't new. I remember this one being discussed about seven years ago.

Well put me on board then. Walter, please don't forget to tweak the associativity rules: var ~ " literal " ~ " literal " concatenates literals first.

Andrei
November 12, 2010
On Fri, 12 Nov 2010 04:53:23 -0500, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:

> On 11/12/10 1:06 AM, Don wrote:
>> Andrei Alexandrescu wrote:
>>> On 11/11/10 5:59 PM, Walter Bright wrote:
>>>> Andrei Alexandrescu wrote:
>>>>> Let me ask a related question: if there were a priority list of things
>>>>> that Walter should be busy with, where would this feature be on that
>>>>> list?
>>>>
>>>> For once, I agree with Bearophile. The adjacent string concatenation was
>>>> a very very early feature, and the ~ completely supplants it. While I
>>>> don't think it causes many problems, it's a pointless redundancy and
>>>> should be removed.
>>>
>>> I agree too but there are many similarly good ideas (some of which
>>> from himself) that are older.
>>>
>>> Andrei
>>
>> This isn't new. I remember this one being discussed about seven years ago.
>
> Well put me on board then. Walter, please don't forget to tweak the associativity rules: var ~ " literal " ~ " literal " concatenates literals first.

You mean *should* concatenate literals first?  I think currently it doesn't.

-Steve
November 12, 2010
On Thu, 11 Nov 2010 19:11:54 -0500, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:

> On 11/11/10 3:33 PM, 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 ~)?
>
> Let me ask a related question: if there were a priority list of things that Walter should be busy with, where would this feature be on that list?

Depends.  If it's easy to fix, bang it out.  If it's more involved, it should be low.  I don't see this as a heavy hitter.

I'd *much* rather see inout fixed.

-Steve
November 12, 2010
On 11/12/10 4:41 AM, Steven Schveighoffer wrote:
> On Fri, 12 Nov 2010 04:53:23 -0500, Andrei Alexandrescu
> <SeeWebsiteForEmail@erdani.org> wrote:
>
>> On 11/12/10 1:06 AM, Don wrote:
>>> Andrei Alexandrescu wrote:
>>>> On 11/11/10 5:59 PM, Walter Bright wrote:
>>>>> Andrei Alexandrescu wrote:
>>>>>> Let me ask a related question: if there were a priority list of
>>>>>> things
>>>>>> that Walter should be busy with, where would this feature be on that
>>>>>> list?
>>>>>
>>>>> For once, I agree with Bearophile. The adjacent string
>>>>> concatenation was
>>>>> a very very early feature, and the ~ completely supplants it. While I
>>>>> don't think it causes many problems, it's a pointless redundancy and
>>>>> should be removed.
>>>>
>>>> I agree too but there are many similarly good ideas (some of which
>>>> from himself) that are older.
>>>>
>>>> Andrei
>>>
>>> This isn't new. I remember this one being discussed about seven years
>>> ago.
>>
>> Well put me on board then. Walter, please don't forget to tweak the
>> associativity rules: var ~ " literal " ~ " literal " concatenates
>> literals first.
>
> You mean *should* concatenate literals first? I think currently it doesn't.
>
> -Steve

Yah, "shall" as they say in Standardese :o). Currently it doesn't, but you get to catenate literals by juxtaposition. For example, this expression:

s ~ "def" "ghi"

when naively changed to

s ~ "def" ~ "ghi"

will do more work than before. We must avoid that.


Andrei
November 12, 2010
Andrei:

> will do more work than before. We must avoid that.

I have added a note at the bottom of the relative bug report.

Bye,
bearophile
November 14, 2010
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.

ctc = compile-time constant

Stewart.
November 14, 2010
Stewart Gordon:

> 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.
> 
> ctc = compile-time constant
> 
> Stewart.

It may be good to add that comment here, if you want I may add it myself: http://d.puremagic.com/issues/show_bug.cgi?id=3827

Bye,
bearophile
November 14, 2010
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.
> 
	No because making ~ right-associative would cause the reverse
problem: ctc ~ ctc ~ var would not work. What is needed is for ctc ~
ctc ~ var ~ ctc ~ ctc to be processed as ((ctc ~ ctc) ~ var) ~ (ctc
~ ctc).

> ctc = compile-time constant
> 

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr



November 20, 2010
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.
November 29, 2010
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?

-- 
Bruno Medeiros - Software Engineer