|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2007-03-14 15:42:30
On Wednesday 14 March 2007 15:05 pm, Hartmut Kaiser wrote:
> Frank Mori Hess wrote:
> > I have to say I really am not a big fan of needless
> > overloading of the languages operators like logical || and
> > &&. Especially when you are overloading them with functions
> > that really don't correspond to the original operators. What
> > if I want to overload || with a function that actually does
> > correspond to logical or, like
> >
> > Future<bool> operator||(const Future<T> &a, const Future<U> &b);
>
> 1. Why do you would do that? Do you have a use case?
Making active functions that take futures as arguments and return futures
as return values is the primary feature of libpoet. See
http://www.comedi.org/projects/libpoet/
So the operator|| above would be used if you wanted to || two results and
pass the result of the || to another active function without blocking
waiting for the futures to become ready. Really it was just an example
though, I'm not currently planning to implement this (although maybe I
will someday if I discover it to be useful).
> 2. If you really have to do that, simply do not include the header(s)
> defining the operators.
I don't really have to define an operator||, I could just give the function
an ordinary name. My point is, composing futures like in Thorsten
Schütt's implementation doesn't really have to define an operator||
either. And, if I had to choose which function had a more legitimate
claim to use operator||, I'd choose my example.
Not including the headers isn't really a solution, since it precludes the
use of the conflicting functions in the same code.
Pointless overloading isn't a good thing. What does it buy you here? A
pair of parenthesis.
-- Frank
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk