
At 01:43 PM 10/30/03 +0100, Samuele Pedroni wrote:
- multi methods cover some ground also coverd by interfaces and adaptation: *) a generic function/multi method is also an interface *) some of the things you can achieve with adaptation can be done with multi methods Once you have multimethods do you still need adaptation in some cases or, could one obtain the functionality otherwise or do you need dispatch on interfaces (not just classes), how would then interfaces look like and the dispatch on them?
With a sufficiently powerful predicate dispatch system, you could do away with adaptation entirely, since you can simulate interfaces by implementing a generic function that indicates whether a type supports the interface, and then defining a predicate type that calls the generic function. That is, I define a predicate type IFoo such that ob is of type IFoo if 'implementsIFoo(ob)'. Then, for any type that implements the interface, I define a multimethod saying that implementsIFoo() is true for objects of that type. Then, I can declare multimethod implementations for the IFoo predicate type. What I'm curious about is: is there any way to do it *without* predicate types? Could you have an "open ended union" type, that you can declare other types to be of, without having to inherit from a base type?