Why Erlang is the best concurrent language available
James Hague
jamesh@REDACTED
Fri Jan 24 16:26:35 CET 2003
Note! This completely off of the original subject! :)
Luke Gorrie wrote:
>But I reckon a seriously cool feature of the Erlang
>implementation is that you *can* build up a huge stack
>and unwind it if you want to, which tends to be pretty
>often for me. Consider the implementation of
>'map' from lists.erl:
>
> map(F, [H|T]) ->
> [F(H)|map(F, T)];
> map(_, []) -> [].
Ah, but technically that's tail recursive modulo cons (i.e. the only thing
keeping it from being tail recursive is that you need the result in order to
build a cons cell). If you were writing this in Scheme, you could keep a
pointer to the end of the list and the whole thing would be tail recursive
(and at least all of that nonsense would be hidden inside of map). Some
Prolog compilers do this automatically.
(I don't think Erlang desperately needs this--though sure, it would be
cool--but lack of this is something that might look 'horrifying' to someone
not used to writing code in functional languages.)
P.S. I still love how list comprehensions have made map obsolete:
map(F, L) -> [F(X) || X <- L].
More information about the erlang-questions
mailing list