3 ms·
https://erlang.org/doc/programming_examples/bit_syntax.html https://erlang.org/doc/programming_examples/bit_syntax.html > say sendSeq was one bit but we still
by Jtsummers 5y ago
https://erlang.org/doc/programming_examples/bit_syntax.html https://erlang.org/doc/programming_examples/bit_syntax.html
> say sendSeq was one bit but we still wanted it to take 3 bits:
> [0] ++ pad 3 sendSeq ++ poll ++ recvSeq
In Erlang you could do this to get something padded (or truncated) to the correct size:
<< 2:3 >> ;; corresponds to the 3 bits <<010>>
So you can do something like this to ensure the precise bit size of each field:
<< 0:1, SendSeq:3, Poll:3, RecvSeq:3>>
- voidnullnil 5y agoYaeh, my point was that it is trivial to define a pad function and call it instead of needing some syntax like Erlang. But now I see there is deconstruction too, which is more arguably useful to take the time to add syntax for.