On Tue, Dec 9, 2008 at 7:05 PM, Rich Hickey <[EMAIL PROTECTED]> wrote: > > Thanks. I think it does a bit too much - I only want to relax the > requirement for namespace-qualification, not any of the other > assertions (e.g. that the participants are either Named or Classes, > can't be = etc).
Right, that makes sense. I believe this new patch is closer to what you are looking for. It moves the namespace checks for both tag and parent to the two argument case and keeps the not=, class? or Named checks in the three argument case. A couple tests: kant[~/src/clojure]$ iclj 1:1 user=> (derive :child :parent) java.lang.Exception: Assert failed: (namespace parent) (repl-1:1) 1:2 user=> (derive (make-hierarchy) :child :parent) {:parents {:child #{:parent}}, :ancestors {:child #{:parent}}, :descendants {:parent #{:child}}} 1:3 user=> (derive 1 :parent) java.lang.Exception: Assert failed: (namespace parent) (repl-1:3) 1:4 user=> (derive (make-hierarchy) 1 :parent) java.lang.Exception: Assert failed: (or (class? tag) (instance? clojure.lang.Named tag)) (repl-1:4) Is this better? - J. --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---
Index: src/clj/clojure/core.clj =================================================================== --- src/clj/clojure/core.clj (revision 1149) +++ src/clj/clojure/core.clj (working copy) @@ -3041,12 +3041,15 @@ child can be either a namespace-qualified symbol or keyword or a class. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to, and modifies, the global hierarchy." - ([tag parent] (alter-var-root #'global-hierarchy derive tag parent) nil) + ([tag parent] + (assert (namespace parent)) + (assert (or (class? tag) (and (instance? clojure.lang.Named tag) (namespace tag)))) + + (alter-var-root #'global-hierarchy derive tag parent) nil) ([h tag parent] (assert (not= tag parent)) - (assert (or (class? tag) (and (instance? clojure.lang.Named tag) (namespace tag)))) + (assert (or (class? tag) (instance? clojure.lang.Named tag))) (assert (instance? clojure.lang.Named parent)) - (assert (namespace parent)) (let [tp (:parents h) td (:descendants h)