Hi,

Am 21.02.2012 um 22:56 schrieb Aaron Cohen:

> One complication I'm not sure about is nested fns.
> 
> I'm typing the following in my email client, so forgive any typos...
> 
> For instance: {:op :fn, :children [{:op fn, :children [{:op :constant,
> :form 1}]}, {:op :constant, :form 2}]}
> 
> Does your solution result in the top level getting both constants?
> Unfortunately, my specification didn't mention that, but each fn acts
> as a level of scope for the constants, they shouldn't dribble out to
> the top.

At the moment they do. But it's easy to filter out ::fn's.

(defmethod collect-constants ::recursive
  [{:as form :keys [children]}]
  (->> children
    (filter #(-> % :op (= ::fn)))
    (map :constants)
    (reduce into #{})
    (assoc form :constants)))

This breaks the chain of constant propagation at nested ::fn forms.

Meikel

-- 
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