lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> int myFooFlags = FOO_BLUEPANTS | FOO_3PLANES | FOO_EDIBLE;

And why not:

'flags = FOO_BLUEPANTS + FOO_3PLANES + FOO_EDIBLE' ?

I don't really see where is the problem here. You can add a new bitfield type
as userdata with ease. Then just overload the '+' and '-' operators to act as
'|' and '-', so that '+' returns a new bitfield and '-' returns a boolean.

if flags-FOO_BLUEPANTS then
end

if flags-(FOO_BLUEPANTS+FOO_3PLANES) then
end

if flags-FOO_BLUEPANTS or flags-FOO_3PLANES then
end

In my opinion that doesn't look bad, but that's just matter of taste. If
there 's some interest I will write a simple module to implement that during
this week.


Ignacio Castaño
castanyo@yahoo.es


___________________________________________________
Yahoo! Móviles
Personaliza tu móvil con tu logo y melodía favorito 
en http://moviles.yahoo.es