Leandro Lucarella wrote:
Lars T. Kyllingstad, el 17 de noviembre a las 09:54 me escribiste:
In some ways the current code is better, because it actually checks if
a construct works or not, rather than requiring a specific function
signature. Whether the code will work is really the minimal
restriction you can place on the interface. A specific may be too
tight. For instance, above you don't really care if empty returns
bool or not. Just if you can test it in an "if".
Another, related way in which the current code is better is that it
doesn't care whether empty, front, and popFront are functions or
variables. As we know, the standard trick for infinite ranges is to
declare empty as an enum, not a function.
Is not that hard to write:
bool empty() { return false; }
instead of
enum bool empty = false;
That's why I mentioned infinite ranges. An infinite range is *defined*
as a range where empty is implemented as
enum bool empty = false;
isInfinite(Range) tests whether this is the case, which it wouldn't be
able to do if empty() was a function.
-Lars