Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2

Walter Bright newshound2 at digitalmars.com
Fri Jan 29 08:02:34 UTC 2021


Comparing two simple examples of #DIP1036 and #DIP1027:

DIP1036:
   printf(i"%s${item} %02d${other_item}"); // metaprogramming + printf overload

DIP2027:
   printf(i"$item ${%02d}other_item");  // direct


DIP1036:
   writeln(i"I ate ${apples} apples and ${bananas} bananas totaling ${apples + 
bananas} fruit.");

DIP1027:
   writefln(i"I ate $apples apples and $bananas bananas totaling $(apples + 
bananas) fruit.");


DIP1036 is more user typing, including awkward-to-type { }, along with needing 
substantial user code to implement (for printf).

DIP1027's syntax is optimized to make the most common cases the simplest for the 
user, no user code is required.


More information about the Digitalmars-d mailing list