On Thu, May 5, 2011 at 4:16 PM, Alan <a...@malloys.org> wrote: > (let [fnmaker4 (fn [coll] (fn [n] (nth coll n))) > ints (range)] > (= (fnmaker4 ints) (fnmaker4 ints))) > > You want to make it impossible to compare functions that close over > infinite sequences? What is the point of being able to compare > functions if there are cases in which using the functions will > succeed, and the existing comparison strategy would not cause errors, > but your new proposal does?
Hm, that is a problem. You'd need to compare not the sequences, but their generator functions. :) > Similarly, if you try to eval such a function, your proposed function- > eval semantics would, as I understand it, store its closed-over values > in a class constant somewhere. Then there's some secret place holding > onto the head of my lazy sequences for me? No thanks. Your fnmaker4 already holds onto the head of ints, above, so that this: user=> (def q (fnmaker4 (iterate inc 0))) #'user/q user=> (q 119) 119 user=> (q 0) 0 can work properly. Externalizing of lazy sequences that are potentially infinite does present a complex issue, though. One option is to not allow it. (Right now, I think it will actually try to write out an infinite sequence to disk and eventually run out of filesystem space if you use prn or something.) Another is to try to output not the sequence, but code that will reconstruct the sequence, which means being able to externalize the function references involved. :) -- 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