defcenum with non-integer base-type

Stelian Ionescu sionescu at cddr.org
Wed Feb 24 20:28:38 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)?

CFFI should implement the C standard, and anybody who wants additional semantics can implement them. It's not like Lisp is insufficiently expressive for those who need it.
The number of users who will be confused by slightly different semantics will be much more than those who actually have an use for enums backed by doubles, or similar extensions. We've already made a big mistake with DEFBITFIELD being what it is now.

-- 
Stelian Ionescu a.k.a. fe[nl]ix
Quidquid latine dictum sit, altum videtur.



More information about the cffi-devel mailing list