[erlang-questions] Generators?

Richard Carlsson richardc@REDACTED
Tue Jul 31 23:06:20 CEST 2007


Thomas Lindgren wrote:
> It seems quite feasible to take this approach further,
> though. In particular, compositions of several
> higher-order functions could also be turned into
> specialized code and optimized in various ways. For
> Haskell, this has been explored in the context of
> deforestation (e.g, "A Shortcut to Deforestation").
> The equivalent still remains to be done for Erlang.

We had a couple of students implement the S. to D. (or if it was plain
old Deforestation... my memory fails me), but their results were not
very encouraging, and I had no time to try to improve on their work.

It's hard to find existing real code where deforestation gives an
improvement. The problem is generally that the producer and consumer
code tends to be too far away from each other, so the optimization can
rarely (read "never") be applied.

It could be argued, though (and I would agree), that Deforestation is an
optimization that simply _should_ be available in the compiler, so that
you can rely on it when you write your code. If anyone (perhaps Thomas,
in his proverbial Copious Spare Time) could implement it as a compiler
pass on the Core Erlang level, I would applaud them. I might even be
able to dig up the student project source code from my archives if that
would be of use.

    /Richard



More information about the erlang-questions mailing list