2012/2/21 Meikel Brandmeyer <m...@kotka.de> > 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. >
Trying to extrapolate the example just a little bit, I can see that with this solution it may then be up to every kid of form containing an ::fn form to know it should stop propagating ::fn constants. The next step would probably to have separate policies for aggregating constants at one node, and exporting constants to enclosing nodes. A ::fn node would aggregate all exported constants from its children nodes, but export none. But maybe it's just me trying to extrapolate too much. > > 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 > -- 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