Hi,

"John Trammell" <[EMAIL PROTECTED]> writes:

> After a little searching I've stumbled across "add-hook! exit-hook
> ...", but for the life of me I can't seem to get it to do what I want.
>  Here's a taste of what I'm looking for:
>
>    (define foo (lambda () (display "foo") (newline)))
>    (add-hook! exit-hook foo)
>    (run-hook exit-hook)
>
> I'd like something like this, that doesn't need the explicit
> "run-hook" at the end.  Ideas?

`exit-hook' is only run by the REPL, so it's not useful in programs.

One possibility is to catch the `quit' exception:

  guile> (catch 'quit
           (lambda ()
             ;; the function that may `exit'
             (exit 1))
           (lambda (key . args)
             ;; the handler
             (format #t "quit: ~a~%" args)))
  quit: (1)

Thanks,
Ludovic.



Reply via email to