[OT] new thing I learned for today

jmh530 john.michael.hall at gmail.com
Wed Dec 18 14:18:24 UTC 2019

On Wednesday, 18 December 2019 at 01:20:33 UTC, Steven 
Schveighoffer wrote:
> [snip]
> BTW, people have been talking about usage like:
> auto str = i"I have $apples apples".format;
> And it got me thinking, does this actually work? I mean, can 
> multiple parameters be used for UFCS?
> Answer: yes.
> auto str = AliasSeq!("I have %s apples", apples).format; // OK
> pretty cool. I had no idea.
> -Steve

I think it works because format takes a variadic template as an 
input. Given the connection between variadic templates and 
AliasSeq, the input is basically an AliasSeq in the first place. 
Shouldn't be an issue having AliasSeq's with length>1.

I don't know if I would describe it as multiple parameters. I 
would call UFCS with multiple parameters as describing when you 
have foo(x, y, z), you can call x.foo(y, z). In this case, 
something like
auto str = AliasSeq!("I have %s apples").format(apples);
also compiles without error and would be more comparable.

More information about the Digitalmars-d mailing list