[cffi-devel] defenum proposal

Luís Oliveira luismbo at gmail.com
Sun Jan 22 15:56:45 UTC 2006


On 2006-jan-22, at 14:47, Frank Buss wrote:
> It is not necessary to use keywords like for the named enums, because
> unnamed enums in C are just syntatic sugar for a list of  
> "#define"s, which
> is mapped to a list of defconstants. I don't know, if this macro  
> fits in the
> philosophy of CFFI, perhaps in some utility class, and maybe with  
> another
> name "defanonenum".

I don't really think of C's enum that way. If I want constants, I use  
#define (and defconstant in CL). If I want to represent some sort of  
entity or concept I use an enum (and symbols in CL). For example:

   #define MAX_COUNT 127

   (defconstant +max-count+ 127)

vs.

   enum {
     RED,
     BLUE
   };

   :red, :blue (or 'red, 'blue)

I suppose defcenum shouldn't force the user to use keywords though?

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/
Equipa Portuguesa do Translation Project
http://www.iro.umontreal.ca/translation/registry.cgi?team=pt




More information about the cffi-devel mailing list