AW: [cffi-devel] defenum proposal

Hoehle, Joerg-Cyril Joerg-Cyril.Hoehle at t-systems.com
Mon Jan 23 09:47:10 UTC 2006


Luís Oliveira wrote:
>I suppose defcenum shouldn't force the user to use keywords though?
Certainly not! Where would you get their value from if they are interned into the keyword package.

BTW, I think a SWITCH macro would be a useful companion to ENUM. It's CASE where you can put such things into the selector clauses.
Instead of
(case event-type
  (#.SDL-keyboard-event[-enum] (do-this)) ...
  ...
or
(cond
 ((if (eql event-type SDL-keyboard-event[-enum]) ...
 ((if ...
or
(cond
  ((if (enum-eq? event-type SDL-keyboard-event) ...)
  ...

BTW, I hate enums in Lisp and the explosion of constants etc. that they cause.

I'm not convinced DEFCONSTANT is appropriate.  Maybe all is needed is a mapping from name to values (and vice-versa, the CLISP FFI has it), and nice useable forms like the above SWITCH to hide ugliness.

BTW, DEFCONSTANT won't help with types like (:array :character MAX_PATH)
which once again, shows that it's not a good translation of C. It's just widespread.
(:array :character #.MAX_PATH) is also ugly, but I've never thought about finding something better.

FWIW, remember to wrap such uses of defconstant into EVAL-when also compile.

Regards,
	Jörg Höhle



More information about the cffi-devel mailing list