UFCS - why only allow the first parameter?
Jonathan M Davis
jmdavisProg at gmx.com
Fri Feb 22 23:43:09 PST 2013
On Saturday, February 23, 2013 08:26:57 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
Because that's not what member functions look like. The whole point is to make
calling the free function look as if it were a member function on the type of
its first argument. In general, it shouldn't matter whether a function is a
free function or a member function, it can be called the same way. That then
makes the call syntax for functions "universal."
What you seem to be suggesting is to basically make it so that you can put the
parens of the function call on either side of the function name, and that's
not at all what UFCS is trying to do, and it doesn't help one whit with
generic code, which is the primary benefit of UFCS.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list