Let's say I write the following code:

(let* ((f (lambda () (debug))))
  (funcall f))

This will produce the following backtrace:

Debugger entered: nil
  (closure (bootstrap-version t) nil (debug))()
  funcall((closure (bootstrap-version t) nil (debug)))

Is it possible to name the closure somehow in order to more easily read the backtrace? (In my use case, I can't just extract the function into a defun, because the function inherits lexical variables from an outer scope.) The closest I've found so far is to use a cl-block, but it still clutters the backtrace quite a bit.

(let* ((f (lambda () (cl-block foobar (debug)))))
  (funcall f))


Debugger entered: nil
  (catch '--cl-block-foobar-- (debug))
  (cl--block-wrapper (catch '--cl-block-foobar-- (debug)))
  (cl-block foobar (debug))
  (closure (bootstrap-version t) nil (cl-block foobar (debug)))()
  funcall((closure (bootstrap-version t) nil (cl-block foobar (debug))))
  (let* ((f (lambda nil (cl-block foobar (debug))))) (funcall f))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.