Re: Safe enumerations for codesets
Lassi Kortela 15 Dec 2022 09:29 UTC
> I would say that an implementation should export an enumeration type
> such that, e.g. (codeset errno) expands to 'errno, and such that
> (codeset lassi) will be a syntax error (meaning that the lassi codeset
> is not supported).
That doesn't really make sense, as you could do something like:
(codeset-message (codeset some-codeset) (some-other-codeset foo))
and it doesn't ensure that 'foo is in fact part of some-codeset.
It should be something like this instead:
(codeset-message (errno EPIPE))
or:
(errno-message EPIPE) [syntax]
The present SRFI is meant to be a bare minimum foundation that doesn't
express an opinion on enums. It's possible to build enum-based stuff on
top. I think that should generally be done on the user's end, not by the
codeset provider. The codeset provider may not be up to date on all the
latest codes.
I'll add the following to the SRFI's "Examples" section since it works
out of the box without imposing any changes on the SRFI, or on codeset
providers.
(define-enumeration errno
(EPERM ...)
errno-set)
(codeset-message 'errno (errno EPERM))