4 ms·
One difference between objects and closures is that objects require explicitly passing state into them, while closures can capture state from their context. Thi
by asimjalis 17y ago
One difference between objects and closures is that objects require explicitly passing state into them, while closures can capture state from their context. This is powerful because it lets you explore different abstractions cheaply with closures. Programming in Lisp I frequently stumble upon abstractions that I would not have noticed if I was programming in Java or some other closure-less language. For example, a button is just a closure. It supports exactly one operation: click.
- j_baker 17y agoThis can also be a bad thing. If you explicitly pass in parameters to something, it's much easier to tell where certain pieces of data are coming from.
- asimjalis 17y agoRight. More explicit means less fluid. So there is a trade-off. Fluidity might not be important when the design is well-known and fixed. But if you want to use code as a medium for exploring design, then fluidity is powerful.