DIP 1027--String Interpolation--Final Review Feedback Thread

Juraj Mojzis mojo at frikulin.sk
Wed Feb 12 11:49:11 UTC 2020


On Thursday, 30 January 2020 at 09:47:43 UTC, Mike Parker wrote:
> This is the feedback thread for DIP 1027, "String 
> Interpolation".

If
writefln(i"I ate $apples and ${%d}bananas totalling $(apples + 
bananas) fruit.");
gets rewritten as:
writefln("I ate %s and %d totalling %s fruit.", apples, bananas, 
apples + bananas);

Than for function:
void my_err_log(string err_msg, string file, int line, int char) 
{...}

called as:
my_err_log(i"Error loading image $image_path.", src_file, 
src_line, src_char);

gets rewritten as:
my_err_log("Error loading image %s message", image_path, 
src_file, src_line, src_char);

Results in an error but users will expect this to work.

Worst case scenario is function that match:
void draw_text(string text, int optional_x = 0, int optional_y = 
0) {...}
callad as:
draw_text(i"Today is $day.$month.");


For example, Phobos exceptions are mostly defined as :
this(string msg, string file = null, size_t line = 0)
this(string msg, string file = __FILE__, size_t line = __LINE__, 
Throwable next = null)
etc.

In my opinion, this is the fundamental flaw in the proposal.




More information about the Digitalmars-d mailing list