String Interpolation
Adam D Ruppe
destructionator at gmail.com
Wed Oct 25 19:09:30 UTC 2023
On Wednesday, 25 October 2023 at 18:54:21 UTC, Andrea Fontana
wrote:
> Send me a link about these things you wrote. I missed them. I
> would like to understand what's wrong with text() syntax sugar.
http://dpldocs.info/this-week-in-d/Blog.Posted_2019_05_13.html#my-string-interpolation-proposal
(in this one, i came out in favor of an object, but on the fence
for implicit conversion to string, my position is now that the
implicit conversion to string is undesirable, and this weakens
the case of the object over the other alternatives)
https://github.com/dlang/DIPs/blob/344e00ee2d6683d61ee019d5ef6c1a0646570093/DIPs/DIP1036.md
(see also the linked review threads from that)
This isn't D specific, even Wikipedia has a page on it:
https://en.wikipedia.org/wiki/String_interpolation#Security_issues
And newer additions to languages try to do it right:
https://openjdk.org/jeps/430
Note:
> String interpolation is dangerous
>
> Unfortunately, the convenience of interpolation has a downside:
> It is easy to construct strings that will be interpreted by
> other systems but which are dangerously incorrect in those
> systems.
>
> [snip ]
>
> Can we do better?
>
> For Java, we would like to have a string composition feature
> that achieves the clarity of interpolation but achieves a safer
> result out-of-the-box, perhaps trading off a small amount of
> convenience to gain a large amount of safety.
More information about the Digitalmars-d
mailing list