Implicit conversion of concatenation result to immutable
Per Nordlöw
per.nordlow at gmail.com
Thu Apr 1 22:17:08 UTC 2021
On Thursday, 1 April 2021 at 21:59:21 UTC, H. S. Teoh wrote:
> Just use .idup on the result.
That creates an unnecessary GC allocation in cases such
```d
string x;
const(char)[] y;
throw new Exception(x ~ y.idup)
```
which, imho, is very much worth considering avoiding the need for.
The implicit conversion could be special cased in the compiler to
be allowed only on a `CatExp` being an r-value, naturally
non-aliased.
As mentioned above this is analogous with conversion rules of new
expressions.
More information about the Digitalmars-d
mailing list