bad match question

Francesco Cesarini (Erlang Training & Consulting) francesco@REDACTED
Tue Jun 7 17:30:45 CEST 2005


Hi Charles,

it has to do with the properties of Erlang. Matching is used for three 
things,

* Assignment
* Comparison for choice of branch in function / case / receive clauses
* Extraction of data from complex data types

In your example, the first instance is assignment, the second is 
comparison. And crashing when a match in a function clause fails is 
Erlang's semantical behavior.

A possibility would be a compiler warning (Many were added in R10), but 
the code should still compile and execute.

Regards,
Francesco
--
http://www.erlang-consulting.com

Charles Blair wrote:
> i'm curious why the bad match here isn't caught until runtime:
> 
> -module(test).
> -compile([export_all]).
> 
> start() ->
>   Test = [a, b, c],
>   Test = [1, 2, 3].
> 
> thanks.
> 
> 




More information about the erlang-questions mailing list