Binaries Mapping

Binaries in Hamler are imported from Erlang. The Bit Syntax Expressions in Erlang are defined as below:

  1. <<>>
  2. <<E1,...,En>>
  3. Ei ::= Value
  4. | Value ":" Size
  5. | Value "/" TypeSpecifierList
  6. | Value ":" Size "/" TypeSpecifierList

The Bit Syntax in Hamler is a bit different from Erlang, that ‘/‘ is replaced with ‘:’:

  1. <<>>
  2. <<E1,...,En>>
  3. Ei ::= Value
  4. | Value ":" Size
  5. | Value ":" TypeSpecifierList
  6. | Value ":" Size ":" TypeSpecifierList

Binaries in Hamler:

  1. <<127,0,0,1>>
  2. <<"ABC">>
  3. -- Binary Pattern Match
  4. <<bigI:16:Big-Unsigned-Integer>> = <<1,2>>
  5. <<litI:16:Little-Signed-Integer>> = <<1,2>>

Binaries in Erlang:

  1. <<127,0,0,1>>
  2. <<"ABC">>
  3. <<1:16,2:4,3:4>>
  4. -- Binary Pattern Match
  5. <<X:3,Y:5,Z:8>> = <<1,0>>
  6. <<BigI:16/big-unsigned-integer>> = <<1,2>>
  7. <<LitI:16/little-signed-integer>> = <<1,2>>