Discussion Thread: DIP 1036--Formatted String Tuple Literals--Community Review Round 1

SHOO zan77137 at nifty.com
Fri Sep 11 17:37:36 UTC 2020

I'm eagerly awaiting the inclusion of this feature in the D 

Well, I have a few questions and points about this DIP.

1. Although the Abstract says "embedding arguments in the string 
itself", the DIP does not propose a syntax for embedding 
arguments in the string; the DIP proposes a syntax for splitting 
the string into tuples. I think, as I do, that what most people 
want is "embedding arguments in the string itself", so the 
essence of DIP should be the same. It might be a good idea to add 
a `f"..."` syntax that has the same meaning as `i"...".idup`.

2. It doesn't seem to work well with the {} style formatting 
employed by C#, Rust, etc. Is the following interpretation 
`String.Format("You are now {0} years old.", years - 1)` eq 
`String.Format(i"You are now ${\{0\}}(years - 1) years old.")`
This is a commonly used formatting style, so it would be nice to 
have an aid to this.

3. The object.idup in the DIP uses `import std.format`, is it 
permissible for the druntime to be dependent on Phobos?

4. Are there any reasons why backquotes (i`...`) are not allowed? 
Of the several string literals currently available, back-quoting 
string literals seem to be a good match for this DIP.

5. Although you use the name idup, idup should be used to create 
`immutable(_d_interpolated_string!Parts)`, which is an immutable 
duplication. In other words, I think you should avoid using this 
name. A good alternative is `toString`. On the other hand, this 
alternative may dilute the implications of the GC being used, but 
idup does not imply that the GC will be used in the first place.

More information about the Digitalmars-d mailing list