static interface

Leandro Lucarella llucax at gmail.com
Tue Nov 17 06:19:56 PST 2009


Lars T. Kyllingstad, el 17 de noviembre a las 15:12 me escribiste:
> 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.

OK, there are way to fix that too, but I see your point now.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
"The Guinness Book of Records" holds the record for being the most
stolen book in public libraries



More information about the Digitalmars-d mailing list