Noob - Getting Started Infinte Loop?

Lennart Ohman lennart.ohman@REDACTED
Thu Aug 31 10:24:32 CEST 2006

the _ (only an underscore) is never bound from efficiency
reasons. For instance:

f(foo,bar) -> ...;
f(frotz,X) -> ...;
f(_,X) -> ....

could be used to indicate in the third clause that Erlang
should not spend time on binding the first argument to a
variable since it will not be used. Actually, if you replace
the third head with f(DontCare,X) -> you will get a compiler
warning. The compiler suspects that you misspelled that variable
name, and it should be one you actually use in the body.

Then you have the possibility of placing an _ in front of
a variable name. Like _dontCare. That will actually make the
variable bound and possible to use (however good Erlang practise
says you shouldn't). The underscore removes the compiler
warnings in this case.

Best Regards

Lennart Ohman                   office  : +46-8-587 623 27
Sjoland & Thyselius Telecom AB  cellular: +46-70-552 67 35
Sehlstedtsgatan 6               fax     : +46-8-667 82 30
SE-115 28, STOCKHOLM, SWEDEN    email   : lennart.ohman@REDACTED

> -----Original Message-----
> From: owner-erlang-questions@REDACTED [mailto:owner-erlang-
> questions@REDACTED] On Behalf Of fbg111
> Sent: Thursday, August 31, 2006 12:58 AM
> To: erlang-questions@REDACTED
> Subject: Re: Noob - Getting Started Infinte Loop?
> ke han wrote:
> >
> > 3 - Also, for efficiency sake, you should name the variable "First"
> > as "_First" to indicate you do not want the value bound.
> >
> I was under the impression so far that all variables in Erlang are bound,
> unless 'bound' means something other than you can't change the value of a
> variable after assignment?  Thanks!
> --
> View this message in context:
> Started-Infinte-Loop--tf2189189.html#a6069968
> Sent from the Erlang Questions forum at

More information about the erlang-questions mailing list