|
![](/i/fill.gif) |
Warp wrote:
> Darren New <dne### [at] san rr com> wrote:
>> Yep. And now what do you do if the "less" you want to use is actually a
>> member function of type T? What if the "less" you want to use is
>> class MyDate {
>> bool comesBefore(const MyDate& otherDate);
>> }
>
> You create a comparator and give that to std::sort. A comparator can be,
> for example, a (regular) function which takes two elements and returns bool.
And that's precisely what the C# syntax avoids you having to do, in the
other direction.
It's in there most likely because of LINQ, which is a bit of the language
that turns something that looks a bit like SQL into something that looks
like method calls. If there were two syntaxes for each possible call that
LINQ generated, you'd have a mess. So now
int xyz(this T alpha, U beta)
is a valid overloaded function candidate for
alpha.xyz(beta)
when alpha is a T and beta is a U.
--
Darren New, San Diego CA, USA (PST)
"Ouch ouch ouch!"
"What's wrong? Noodles too hot?"
"No, I have Chopstick Tunnel Syndrome."
Post a reply to this message
|
![](/i/fill.gif) |