On Sat, Aug 17, 2002 at 02:18:56PM -0400, David Abrahams wrote: > Huh? That's certainly not what I thought I was saying. I was saying that a > reason I thought it was important to be able to test type categories (what > Guido calls "look before you leap") was for implementing multiple dispatch. > In other words, an idiom which most people agree is usually a bad choice > for user code might be a great choice for a generalized library or language > facility. Multiple dispatch is one possible use for testing type categories. Another important use is early detection of errors and more informative error messages. When using a library the errors resulting from a bad argument to one of its published entry points are often raised deep within someone else's code with an uninformative message, making them hard to trace. If an object of the incorrect category is passed to a method that just stores a reference to it the actual error may only be raised much later, making it even harder to trace. There is also the issue of trusting someone else's code - maybe it's a bug in the library? With explicit category checks it's easier to tell that the source of the problem. The extreme form of early detection is static typing, of course. Forcing category checks on all arguments passed is too much overhead for me. I prefer explicit checks for protocol compliance at some well-defined interface points between different domains of code. When an exception is raised the region of uncertainty about its real source can sometimes be quite large. Category checks can serve as a kind of fire door to try to limit the spread of uncertainty. The problem with putting too many fire doors is that they hinder passage because they must be kept closed at all times. Oren
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4