How to do table lookups?
Matthias Lang
matthias@REDACTED
Sun Mar 7 02:39:32 CET 2004
In theory, the shell behaves the same way as a real Erlang program.
In practice, the shell has its own little interpreter for binary
pattern matching and that interpreter doesn't get all the error cases
quite right. Your example is one such case.
If you put it in a program, it'll give you the badmatch you asked for
go() ->
<<A:1, Rest/binary>> = <<255>>,
Rest.
----
1> mml:go().
** exited: {{badmatch,<<255>>},
Matthias (tried the above on R8B)
Vance Shipley writes:
>
> What the heck is this? Binaries must be a number of bits
> divisable by 8 however the example Edmund gave doesn't give
> an immediate error but instead returns siomething which
> actually isn't a binary!
>
> -Vance
>
>
> Erlang (BEAM) emulator version 5.3 [source] [threads:0]
>
> Eshell V5.3 (abort with ^G)
> 1> <<A:1, Rest/binary>> = <<255>>.
> <<255>>
> 2> A.
> 1
> 3> is_binary(Rest).
> false
> 4> Rest.
> {[1,1,1,1,1,1,1],
> 7,
> <<>>}
More information about the erlang-questions
mailing list