Ken Wesson <kwess...@gmail.com> writes: Hi Ken & Alan,
> Adding metadata to an object produces a new object, rather than > altering the existing object. Every time you increment the counter > for a function in p it becomes different, and the memoize treats it as > new. Then I've misread that statement on the homepage: An important thing to understand about metadata is that it is not considered to be part of the value of an object. As such, metadata does not impact equality (or hash codes). Two objects that differ only in metadata are equal > So, each time p-apply-memoized gets called with "the same" p, because > all the counters have been bumped, it's not actually the same p as far > as memoize is concerned, and so you don't get the benefits of > memoization anymore. Yes, now I got it. For the future, I should remember that I can put metadata only on symbols and collections (which the docs already state). > Solution: don't mess with the function metadata. Instead, use a global > map from fns to counts, or something. In fact, that was my first idea, but since I started doing clojure and functional programming last week, I always have a bad gut feeling when adding a global. And what would happen if I executed many p-applys in many threads? Most probably, I have to establish a `binding' in the entry function p-apply, right? Bye, Tassilo -- 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