[erlang-questions] Simple Erlang Recommendation (last returned value)

James Hague <>
Sat Jul 26 23:17:10 CEST 2008


> Imagine this:
>
> X = tl(L),
> ... many messy lines ...
> *X = tl(X),
> ... another many lines ...
> *X = tl(X),
> ... another many almost unreadable messy lines ...
> sensitive_usage(X), % <--- buggy X value observed here
>
> And my question is, where Value of X came from? It goes from L, but how long
> it take and how many errors you can do when you will investigate?

It's just as bad when there's code like this:

T2 = something(T),
T3 = something(T2),
T4 = something(T3),
T5 = something(T4),
T6 = something(T5)

You may laugh at that code, but it's hardly uncommon, even in code
written by experienced programmers.  It's very easy to accidentally
use T4 in a spot when you meant T3, or to have to renumber things and
make a mistake.

Please note that I am not arguing for changes in Erlang.  I truly am
not.  But I can understand why this request comes up regularly.

James



More information about the erlang-questions mailing list