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

Steven Schveighoffer schveiguy at gmail.com
Sun Jan 31 16:00:53 UTC 2021


On 1/30/21 2:36 AM, Jacob Carlborg wrote:
> On 2021-01-29 21:45, Steven Schveighoffer wrote:
> 
>> Yes, that would return false.
>>
>> But, this seems still pretty far fetched for a real use case. Not only 
>> that, but there is still a way to fix it, just use .idup if what you 
>> really meant was a string. And it's not something that's needed to be 
>> done by the author of someTemplate, just the user in the (probably 
>> one) case that he uses it.
>>
>> Consider that there are still places where one must use 
>> AliasSeq!(things) to work with them properly in templates (I get bit 
>> by this occasionally). It's quite similar actually.
>>
>> I remain unconvinced that this is a problem. But I will concede there 
>> are a few more cases where an explicit idup might be required than 
>> just tuple.
> 
> You could tweak the DIP slightly and say: in all places `idup` is 
> automatically inserted, except in a parameter list where the first 
> parameter is `interp`.
> 
> template someTemplate(Args...) {
>      static if (anySatisfy!(isSomeString, typeof(Args)) {
>          // ...
>      }
> }
> 
> someTemplate!(i"I have ${count} apples");
> 
> The above would evaluate to true.
> 
> template someTemplate2(interp!string i, Args...) {
>      static if (anySatisfy!(isSomeString, typeof(Args)) {
>          // ...
>      }
> }
> 
> someTemplate2!(i"I have ${count} apples");
> 
> The above would evaluate to false.
> 

No, I don't want to do this. It's possible, but very very unintuitive, 
especially when the expanded form MUST match a variadic parameter The 
more we special case these rules, the harder to understand it gets.

And besides, your first parameter is not right. There's actually no way 
to specify it outside a template constraint I think.

-Steve


More information about the Digitalmars-d mailing list