Binary list pattern maching direction?

Kenji Rikitake kenji.rikitake@REDACTED
Thu Dec 17 03:06:06 CET 2009


I've been using the following Erlang binary list matching pattern for
quite a while.

Actually, this piece of code below as a shell command sequence is
originally from ssh_sftpd.erl in the ssh module of R13B02 (and maybe
later).

My question:

* The variables on the left-hand side of the matching operator (=) match
  from left to right.  Is this guaranteed or documented anywhere in
  Erlang reference manual(s)?
  
Answers or references appreciated.

-- begin --

2> <<Len:32/unsigned-big-integer, Msg:Len/binary, Rest/binary>> = <<0,0,0,5,10,11,12,13,14,15,16,17>>.
<<0,0,0,5,10,11,12,13,14,15,16,17>>
3> Len.
5
4> Msg.
<<10,11,12,13,14>>
5> Rest.
<<15,16,17>>

-- end --

Kenji Rikitake




More information about the erlang-questions mailing list