Re: posix-error and a list of scheme procedure arguments hga@xxxxxx 15 Aug 2020 11:50 UTC

> From: "Marc Nieper-Wißkirchen" <xxxxxx@nieper-wisskirchen.de>
> Date: Saturday, August 15, 2020 6:16 AM
>
> Am Sa., 15. Aug. 2020 um 12:58 Uhr schrieb <xxxxxx@ancell-ent.com>:
>
>> The theory I've been working on is that it's the responsibility of
>> the calling Scheme procedure to catch such thrown errors and turn
>> them into proper SRFI 170 errors.  Like too many other details,
>> I've fudged this for the SRFI 170 Chibi Scheme sample
>> implementation, its automagic FFI only throws type check errors, I
>> just mechanically duplicate that checking in the calling Scheme
>> procedure.  An error like EPERM, which of course can only be
>> detected at the C level, is done through an error return value and
>> then (improper) querying of errno.
>>
>> Having 'scheme-procedure be #f deprives the user of valuable
>> information that could make debugging quite a bit harder, although
>> if you fake the values for the 'args key it probably won't be too
>> bad.
>>
>> One alternative that occurs to me is that you could pass to the C
>> code the calling Scheme procedure, or as you note, examine the
>> stack to get that and the args.
>
> Depending on the implementation there may be no stack entry. And you
> probably don't want the overhead to pass the called Scheme procedure
> and its arguments in the generic case where there is no error.

I agree with the latter point, it's weighing down each call just in
case an error is detected.

> The information about the called procedure and its arguments is
> certainly useful for debugging, but it is probably best to leave it up
> to the implementation how (and if) this information is provided (at
> least until we have some general consensus about debugging
> facilities).

Disagree on the "and if", I don't think an implementation will be
providing enough useful information if it doesn't provide that basic
information.  It's still explicitly allowed, ed style "?" errors
without, well, I suppose any keys in Lassi's conception.  In my
conception including example code, they'd have 'status or 'error
as the value of the 'set key, and require *nothing* else in the object.

Is it really a grave imposition on the programmer using SRFI 198 to
have to supply one of those two generic reserved 'set values if he
just wants to get the job done, doesn't for example want to go to the
trouble of registering an error set with Schemeregistry??

Note also I plan to carve out some very genetic 'set values, like
genetic-unix-lib, which would only require the keys 'scheme-procedure,
'foreign-interface, 'message, and 'args.  SQLSTATE is also a good
candidate for this.  But of course we can't require the user of SRFI
198 to bother checking Schemeregistry before using SRFI 198.

- Harold