On Mon, Apr 19, 2010 at 12:15 PM, falcon <shahb...@gmail.com> wrote:
> As I understand it, map is, itself, lazy. Does that mean that using
> map to implement these methods would create extra intermediate
> structures?

Yes.

> What if often used functions such as map/reduce/filter were macros,
> that could 'deforest' (to use Haskell terminology) these intermediate
> structures?  Implementing all these functions on top of each other
> wouldn't create any extra overhead then.

That would involve code walking macrology. That is notoriously fragile
for something like this.

GHC uses rewrite rules for deforestation in Don and Duncan's byte
streams library. Rewrite rules need to be applied after inlining to be
useful for deforestation. That's part of the reason they're integral
parts of GHC's compilation pipeline rather superficial preprocessors.

Macros are not the right tool.

-Per

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to