News for hackers. Stuff that matters.
Re:A Bit Overcomplicated by Jtsummers on Thursday August 05, 2021 @03:44PM (#28078583)
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>>
Re:A Bit Overcomplicated by voidnullnil on Friday August 06, 2021 @12:11PM (#28089148)
Yaeh, 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.