[erlang-questions] Generators?

Thomas Lindgren thomasl_erlang@REDACTED
Tue Jul 31 19:55:26 CEST 2007


--- tsuraan <tsuraan@REDACTED> wrote:

> >
> > I think the point tsuraan is making here (correct
> me if I'm wrong,
> > tsuraan) is that the combination of prebuilt
> abstractions (zipwith and
> > sum (or more generally, fold)) is more desirable
> than a hand-coded
> > explicitly recursive function because the
> abstractions are more
> > 'functional style' (something I would agree
> with--in other communities
> > (Haskell coming to mind), it is strongly
> encouraged to use common
> > abstractions, even to the point where using
> explicit recursion is
> > sometimes discouraged). But the problem is that
> these abstractions, or
> > at least the combination of them, are slower than
> a hand-coded
> > function explicit recursion function. So, is there
> any way to make the
> > natural abstractions work as fast as the
> hand-coded version?
> >
> > Bryan
> >
> 
> Yeah, that's the question I'm going for :)

Creating local copies of higher-order functions and
plugging in function arguments can be very effective,
and a suitable optimizer can easily do it
automagically (see my paper in EUC 2001 for an
example; it appears that the beam compiler can do it
too nowadays). Doing this can sometimes yield
satisfying integer speedups on real code.

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.

Best,
Thomas



       
____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/



More information about the erlang-questions mailing list