Multimethods are ambient actions. You could implement them with functions and any sort of type system. Maybe also a way to have variable-length parameter lists. If that's OO then functional programming is object-oriented programming.
Re:What is a functional programming language?
by jrockway on Friday July 24, 2009 @03:09PM
(#722190)
Yes, functional programming is very similar to OO.
OO:
class SomeType {
<data> ;
SomeOtherType function1() {
this.whatever ;
...
}
}
FP: data SomeType ...
f1 :: SomeType -> SomeOtherType
f1 this = whatever this >> ...
Same idea, different syntax. (Type classes will allow polymorphism, if that's what you're after.)You are thinking of the abstraction in terms of its implementation. There is no reason why a method in a class would physically be in that class; the class just acts as a namespace:
class Foo { method }
Foo.method();
and (defmethod Foo.method ...)
(Foo.method)
are the same.Multimethods means that a method is dispatched not only on basis of the receveiving object (or read: first argument) but on basis of all arguments. The term is inherently related to OOP: http://en.wikipedia.org/wiki/Multimethod
(Remember the whole "sending a message to an object" thing? You do that with both variants. In the single-dispatch case, the method is a structure in the metaclass instance. In the multiple-dispatch case, some other helper object finds the right method. Same idea, though.)