Closed technoblogy closed 5 years ago
If the expression in a return statement calls a function that itself uses a return statement, the first return statement never returns. For example:
(defun tst (x) (loop (return (fun x)))) (defun fun (y) (loop (return (car y))))
then calling:
(tst '(a b))
should return a, but instead hangs up.
A workaround is to assign the result to a temporary variable, and then return that:
(defun tst (x) (loop (let ((val (fun x))) (return val)))) (defun fun (y) (loop (return (car y))))
So now, as expected:
> (tst '(a b)) a
If the expression in a return statement calls a function that itself uses a return statement, the first return statement never returns. For example:
then calling:
should return a, but instead hangs up.
A workaround is to assign the result to a temporary variable, and then return that:
So now, as expected: