On 9/9/25 22:46, Marc Feeley wrote:
My guess is that you have defined the `setup-primitives` macro using `define-macro`.
Thanks. To simplify things I got rid of the macro, that's not the issue.
The issue is that the result of computable-sqrt, where the error is raised, is not called in tail position, and where it is called the handler I defined is not invoked:
(CR->string (CRsqrt #e-1e-100000) 100000)
*** ERROR IN loop, "basics.scm"@62.37-62.43 -- computable-sqrt: argument is negative: #<procedure #5> ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ basics.scm ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ┃⋯ 61┃ (let* ((k* (+ k (integer-length k))) 62┃ (result (x k*))) ;; << points here 63┃ (set! result-so-far (cons k* result)) ┃⋯ 1>
So what do I wrap this call to (x k*) in to get it to pass up the exception to the handler in CRsqrt, which is
(pp CRsqrt)
(lambda (x) (let ((args (check-args 'CRsqrt (list x)))) (with-exception-catcher (lambda (err) (##raise-range-exception 1 CRsqrt x)) (lambda () (make-CR (computable-sqrt (car args)))))))