Sub-set key and zero/nonzero success/failure status sets
Lassi Kortela 14 Aug 2020 08:47 UTC
> BTW, it's occurred to me that we should add a 'sub-set key. Maybe for
> 'sqlstate as you and John have explored, where SQL RDBMSes that follow
> it would naturally have that as the 'set, and e.g. 'postgresql as a
> subset. Just checked and it even covers connection failures.
And for ('set 'errno) we could have ('subset 'linux), ('subset 'freebsd)
and the like.
I thought about this earlier but dropped the idea because I wasn't
confident in my ability to say what the right subset is in the general
case. What if there are two reasonable contenders for 'subset, which one
do we pick?
It's probably wiser to use more specific property names. 'os to name the
operating system, 'sql-engine (better name welcome) next to 'sqlstate to
name which database generated it, etc.
> And I've identified what I'm currently naming "generic-unix-lib" for
> libraries like libsodium that return only a sentinel value like -1 on
> error, 0 on success. It has no structure beyond that, except of
> course for what's naturally covered by the standard keys of
> scheme-procedure, foreign-interface, and message.
Good thinking.
IMHO the error-set concept is stretched a bit beyond its bounds here. A
set is supposed to be enumerable (at least in principle, e.g. by running
a groveler or reading a manual). Return codes 0 and -1 form a set of two
values, but since we're being this vague:
1) it's not really useful to talk about a set; while sets work fine for
zero or more elements, they are mainly useful when there are many of them.
2) we probably don't know that -1 and 0 are the only possible return
value. What if -2 is also a possible return value? Is the spec really
that >=0 is success, <0 is error? If all negative integers are possible
error values, we have an infinite set and enumeration is no longer
useful. We should really talk about something else than a set.
For easy but vague cases where we only know to distinguish success and
failure, I suggest we use a boolean 'success? field in the object.
If we want to preserve the exact integer return code we got, but only
know that zero is success and nonzero is failure (or the inverse), I
suggest we leave out 'set and only return 'code and 'success?.