2 ms·
The author provides the example o.f() f(o) and states that o.f() implies that f is polymorphic while f(o) implies a source code dependency on a particular
by smadge 9y ago
The author provides the example
o.f()
f(o)
and states that o.f() implies that f is polymorphic while f(o) implies a source code dependency on a particular function f. They conclude objected oriented is polymorphic, while functional is referentially transparent.
This is not true. In the functional case of f(o), o could be a value with a type which is an instance of a type class which must define a function f. In which case f is a polymorphic function. Comparably to how o.f() implies o is a type (ie a class) which implements an interface that requires the class implement a method f. However in the function case we get polymorphism AND referential transparency. Whereas in the object oriented case we have no garauntees about referential transparency.