Re:Functional Programming – How and Why
by galaxyLogic on Tuesday January 03, 2023 @03:42PM
(#34237712)
An often overlooked feature of OOP is the use of pseudo-variable 'this' (or 'self in Smalltalk).
That is about name-scope. You can refer to your own method simply by its name via 'this', and when you call it you know it can access the state inside that particular object.
Without 'this' an object in JavaScript and other OOP languages could not access its own properties including it (possibly mutable) state.
Is there an equivalent to 'this' in purely FP languages?
On the contrary, this helps with modularity, which is a good thing. You can then swap out the object for another object with the same interface, but where the functions (methods) have different implementations.