I am wondering how pattern matching is usually implemented. for example in Erlang do you think its implemented at the byte-code level( there\'s a byte-code for it so that it
The best thing I can suggest is to compile up some test functions and have a look at the generated code.
erlc -S test.erl
generates test.S which is fairly readable.
To answer the question, pattern matches are built up in an efficient way from more primitive operations. Here's part of the code from a function clause matching {X, [H|T]}.
{test,is_tuple,{f,1},[{x,0}]}.
{test,test_arity,{f,1},[{x,0},2]}.
{get_tuple_element,{x,0},0,{x,1}}.
{get_tuple_element,{x,0},1,{x,2}}.
{test,is_nonempty_list,{f,4},[{x,2}]}.