defcenum with non-integer base-type
Attila Lendvai
attila at lendvai.name
Wed Feb 24 20:00:05 UTC 2016
>> What would we gain from being a bit more draconian about the base type?
>
> We gain being standards-compliant. A C enum is an int, period.
i kinda agree.
but on the other hand:
it's pretty useful where i've seen it in the wild, in cl-glu: there
are a bunch of #define's with increasing values, and a function that
accepts those values, but in a double typed argument. with a relaxed
defcenum, or equivalent, one can continue using the automatic
keyword-symbol->value mapping.
maybe add another, more relaxed costruct? a cffi:defenum?
but on the other hand is the added complexity worth it? is a use-case
like this frequent enough to warrant it?
this all more or less boils down to the following fundamental
question: should CFFI try to mirror the C standard on the lisp side?
or should it be more permissive where the cost of being permissive is
low (e.g. in introducing latent bugs or other programmer surprises)?
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“When buying and selling are controlled by legislation, the first
things to be bought and sold are legislators.”
— P.J. O'Rourke (1947–)
More information about the cffi-devel
mailing list