Re: Safe enumerations for codesets
Marc Nieper-WiÃkirchen 14 Dec 2022 18:26 UTC
Am Mi., 14. Dez. 2022 um 13:42 Uhr schrieb Lassi Kortela <xxxxxx@lassi.io>:
>
> > You don´t write (define-enumeration <errno> ...) but
> > (define-enumaration errno (EPERM ...) errno-set).
> >
> > Then (errno EPERM) => 'EPERM (with compile-time checking whether EPERM
> > is allowed!)
>
> I see. That works out well (with no changes to the SRFI):
>
> (define-enumeration errno
> (EPERM
> ENOENT
> ESRCH
> EINTR
> EIO
> ENXIO
> E2BIG
> ENOEXEC
> EBADF
> ECHILD
> EDEADLK
> ENOMEM
> EACCES
> EFAULT)
> errno-set)
>
> (codeset-message 'errno (errno ENOENT))
>
> The only problem is that the name of the set, 'errno, is still quoted.
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).