[Issue 16602] Implicit string concatenation and precedence of ~

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Oct 7 15:52:12 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=16602

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
Okay. What's the bug? There has been talk of making it so that expressions are
always evaluated left-to-right, but AFAIK, it's still the case the order of
evalutation is undefined. So, ~ is behaving perfectly normally. You might as
well complain that

import std.stdio;

int foo(int i, int j)
{
    return i * j;
}

void main ( )
{
    writeln(42 + 10 * 19);
    writeln((42 + 10) * 19);
    writeln(42 + 10.foo(19));
}

prints

232
988
232

instead of
232
988
988

With the implicit string concatenation, it basically treated the strings as one
giant string, and concatenated them at compile time. ~ on the other hand would
only be compile time if it's optimized to be that way. So, they've never had
the same semantics, and it doesn't make sense for them to.

So, while I grant you that this shows that simply replacing an implicit string
concatenation with an explicit one is not necessarily the correct fix for code
that uses implicit string concatenation, I don't see how that's a bug.

--


More information about the Digitalmars-d-bugs mailing list