Re:What is a functional programming language?
by lg on Thursday July 23, 2009 @09:45PM
(#720759)
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.
[ Parent
| on HN ]
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