DIP 1027---String Interpolation---Format Assessment

Walter Bright newshound2 at digitalmars.com
Mon Feb 24 20:55:16 UTC 2020


On 2/24/2020 11:45 AM, Adam D. Ruppe wrote:
> On Monday, 24 February 2020 at 19:35:16 UTC, Walter Bright wrote:
>> Having the compiler lower string interpolation to some hidden template is - 
>> AST macros. We're not doing AST macros.
> 
> This is untrue.
> 
>> Hidden user-defined semantics are not for D.
> 
> We are NOT calling for this.
> 

https://digitalmars.com/d/archives/digitalmars/D/DIP_1027--String_Interpolation--Final_Review_Discussion_Thread_335065.html#N335132

 > * put the format literal in a wrapper type.
 > i"$foo %"
 > is translated to the tuple:
 > __d_format_literal!("%s %%"), foo


and also you wrote:

 > if we can
 > all agree to amend it to put in the template thing we can fix
 > everything. Even with just the one string arg, we can do a lot
 > with it...

and proposed a lowering to:

 > i"your hex data is ${%02x}someByte"
 >
 > (_d_interpolated_string!("your hex data is ",
 > _d_interpolated_format_spec("%02x"))(), someByte)

and proposed:

 > i"$foo %"
 > is translated to the tuple:
 > __d_format_literal!("%s %%"), foo
 > struct __d_format_literal(string fmt) {
 >          enum f = fmt;
 >          alias f this;
 > }


More information about the Digitalmars-d-announce mailing list