String Interpolation Compare - DIP1027 and YAIDIP

Walter Bright newshound2 at digitalmars.com
Sat Oct 21 06:44:22 UTC 2023


On 10/20/2023 9:42 PM, Steven Schveighoffer wrote:
> Yes and no. It's very clearly geared towards writef (or else we would have some 
> other default other than %s), even though it doesn't require hooking with 
> writef. But in effect, writef and format (and other functions like it, such as 
> loggers) are the only functions it works with "out of the box".

That's no surprise, since Phobos has adopted that style for more than just 
writef, such as std.format.format(). There's no reason to invent a different one 
for loggers.

https://dlang.org/phobos/std_format.html#format

Besides, I had modified DIP1027 to enable any format string between { } 
specifically to accommodate your database use case.


> There are many 
> other functions that use the same style of "blueprint + data" calls which will 
> utterly fail, and can't be made to work with DIP1027.

Example, please. I already showed how to do Adam's example of things that 
wouldn't work with DIP1027.


> BTW, I count a failure as having to specify the correct substitution as the 
> user. That is the domain of the function or the type system.

I don't know what that means.

 > Nobody, and I really truly mean, NOBODY, is clamoring for better ways to call 
printf (specifically printf).

Which is too bad. printf has many advantages:

1. small
2. only the call is emitted to the object file
3. several decades spent optimizing it
4. ubiquitous
5. very well documented
6. very battle-tested

(2) is very important when trying to track down a bug, and one needs to examine 
the object code. D's format checking has eliminated much of the problems using it.

 > NOBODY

Nobody wanted ImportC, either. However, several people have told me that they 
have been seduced into using it and found it delightful and very productive. 
Heck, in another posting I discovered it could be used to translate C code to D!


More information about the Digitalmars-d mailing list