The state of string interpolation

Steven Schveighoffer schveiguy at
Fri Dec 7 20:13:09 UTC 2018

On 12/7/18 2:52 PM, H. S. Teoh wrote:
> On Fri, Dec 07, 2018 at 01:46:05PM -0500, Steven Schveighoffer via Digitalmars-d wrote:
> [...]
>> 	text(iq"CODETEMPLATE
>> 		void ${funcName}(${funcParams.formatted!"%-(%s, %)"}) {
>> 			${generateBoilerplate}
>> 			for (i; 0 .. ${numIter})
>> 			{
>> 				${generateFuncBody}
>> 			}
>> 		}
>> Oh, and it requires zero library support. It just works, as if you
>> called it with the parameters in the right place.
> The irony is that formatted!"%-%(s, %)" is essentially std.format
> wrapped in nice clothes, the very thing which we're trying to replace
> with string interpolation, and the very example of my point, which is
> that (standard) string interpolation syntax is limited in what it can
> express before you have to resort to inline code.

My vision of formatted would be simply a pairing of a format specifier 
with a value. It would be up to the function to interpret that (i.e. 
text, or inlineformat or whatever you like).

But the point is you are coupling the format with the value in the same 
place. Which is the idea behind the "named parameters" that you have.

I don't want the language to do any sort of formatting at all. That's a 
library feature. We just need the interpolation feature to give us a 
nicer way to call it.


More information about the Digitalmars-d mailing list