lua-users home
lua-l archive

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


Rici Lake wrote:


I use bit operations for fairly long bit strings. Using bits in a number in order to compress a small number of "flags" into a single operation strikes me as an abuse both of flags and numbers, but that might be just me being a purist.

my major "number as bitset of flags" use is returning status codes from a function in c. since lua funcs can return mutiple values, and/or an ad-hoc table, it's not a normal usage case.

i would personally use a mutable buffer for the string of digits - give it a string constructor, __tostring() retriever, and have it return 0 for any out-of-range bits. it can auto-expand on bit set if required.
(i'm biased - i have such a buffer class)

Adrian