3 ms·
Am I correct in my understanding that with a closure, it is one or more data bound to one function, while with object orientation, one or more functions are bou
by Lawtonfogle 11y ago
Am I correct in my understanding that with a closure, it is one or more data bound to one function, while with object orientation, one or more functions are bound to one or more data?
- Jtsummers 11y agoYes, but it can go a bit further. http://c2.com/cgi/wiki?ClosuresAndObjectsAreEquivalent http://c2.com/cgi/wiki?ClosuresAndObjectsAreEquivalent A singular closure is 1+ data bound to an entity (function). A singular object is multiple data/functions bound to one entity (object). In the link above there are examples of either generating multiple closures tied to the same set of data (like tel's example), and also examples of having a singular closure that takes as a first parameter a "method" name and branching based on that. Using either solution you have an OO system using closures as your basis.