[erlang-questions] Compiler list comprehension optimizations
Fri Jun 14 11:16:45 CEST 2013
First, I don't think this is done today.
Second, it's a difficult issue in the general case. Unlike Haskell, Erlang is a strict language, so if you're a stickler for having the program behave the same before and after optimization, you will see that, in the general case, you run a risk of getting different answers if you reorder computations that way. For example, a different exception or different side effects could be generated in the new program. Ensuring the optimization is safe can quickly get intractable to a compiler. (So in practice it might be applied only in rare or simplistic cases.)
With that said, I think it could be interesting to investigate this optimization further, perhaps simply by being more relaxed about such issues. It can obviously yield great results in Haskell.
> From: Jonathan Leivent <jleivent@REDACTED>
>Another question about list comprehension optimizations: If a list
>being iterated over is generated from a function that just builds the
>list element-wise, can the compiler inline that function so that the
>intermediate list isn't built?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions