Can pattern variables be globally bound?

Roger Price rprice@REDACTED
Sat Mar 25 14:32:24 CET 2006


The following program:

-module(test) .           %  1
-export([test/1]) .       %  2
test (X) ->               %  3
  case X*10               %  4
  of 0 -> a               %  5
  ;  X -> b               %  6
  end .                   %  7

compiles with no warnings, and provides the following output:

Eshell V5.4.9  (abort with ^G)
1> test:test(0) .
a
2> test:test(1) .

=ERROR REPORT==== 25-Mar-2006::14:20:45 ===
Error in process <0.31.0> with exit value: 
{{case_clause,10},[{test,test,1},{shell,exprs,6},{shell,eval_loop,3}]}

My understanding of the error message is that the pattern variable X on 
line 6 is already bound to the value 1, and therefore no match is possible 
for value 10.  Is this correct?

Roger



More information about the erlang-questions mailing list