Open kenseehart opened 4 years ago
This may be best implemented with an additional abstraction layer because there are advantages to the assumption of fixed size fields, such as immutability of allocation (even when unions are involved).
Perhaps there is synergy with bit streaming. We can use a fixed size union or array with a header, then based on content decide the number of bits to actually consume from the bitstream buffer.
Many applications involve variable length arrays and various kinds of variable length encodings.
A mechanism for dynamic field reallocation would support these.
struct( num_parrots = uint(5), parrots = parrot_struct['num_parrots'], )
Note that the reference to the
num_parrots
field is a string. This is necessary in any case because thenum_parrots
object is not in scope. But also, we want the value to be generalized to an expression.struct( num_parrot_dozens = uint(5), parrots = parrot_struct['num_parrot_dozens*12'], )
We need a way to explicitly distinguish between fixed allocation with hidden padding and variable allocation.