std.range: Order of arguments unluckily chosen?
Mehrdad
wfunction at hotmail.com
Sat Jun 4 20:14:53 PDT 2011
On 6/4/2011 4:25 PM, Michel Fortin wrote:
> Perhaps like this:
>
> auto take(R)(uint count, R this) { ... }
>
> Note that the second parameters's name is "this", which would mean
> that the second argument is the one that disappear using the member
> syntax.
>
> It can then be called this way:
>
> take(3, range);
>
> or this way:
>
> range.take(3);
>
> Having to specify explicitly whether a function is meant for
> member-syntax this way would also fix a couple of issues regarding
> UFCS: UFCS properties would be able to work correctly, and name
> clashes would happen less often when using the member syntax.
+1 for the idea, it's pretty similar to C#'s extension method syntax,
and it's pretty intuitive IMHO.
More information about the Digitalmars-d
mailing list