Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
Jacob Carlborg
doob at me.com
Sat Jan 30 07:36:24 UTC 2021
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.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list