[erlang-questions] widefinder update
Matthias Lang
matthias@REDACTED
Mon Oct 29 18:02:36 CET 2007
Anders Nygren writes:
> > > -The compiler should treat don't care variable (_Var) the same
> > > as (_), and not bind them.
Careful here, it's possible to interpret what you wrote in ways which
lead to incorrect reasoning about programs.
_Var is not the "don't care" variable in general. As far as observable
behaviour goes, _Var *is* bound and the compiler is not allowed to not
bind variables of that form in general. Some examples where the
difference is observable:
46> f(), <<_A, _B>> = <<1,2>>.
<<1,2>>
47> f(), <<_A, _A>> = <<1,2>>.
** exited: {{badmatch,<<1,2>>},[{erl_eval,expr,3}]} **
48> f(), <<_, _>> = <<1,2>>.
<<1,2>>
Variables longer than one character starting with an underscore are
special in only one way: they suppress a warning.
Naturally the compiler is free to optimise away variables which aren't
used.
Matthias
More information about the erlang-questions
mailing list