Re: Error in error?
On 22-09-2022 01:17, sidhu1f wrote: You are both correct. My motivation was to use the assert macro from guile-libs (www.nongnu.org/guile-lib/doc/ref/debugging.assert/). Do you know that Guile already has an 'assert 'macro (see: (guile)rnrs base)? It is less capable though (no ?r-exp), so maybe not suitable for your purposes. In assert.scm (version 0.2.7), the error procedure invocation on line 62 uses "~a". So should this invocation be replaced by scm-error instead? It seems so to me, you could give it a try. Greetings, Maxime. OpenPGP_0x49E3EE22191725EE.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature
exit-hook never executed
Hi, `exit-hook' seems to only be executed when in a REPL. Is there a way for it to be executed at the end of a none interactive program? My intend here is that I have a module that load a foreign extension and initialize its runtime so that other modules of that extension can be used. I then add a hook for finalizing the extension, which is important to save data. Here's the snippet: --8<---cut here---start->8--- (define-module (jami) #:use-module (system foreing-library)) (let* ((libjami (load-foreign-library "libguile-jami")) (init (foreign-library-function libjami "init")) (fini (foreign-library-function libjami "fini"))) (init) (add-hook! exit-hook fini)) --8<---cut here---end--->8--- So I guess the trivial solution would be to ask the user to manually call the `init' and `fini' procedure before using any procedures of the extension. Something like this: --8<---cut here---start->8--- (define-syntax-rule (with-jami body body* ...) (dynamic-wind init (lambda () body body* ...) fini)) --8<---cut here---end--->8--- But it would be nice to a have a hook for finalization like `exit-hook' that is hidden from the user. Though? -- Olivier Dion oldiob.dev