3 ms·
Regarding the use of integers as bit arrays, it would be nice if the syntax supported referring to a subset of the bits, similarly to bitfields in structs. Exa
by nitrogen 15y ago
Regarding the use of integers as bit arrays, it would be nice if the syntax supported referring to a subset of the bits, similarly to bitfields in structs.
Example based on the syntax from the article:
x: int<+32>;
x[0:6] = 42; // Set six bits starting with lsb 0 to 42
- slashvar 15y agoYes, this is in the TODO list ;) In fact, it doesn't reach top priority since we can do without for now (we have bitfields.) The issue with slicing is more a question of design: does slicing need to be constant expression or should we authorize more expression power (and then how could we implement that and how could we check it … ) Anyway, I'm looking for a clever way to define values accessed in a none uniform ways. Integer as bit array was the simplest idea to test (and seems useful to me.) Now the compiler has almost everything I need to implement easily that kind of syntactic sugars.