[erlang-questions] Reassigning variables

James Hague james.hague@REDACTED
Thu Mar 19 18:18:08 CET 2009

I'm not surprised to see the storm that this has started.  But after
having taken the deep dive into Erlang for decidedly non-traditional
FP applications (see http://prog21.dadgum.com), here's what I've

For some types of programs, it takes significantly less effort to
write code if you can re-use names within the same function.

I'm not saying it's the most elegant solution or the the easiest to
reason about, but it's hands-down the most straightforward to write.
Quite often I find I could bang-out code quickly given the ability to
"destructively update variables," but trying to craft it without such
an ability results in code that takes extra time to write and is
usually much more sensitive to slight changes in the problem
definition.  I don't think that flatly denying this does any good.
All it does is make Python and Ruby look very attractive in some

You can ALREADY simulate imperative updates using function calls (see
http://prog21.dadgum.com/5.html).  Adding some syntactic sugar to make
this easiest is a good thing.

Now remember, there's still NO need to add "for" loops and "while"
loops to Erlang.  But re-using names within the same function?  Yes
please, providing it can be done in a clean way; I realize it can
conflict with pattern matching if not done correctly.


More information about the erlang-questions mailing list