[GoLUG] Scheme -- guile3, may all your parentheses be in the correct order

Barry Fishman barry at ecubist.org
Sun Aug 18 21:55:22 EDT 2024


On 2024-08-19 00:11:10 GMT, David Billsbrough wrote:
> I had time today to see if I could add your suggestion and I got it to
> do the date calculations.  Updated the Repo.
>
> Does scheme handle error handling in any standard way across versions?

Error handling is specific to the scheme implementation.  Two different
approaches are use in the last two standards (R6RS and R7RS).
Guile sort of supports both.  I really try to avoid it all, and
call (error "message") if I can't avoid the problem.

Something line:

 (define data-file (or (getenv "HOME")
                       (error "HOME environment variable not set"))
                       "/.foobar")

Or if I can't get around it:

(use-modules (ice-9 exceptions))

(with-exception-handler
    (lambda (k)
      (display "Caught error: ")
      (write k)
      (newline))
    (lambda ()
       (/ 3 0))
    #:unwind? #t)  ;; A guile-ism to avoid prompt interaction

(display "Code after handling error")
(newline)

-- 
Barry



More information about the GoLUG mailing list