digitalmars.D - Implicit concatenation of adjacent string literals
- Cecil Ward (5/5) Jun 25 2023 This is not supported in D and to concatenate string literals an
- Richard (Rikki) Andrew Cattermole (2/2) Jun 25 2023 This use to work.
- Cecil Ward (7/9) Jun 25 2023 I think so too. I recently had to rework a lot of old code
- Dave P. (10/20) Jun 25 2023 It’s easy to make this mistake:
- Cecil Ward (2/23) Jun 25 2023 An excellent point. I now fall in with the new status quo. :-)
- Mathias LANG (8/11) Jun 25 2023 And it's exactly the reasoning behind the deprecation.
This is not supported in D and to concatenate string literals an explicit ‘~’ operator is required. I’m in two minds as to whether that is a good thing, and am not settling either way. I would be interested to know what the arguments were for and against, when this design aspect was chosen.
Jun 25 2023
This use to work. It was removed a few years ago.
Jun 25 2023
On Sunday, 25 June 2023 at 21:22:49 UTC, Richard (Rikki) Andrew Cattermole wrote:This use to work. It was removed a few years ago.I think so too. I recently had to rework a lot of old code because of it, a real nuisance. Was it thought that null concat was dangerous somehow? A recipe for potential for some kind of mistakes? I presume that reinstating it would be safe enough? If there’s any reason to.
Jun 25 2023
On Sunday, 25 June 2023 at 21:30:52 UTC, Cecil Ward wrote:On Sunday, 25 June 2023 at 21:22:49 UTC, Richard (Rikki) Andrew Cattermole wrote:It’s easy to make this mistake: ```d const x = [ "foo" "bar", "baz" ]; ``` `x` only has 2 elements, when it looks like it has 3.This use to work. It was removed a few years ago.I think so too. I recently had to rework a lot of old code because of it, a real nuisance. Was it thought that null concat was dangerous somehow? A recipe for potential for some kind of mistakes? I presume that reinstating it would be safe enough? If there’s any reason to.
Jun 25 2023
On Sunday, 25 June 2023 at 21:39:13 UTC, Dave P. wrote:On Sunday, 25 June 2023 at 21:30:52 UTC, Cecil Ward wrote:An excellent point. I now fall in with the new status quo. :-)On Sunday, 25 June 2023 at 21:22:49 UTC, Richard (Rikki) Andrew Cattermole wrote:It’s easy to make this mistake: ```d const x = [ "foo" "bar", "baz" ]; ``` `x` only has 2 elements, when it looks like it has 3.This use to work. It was removed a few years ago.I think so too. I recently had to rework a lot of old code because of it, a real nuisance. Was it thought that null concat was dangerous somehow? A recipe for potential for some kind of mistakes? I presume that reinstating it would be safe enough? If there’s any reason to.
Jun 25 2023
On Sunday, 25 June 2023 at 21:47:01 UTC, Cecil Ward wrote:And it's exactly the reasoning behind the deprecation. You can find it in the changelog for 2.072, where this deprecation was introduced: https://dlang.org/changelog/2.072.0.html#deprecated_implicit_cat Note that using the concat operator gives you exactly the same behavior: Concatenation happens at compile time, there is no runtime cost / GC allocation.`x` only has 2 elements, when it looks like it has 3.An excellent point. I now fall in with the new status quo. :-)
Jun 25 2023