John Cowan suggested that SRFI 226 should include a version of Common
Lisp's unwind-protect suitable for Scheme.
In [1], I replied after some discussion with the following proposal
for a definition of a Scheme unwind-protect:
(define-syntax unwind-protect
(syntax-rules ()
((unwind-protect protected-form cleanup-form)
(call-with-continuation-barrier
(lambda ()
(dynamic-wind
(lambda () (values))
(lambda () protected-form)
(lambda () cleanup-form)))))))
As I think it is essential to get this famous form right when included
in a fundamental SRFI like SRFI 226, I would like to hear more
opinions on the above form.
(It should be noted, that Scheme procedures like
`call-with-input-file` are not based on unwind-protect semantics.)
Should there be no consensus on unwind-protect, it is probably better
to reserve an extra SRFI for it (which, in turn, can depend on SRFI
226).
Thanks for taking a look,
Marc
--
[1] https://srfi-email.schemers.org/srfi-226/msg/20888154/