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

Walter Bright newshound2 at digitalmars.com
Thu Feb 6 07:00:33 UTC 2020


On 2/5/2020 1:15 AM, FeepingCreature wrote:
> On Wednesday, 5 February 2020 at 09:11:20 UTC, Walter Bright wrote:
>> On 2/4/2020 9:48 PM, FeepingCreature wrote:
>>> This may sound trivial, but trivial syntax enhancements matter, especially 
>>> for a "top-ten" feature like format strings.
>>
>> It's a fair point, but there's a cost to supporting this. Nothing comes for 
>> free, and supporting everything is not practical.
> 
> Okay, what actually is the cost of lowering to a template instantiation 
> returning a type with an alias to a tuple, compared to lowering directly to a 
> tuple? Is this significantly harder to implement and support?

For one thing, it becomes part of the language specification. It has to be 
documented and taught. It turns a simple feature into a complex one. Having 
language semantics controlled by a hidden template is not in any other part of 
D. It implies that the behavior of interpolated strings is not predictable. 
Template instantiations are a LOT slower than direct implementation. Lots of 
interpolated strings means lots of template instantiations.

Yes, it's also significantly more code to implement, and there has to be error 
recovery for when the template can't be found, and checks for a rogue template.

All that has to be weighed against the benefit. Implementing something just 
because it is feasible and ticks a box is not a sufficient reason to do it. D 
must have smallish features that are widely useful, not be a large collection of 
trivia.



More information about the Digitalmars-d mailing list