Re: posix-error and a list of scheme procedure arguments
Göran Weinholt 16 Aug 2020 08:52 UTC
Shiro Kawai <xxxxxx@gmail.com> writes:
[...]
> I can certainly wrap Gauche's low-level syscall API with guard and
> translate <system-error> to srfi-170 error, in every srfi-170 API. The
> overhead isn't small and I'd rather avoid it if I can.
Loko Scheme's implementation of SRFI 198 uses the R6RS condition system.
This way there is no need to use guard, because any syscall error
anywhere in Loko already raises an R6RS condition and SRFI 198 just
needs to recognize it. Maybe you can use a similar strategy in Gauche,
can you teach SRFI 198 to understand <system-error>?
In Loko, the foreign-error:* procedures understand R6RS conditions and
check their argument to see which kind of condition they've been given.
make-foreign-error translates its argument into conditions. This also
has the benefit of letting any R6RS code handle the &who, &message and
&irritants part of the SRFI 198 error.
It works because SRFI 198 defines a constructor and accessors that hide
the concrete type of conditions. I haven't been keeping up with the
discussion lately, but I hope that this aspect hasn't changed.
Loko is up to date with SRFI 198 draft #3 and SRFI 170 draft #10. Here
is the code:
https://gitlab.com/weinholt/loko/-/tree/master/srfi
(The srfi/ directory is MIT-licensed.)
--
Göran Weinholt | https://weinholt.se/
Debian Developer | 73 de SA6CJK