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
I often have the need to pattern match binaries on dynamic sizes. Currently this is not possible in alpaca (which gives {invalid_bin_qualifier,<<"s">>})
An example:
let s = 5 in
match bin with
<<x: type=binary unit=8 size=s, rest: type=binary>>
I think it would make sense to have the size being expressed as any expression returning an integer.
BEAM does not support having a variable length for any chunk except the last even if it can be easily calculated manually by subtracting the size of the binary and the size of the last chunk. You may be misremembering that.
iex(5)><<x::binary,rest::binary-size(2)>>="foobarbaz"**(CompileError) iex:5: a binaryfieldwithoutsizeisonlyallowedattheendofabinarypatternandneverallowedinbinarygenerators
I often have the need to pattern match binaries on dynamic sizes. Currently this is not possible in alpaca (which gives
{invalid_bin_qualifier,<<"s">>}
)An example:
I think it would make sense to have the size being expressed as any expression returning an integer.
Tested with alpaca 620b9fa
The text was updated successfully, but these errors were encountered: