Class/Interface Modeling of Ranges

Lutger lutger.blijdestijn at gmail.com
Sat Nov 21 02:31:15 PST 2009


dsimcha wrote:
...
> 
> 3.  Can we simplify this by using runtime exceptions instead of compile
> time
> errors for some of this stuff?  For example, every range would have a
> hasLength() method and a length() method.  If hasLength() is false,
> length()
> would throw.  Though this sacrifices compile time error checking, it might
> be
> better in some ways.  For example, if a given compile time type may or may
> not have length depending on its runtime type, you could check at runtime
> whether it has a length and adapt your handling of it accordingly.

[OT] fwiw this is used in .NET a lot to prevent factoring into loads of 
interfaces. They call it Optional Feature pattern (giving further credit to 
the idea that patterns are workarounds for weak spots in a language...)




More information about the Digitalmars-d mailing list