[erlang-questions] How about a new warning? Was: Re: trouble with erlang or erlang is a ghetto

Sam Bobroff <>
Wed Aug 3 02:52:55 CEST 2011

Hello all,

I'll put in my $0.02 on this because I've just been bitten by a bug that
would have been caught by this new warning. I'll stick to the point:


>  2. Is matching against an already-bound variable a check we want?


Yes, because it protects against a kind of bug that is otherwise very easy
to introduce in Erlang:

Quite often when debugging I want to add a new line or two to a function, to
examine or check an intermediate value. e.g.:

 Result = function_call(),

The problem is that I now have to scan down the whole rest of the function
just in case Result has already been used because, if it has, then it's
going to compile fine and cause a run time error!

It's such a simple scenario that it seems very annoying that Erlang can't
help me to avoid it. The "cost" of not being able to do a "backwards"
assignment with the newly bound variable on the right doesn't seem like a
cost at all: I find code that is that way round, or mixes assignments on the
left and right (!) to be unnecessarily confusing. I'd be happy if this was
required by the language but as this is the real world I'd be happy with a
warning I could turn on.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110803/f9fefa5d/attachment.html>

More information about the erlang-questions mailing list