lua-users home
lua-l archive

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


Mark Meijer wrote:
Perhaps bit fields should be treated more as an opaque "type", only
allowing operations to set and clear specific bits by means of the
usual bitwise operators. This may be limiting in some ways, but it
probably also means much simpler semantics, and no unnecessary
conversion issues.

I'm afraid this could be too limiting: suppose you want to use bitwise operators to convert characters between different representations, or to manipulate table indexes, or to operate on values kept as integers in C/C++ structures, or simply to read/write values from/to files, etc.

At the very least, this opaque type should be convertable from/to integers at the least possible cost... which probably means just keeping it as integer and using (implicitly or explicitly) Mike's bit.tobit operator.

  Enrico