"David Bergman" <[EMAIL PROTECTED]> writes: | > The idea that I've been throwing around is to be able to define a | > separate namespace for each type; a function can either belong in a | > "global" (default) namespace, or belong in a particular type's | > namespace. So, in the above example, instead of writing "addToFM fm | > ...", we could instead associate an 'add' function with the FiniteMap | > type, so we could write "fm.add ..." instead. Provided that fm's type | > is monomorphic, it should be possible to call the 'correct' add | > function; if we defined another 'add' function that's associated with | > the Set type, that will only get called if the 'x' in "x.add" is of | > type :: Set. So, like OO languages which inherently give separate | > namespaces to their different objects, here we give separate | > namespaces to different | > (monomorphic) types. In this case, if one simply writes "add" instead | > of "x.add", the compiler throws an error, because there is no 'add' | > function defined in the default namespace; add is only defined when a | > programmer writes "x.add" where x :: FiniteMap or x :: | > Set[1]. | | This overloading by namespace is usually called either ADL | (Argument-Dependent Lookup) or Koenig Lookup (especially in C++.)
Actually in C++, it is called "argument dependent name lookup", and that is the way the C++ definition text calls it. As Andy Koenig has himself pointed out, he did not invent that rule. He mentionned it when the C++ committee was solving a name look-up problem posed by namespaces to operator functions. That name look-up rule was later generalized to non-operator to cover the function-call syntax -- which is what is most known today and referred to above. This ends my C++ hour on Haskell list :-) -- Gaby _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell