On Sunday, 2 April 2017 at 10:05:57 UTC, Jonathan M Davis wrote:
On Sunday, April 02, 2017 11:47:52 Jacob Carlborg via Digitalmars-d wrote:
On 2017-04-02 11:22, Johan Engelen wrote:
> Since 2.072, implicit string concatenation is deprecated > [1]. Can someone give me a link to the discussion about this?
>
> I am wondering about the language spec changes involved.
>
> ```
>
>   "abc"
>   "def"
>
> ```
> means something different than
> ```
>
>   "abc"
>   ~ "def"
>
> ```
> right? (for example because opBinary!(“~”) can be overloaded)

It's not possible to overload operators for the built in types, or am I missing something?

No, it's definitely not possible to overload operators on built-in types.

This is not about overloading of built-in types. It is about the code text `"abc" ~ "def"` and `"abc" "def"` not being equivalent.

I am afraid the deprecation happened without careful thought behind it, because the deprecation text shows only the simplest of cases. It does not show a case where the ~ operator is used as part of a larger expression and together with operator overloading.

```
import std.stdio;

class A {
  A opBinary(string op)(string rhs) {
    writeln(rhs);
    return this;
  }
}

void main() {
  A a = new A();

  a ~ "abc" ~ "def";
        
  a ~ "abc"  "def";
}
```

- Johan

Reply via email to