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

Robert Virding <>
Sun Jul 27 16:23:14 CEST 2008


2008/7/27 YC <>

>
> 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.
>>
>>
> There is a way to satisfy this request without breaking single assignment,
> and that is to have a more sophisticated scoping.
>
> For example, the above in lisp/scheme are:
>
> (let ((t (something t)))
>   (let ((t (something t)))
>      (let ((t (something t)))
> ...)))
>
> No mutabilities involved - just better scopes - can't be that bad for
> Erlang, right? ;)
>

Shameless plug:

Well you can do this today if you use LFE. Plus ti gives you a lot of other
lisp goddies as well.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080727/7f08a2a6/attachment.html>


More information about the erlang-questions mailing list