Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Steven Schveighoffer
schveiguy at gmail.com
Fri Jan 29 20:45:52 UTC 2021
On 1/29/21 3:01 PM, Paul Backus wrote:
> On Friday, 29 January 2021 at 19:51:52 UTC, Steven Schveighoffer wrote:
>> https://github.com/dlang/DIPs/blob/344e00ee2d6683d61ee019d5ef6c1a0646570093/DIPs/DIP1036.md#a-string-interpolation-sequence-is-not-a-value-tuple
>>
>>
>> The intention is for anything other than a function call or template
>> that accepts the expanded form to treat it as a string type. This
>> means typeof too. I should add it to the examples there.
>
> That just pushes the problem back one level:
>
> anySatisfy!(isSomeString, typeof(AliasSeq!(i"I have ${count}
> applies")))
>
> Or, more realistically:
>
> template someTemplate(Args...) {
> static if (anySatisfy!(isSomeString, typeof(Args)) {
> // ...
> }
> }
>
> someTemplate!(i"I have ${count} apples")
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.
-Steve
More information about the Digitalmars-d
mailing list