UFCS - why only allow the first parameter?

Timon Gehr timon.gehr at gmx.ch
Sat Feb 23 04:49:41 PST 2013


On 02/23/2013 08:26 AM, dennis luehring wrote:
> func(a,b,c)
>
> can be written as a.func(b,c)
>
> is there a good reason
>
> for not allwing
>
> (a,b).func(c)
>
> or even
>
> (a,b,c).func()?
>
> for me it feels natural

Syntactically, because that is the comma operator.

The following shows an arbitrary limitation:

auto seq(T...)(T args){ return args; }
void func(int a,int b,int c){ }
void main(){ seq(1,2).func(3); }


But the following works:

struct Q(T...){ T q; }
auto q(T...)(T q){ return Q!T(q); }
void func(int a,int b,int c){ }
void main(){ q(1,2).q.func(3); }



More information about the Digitalmars-d mailing list