4 ms·
Functional programming and objects are not orthogonal as you suggest.
by j2labs 15y ago
Functional programming and objects are not orthogonal as you suggest.
- thesz 15y agoYes, they pretty opposite. Objects should have identity and can be distinguished by identity alone. They are not referentially transparent because of that. In "x = new O(); f(x,x)" you cannot substitute "new O()" into both occurrences of x. Functional values do not have identity and you cannot tell apart 2 and 1+1. Functional values are referentially transparent. In "x = 1; y = x+x" you can change x to 1 in the definition of y.
- j2labs 15y agoAgain, they're not opposite. You can create most of the properties of an object with a closure and versa vice. http://c2.com/cgi/wiki?ClosuresAndObjectsAreEquivalent http://c2.com/cgi/wiki?ClosuresAndObjectsAreEquivalent