In the year or so that I've spent with Common Lisp, I've been trying to make a conscious effort to try to make effective use of lexical closures, rather than immediately run to the relative familiarity of objects.
I've found them really useful on occasion, but as I've tried to use them in more ambitious use cases, I've found myself wanting to use CLOS instead. I'm not sure if that's just a matter of familiarity.
There is some discussion on the topic here, but much of that seems a bit of a pissing contest, and I didn't find it all that enlightening.
My gut feel so far is that I'd tend to use closures in simpler cases, such as:
Am I short-changing closures?
I've found them really useful on occasion, but as I've tried to use them in more ambitious use cases, I've found myself wanting to use CLOS instead. I'm not sure if that's just a matter of familiarity.
There is some discussion on the topic here, but much of that seems a bit of a pissing contest, and I didn't find it all that enlightening.
My gut feel so far is that I'd tend to use closures in simpler cases, such as:
- 1. Where you might see a singleton - a number of top-level functions closed over the same lexical bindings
2. Where you might be generating an abstraction that really is a single function(let ((things ()) (stuff 0)) (defun add-thing (thing) ...) (defun rm-thing (thing) ...))(function make-fsm (x) (let ((state 0) (other-stuff 42)) (lambda () (do-things-with state x)))
Am I short-changing closures?
~garethw