enum-set-unfold
Amirouche Boubekki
(20 Sep 2020 18:35 UTC)
|
Re: enum-set-unfold
John Cowan
(20 Sep 2020 18:55 UTC)
|
Re: enum-set-unfold Wolfgang Corcoran-Mathe (20 Sep 2020 19:09 UTC)
|
Re: enum-set-unfold
John Cowan
(20 Sep 2020 21:56 UTC)
|
Re: enum-set-unfold
Wolfgang Corcoran-Mathe
(20 Sep 2020 23:50 UTC)
|
Re: enum-set-unfold Wolfgang Corcoran-Mathe 20 Sep 2020 19:09 UTC
On 2020-09-20 14:55 -0400, John Cowan wrote: > It seems kind of specialized. You can take apart the bits with SRFI 151, > then map ordinal->enum over them and pass that to list->enum-set. > > On Sun, Sep 20, 2020 at 2:35 PM Amirouche Boubekki < > xxxxxx@gmail.com> wrote: > > > Does it make sense to have such a procedure that will build an > > enum-set from an integer that is in fact the logior of several > > ordinals? If I understand Amirouche correctly, the idea is that we provide some way to take an unsigned integer encoding the combination of several enums to an enum-set, e.g. (bitwise-ior 1 2 4 8) -> {<enum 1>, <enum 2>, <enum 4>, <enum 8>}, with the obvious inverse operation. This might be useful for translating between C-style "flag" combinations and enum-sets. There is a serious bit of awkwardness, though, in that these integers can only encode combinations of enums with ordinals equal to 2^n for some n. We'd need to allow enum-types to have "gaps" (i.e. enums for certain ordinals only), and the conversions would be partial--enum-sets containing enums with invalid ordinals would be rejected, as would many integers. Amirouche, please correct me if I've misunderstood anything. -- Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz> "Prolonged contact with the computer turns mathematicians into clerks and vice-versa." --Alan J. Perlis