DIP 1027--String Interpolation--Final Review Discussion Thread
Jonathan Marler
johnnymarler at gmail.com
Tue Feb 4 01:06:29 UTC 2020
On Thursday, 30 January 2020 at 09:46:38 UTC, Mike Parker wrote:
> This is the discussion thread for the Final Review of DIP 1027,
> "String Interpolation":
>
> https://github.com/dlang/DIPs/blob/d8f2e769c3a8c711e7886ccecc93eac9795dae9c/DIPs/DIP1027.md
>
> This is the first review in which we are operating under the
> new procedure of using separate threads for discussion and
> feedback. Please see my blog post on the topic:
>
> https://dlang.org/blog/2020/01/26/dip-reviews-discussion-vs-feedback/
>
> Here in the discussion thread, you are free to discuss anything
> and everything related to the DIP. Express your support or
> opposition, debate alternatives, argue the merits... in other
> words, business as usual.
>
> However, if you have any specific feedback for how to improve
> the the proposal itself, then please post it in the feedback
> thread. The feedback thread will be the source for the review
> summary I write at the end of this review round. I will post a
> link to that thread immediately following this post. Just be
> sure to read and understand the Reviewer Guidelines before
> posting there:
>
> https://github.com/dlang/DIPs/blob/master/docs/guidelines-reviewers.md
>
> The review period will end at 11:59 PM ET on February 13, or
> when I make a post declaring it complete. Discussion in this
> thread may continue beyond that point.
>
> Please stay on topic here. I will delete posts that are
> completely off topic.
The main issue I have with this DIP is that it performs one too
many steps:
Interpolated String > Strings and Expressions > Format String
Some applications want the "Strings and Expressions" form rather
than the "Format String" form. For example, my alterative D
standard library that doesn't depend on libc
https://github.com/dragon-lang/mar doesn't use format strings at
all and I'd like to be able to use interpolated strings with it.
This means that I'm going to need to reverse the last step to
turn the resulting "Format String" back into a tuple of "Strings
and Expressions". The problem is that it's easy to create a
"Format String" from a tuple, but hard to reverse it, and by the
time the compiler has performed this roundtrip conversion,
compile times will start to suffer.
I recall Andrei Alexandrescu talking about the importance of
"composability" when referring to his memory allocation library.
It's better to have many small components that perform one job
that you can piece together, rather than a small number of big
components that perform many jobs. In the latter case, you end
up with complex interfaces and duplicate functionality scattered
throughout. Interpolated Strings will be more powerful and
flexible if we leave them in a "less processed form", where they
can easily be used for more than string formatting functions.
More information about the Digitalmars-d
mailing list