You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For parsing some formats it's necessary to consult the bits of a value. For example in hvif there are flags in gradients that indicate the size of the colours in the steps of the gradient.
The advanced way to handle this might be with bit-sized types or erlang-style bit patterns.
In cases where you just want flag bits you could have bitfield syntax that just desugars into bitwise ops. Something like flags: u8 bits { foo, bar, etc. } where flags.foo is equivalent to flags & mask.
Full disclosure: I copied a bunch of this from chat logs, so credit to the original authors for the content.
The text was updated successfully, but these errors were encountered:
For parsing some formats it's necessary to consult the bits of a value. For example in hvif there are flags in gradients that indicate the size of the colours in the steps of the gradient.
The advanced way to handle this might be with bit-sized types or erlang-style bit patterns.
kaitai has done some interesting prior work on the former: https://doc.kaitai.io/user_guide.html#_bit_sized_integers as has Zig: https://andrewkelley.me/post/a-better-way-to-implement-bit-fields.html
A simpler option could be bitwise primitive ops.
In cases where you just want flag bits you could have bitfield syntax that just desugars into bitwise ops. Something like
flags: u8 bits { foo, bar, etc. }
whereflags.foo
is equivalent toflags & mask
.Full disclosure: I copied a bunch of this from chat logs, so credit to the original authors for the content.
The text was updated successfully, but these errors were encountered: