the problem of using _Var instead of _

Bengt Kleberg <>
Fri Mar 4 08:21:39 CET 2005


greetings,

i have been tought(sp?) that it is better to use _Var than _ when 
ignoring parts of a pattern match. the reason beeing that i get a small 
amount of documentation, but still reap the benefits of ignorance :-)

the advice is sound. i have used it for four years without problem. then 
today i had (equivilent of) the following pattern in a function head:

fun( [H1|_T], [H2|_T] ) ->
{H1, H2}.

and it crashed with {function_clause,...}. however this works:

fun( [H1|_], [H2|_] ) ->
{H1, H2}.

so i would like to mention that _Var is almost, but not entirely, 
totally unlike _ .


as an aside: i thought of putting this somewhere on the trapexit forums 
(to avoid sending senseless ramblings to the mail list). however, there 
is no ''common mistakes'' or ''gotchas'' in the forum.
perhaps there should be?


bengt



More information about the erlang-questions mailing list