4 ms·
Even passing over that, it's only a closure if it keeps a lexical environment. (lambda (x) (+ x 1)) doesn't close over anything, so it's not a closure, nor doe
by bandrami 11y ago
Even passing over that, it's only a closure if it keeps a lexical environment.
(lambda (x) (+ x 1)) doesn't close over anything, so it's not a closure, nor does it evaluate to one. For that matter, (let ((x 0)) (lambda (x) (+ x 1))) isn't really a closure in any sense because the environment can be inlined out.
- agumonkey 11y agoI call them free closures.
- waldrews 11y agoDoesn't (lambda (x) (+ x 1)) capture +? You could evaluate (lambda (x) (+ x 1)) in a scope of, say, (let ((+ *)) (lambda (x) (+ x 1))) - in some lisps.
- bandrami 11y agoAh, I guess in Scheme it does (I use Common Lisp, where the two namespaces are different). But even then you would need the actual environment there for it to be a closure. The lambda expression is only half of a closure. It's "let over lambda" that is a closure.