> From: Lassi Kortela <xxxxxx@lassi.io> > Date: Saturday, August 15, 2020 7:09 AM > > [...] > >>> 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). > > +1 > >> 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. > > For always guaranteeing to find the calling Scheme procedure, I'd make > that optional so we can ship 170 without a giant delay. I believe both John and I are convinced we should require the triple of 'scheme-procedure, its 'args, and 'foreign-interface (at least the latter is easy in Shiro's signaling an error at the C level scenario). > As far as I can tell, we could solve the errno problem for SRFI 170 by > letting the implementor return a foreign-status object with any 'set > they want (or no 'set at all, which is the same as #f). Except this is a tightly specified SRFI. One problem comes with Shiro's scenario where a C level primitive that's not only called by SRFI 170 (or in the long term, any of the other POSIX SRFIs that extend it), and therefore 'set is unknown, although 'errno, which I'm vastly preferring for the key for the errno raw integer, *can* have a legitimate value. > But they must always fill in an 'errno property with the > errno-equivalent symbol where such is known. Urg for namespacing, but, yes, it's probably not much of an imposition to also report the C define name as a symbol, e.g. 'ENOENT under whatever key we decide for the POSIX errno 'set. > We could provide a mapping of Windows API error codes to errno values in > the sample implementation. Python already does such a mapping in its os > module I think. I really dislike lying to the user. Perhaps justifiable here, but.... > As explained in another thread, I wouldn't use a 'set property to > indicate success vs failure from negative vs nonnegative return values. Set just tells you the slice of the status and error universe the object is in, and ideally it'll be registered in the Schemeregistry. Unless you use the generic reserved values of 'error or 'status (and even then you could lie in using them), it says absolutely nothing about whether the foreign status object represents success or failure, unless by convention all status in that set are one or the other, which is true for the POSIX errno 'set. If not, that would be the job of a standard key inside it. Perhaps common enough to be added to the Standard set conventions at the end of SRFI 198. The 'success? key you suggest below sounds good. > Infinite sets are not enumerable so those are not really error codes. I > would just return a 'success? property that is #t or #f, which gives the > same information. If we want to return the precise return value as well, > I'd return it in 'number (aka 'code) but leave out the 'set unless it > really belongs to a coherently defined set of particular error values. And here I say for the last point you make above, use 'set with either 'error or 'status as the value to signal that the status object is *not* one of those "coherently defined set[s] of particular error values." Which could actually save a lot of effort by telling people, don't look to the Schemeregistry to figure out what the additional keys mean, read the documentation or source code that's using SRFI 198 in this very generic way. - Harold