> You can however make up some namespace and use it throughout your code, so > instead of ::foo, you'll use :my-ns/foo. This namespace don't have to > the current or even a real one.
Interesting. I had no idea. Thank you for that tip. On Saturday, August 9, 2014 4:02:36 PM UTC-4, Jozef Wagner wrote: > > If you want keywords to participate in a multimethod hierarchy, you must > qualify them. > > You can however make up some namespace and use it throughout your code, so > instead of > ::foo, you'll use :my-ns/foo. This namespace don't have to the current or > even a real one. > > Jozef > > On Saturday, August 9, 2014 9:49:58 PM UTC+2, larry google groups wrote: >> >> Thank you for the responses. However, when I look here: >> >> http://clojure.org/multimethods >> >> I see that it says: >> >> "You can define hierarchical relationships with (derive child parent). >> Child and parent can be either symbols or keywords, and must be >> namespace-qualified" >> >> Is there any way I can establish a hierarchical relationship without it >> being name-spaced qualified? I would like to be able to (slingshot/throw+ >> {:type some-symbol}) and have this be caught in a different namespace, but >> I need a way to match the some-symbol, and I would ideally like it if >> some-symbol >> might be part of a hierarchy, such that I'm matching again some-symbol's >> parent. >> >> Is that possible? >> >> I guess I could hard-code all of the namespaces, such that the symbols >> are all: >> >> some-namespace/some-symbol >> >> but that does great reduce the flexibility of the system. >> >> >> >> >> >> >> On Saturday, August 9, 2014 3:30:33 PM UTC-4, James Reeves wrote: >>> >>> Jozef is correct, but to give some examples: >>> >>> (ns example.core >>> (:require [example.other :as other])) >>> >>> (= ::foo :example.core/foo) >>> (= ::other/foo :example.other/foo) >>> >>> (not= :foo :example.core/foo) >>> (not= :example.core/foo :example.other/foo) >>> (not= :other/foo ::other/foo) >>> >>> - James >>> >>> >>> >>> On 9 August 2014 19:14, Jozef Wagner <jozef....@gmail.com> wrote: >>> >>>> Keep in mind that :: is just a syntax sugar that is processed by the >>>> reader, before the compiler kicks in. ::foo is a shorthand for >>>> :your.current.ns/foo. Its purpose is to make it easy to create keywords >>>> that do not clash with other ones. >>>> >>>> Keywords are equal (and identical) only when both of their namespaces >>>> and names are equal. :ns1/foo is thus not equal to :ns2/foo, nor to just >>>> :foo. :: is used in cases where you want to exploit this important >>>> property of keywords, so that your keyword won't e.g. clash with other >>>> keywords in a collection, contents of which you don't know. >>>> >>>> Jozef >>>> >>>> >>>> On Saturday, August 9, 2014 7:46:45 PM UTC+2, larry google groups wrote: >>>>> >>>>> Please forgive this stupid question, but I'm still trying to >>>>> understand exactly what the double "::" means. I have read that I can use >>>>> (derive) to establish a hierarchy and I can imagine how this would be >>>>> useful for things like throwing errors and catching them and logging, but >>>>> I've also read that "::" adds the namespace to the symbol, so I would >>>>> assume that I can not match ::logging from one namespace with ::logging >>>>> from another? >>>>> >>>>> I'm thinking of this especially in my use of Slingshot, where I was >>>>> thinking of doing something like: >>>>> >>>>> (throw+ {:type ::database-problem :message "something wrong in the >>>>> database query"}) >>>>> >>>>> and then at a higher level in my code I was going to catch it with >>>>> something like: >>>>> >>>>> (derive ::database-problem ::logging) >>>>> >>>>> and then using Dire: >>>>> >>>>> (dire/with-handler! #'database/remove-this-item >>>>> [:type ::logging] >>>>> (fn [e & args] >>>>> (timbre/log (str " database/remove-this-item: The time : " >>>>> (dates/current-time-as-string) ( str e)))) >>>>> >>>>> but conceptually I am having trouble understanding how ::logging in >>>>> one namespace can match ::logging in another namespace. Perhaps I should >>>>> just use normal keywords? >>>>> >>>>> >>>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Clojure" group. >>>> To post to this group, send email to clo...@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+u...@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 unsubscribe from this group and stop receiving emails from it, send >>>> an email to clojure+u...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.