2 ms·
In Common Lisp, LAMBDA doesn't automatically define a return point; you have to use BLOCK NIL (or some macro (like DO or LOOP) whose expansion includes a BLOCK
by ScottBurson 15y ago
In Common Lisp, LAMBDA doesn't automatically define a return point; you have to use BLOCK NIL (or some macro (like DO or LOOP) whose expansion includes a BLOCK NIL) in order to be able to use RETURN.
> (defun foo ()
(block nil
(funcall (lambda () (return 3)))
4))
FOO
> (foo)
3
So the problem is that JavaScript's `function' always creates a return point.
- xyzzyz 15y agoYour example does not make much sense, because you can return-from foo in lambda, without enclosing it in a block. The solution proposed by OP (distinguishing "lambda" callables from "block" callables) is in my opinion misguided, because it only solves a problem partially, in a confusing way and creates new, unnecessary entities. The return-from mechanism is simpler and more intuitive.