Let's say I want to override clojure.core/sorted?

(ns random.learning.clojure.overridex
  (:refer-clojure :exclude [sorted?]))

(defn sorted? [coll]
  {:pre [ (coll? coll)]}
  (clojure.core/sorted? coll))

I'm using Eclipse+counterclockwise, so loading this namespace(Ctrl+Alt+L)
first time gives no warnings/errors, loading it second time, one warning
and no errors, and subsequent times it's loaded there are no
errors/warnings.

the warning is this:
WARNING: sorted? already refers to: #'clojure.core/sorted? in namespace:
random.learning.clojure.overridex, being replaced by:
#'random.learning.clojure.overridex/sorted?

I could ignore the warning, no problem, but then I try to use this
namespace in another namespace:

(ns random.learning.clojure.usetheoverridexns
  (:use random.learning.clojure.overridex)
  )

(and
  (= false (sorted? '(1 2)))
  (= true (sorted? (sorted-set 1 2))))


When I load this namespace first time I get:
WARNING: sorted? already refers to: #'clojure.core/sorted? in namespace:
random.learning.clojure.usetheoverridexns, being replaced by:
#'random.learning.clojure.overridex/sorted?
true
I could ignore that, but then I load it again(and any subsequent time) and
this is an error (not just a warning that can be ignored):

IllegalStateException sorted? already refers to:
#'random.learning.clojure.overridex/sorted? in namespace:
random.learning.clojure.usetheoverridexns
clojure.lang.Namespace.warnOrFailOnReplace (Namespace.java:88)

Notice there's no "true" aka return value.

When I actually close the REPL, and Ctrl+Alt+L load only this latter
namespace I get this:

;; Clojure 1.5.0-RC16
;; Switching to random.learning.clojure.usetheoverridexns namespace
WARNING: sorted? already refers to: #'clojure.core/sorted? in namespace:
random.learning.clojure.usetheoverridexns, being replaced by:
#'random.learning.clojure.overridex/sorted?
true
*IllegalStateException sorted? already refers to:
#'random.learning.clojure.overridex/sorted? in namespace:
random.learning.clojure.usetheoverridexns
clojure.lang.Namespace.warnOrFailOnReplace (Namespace.java:88)*


and any subsequent loads, show only the part in bold.

 While this may be some ccw issue, I am probably also doing something wrong
that I could be doing better.
 What is the way to do this? especially in the latter namespace which is
using the namespace which has overridden the sorted?
 I do want the overridden "sorted?" to actually be available and override
the clojure.core/sorted? in any namespaces that are using the overridex
namespace.


Thank you.

-- 
Please correct me if I'm wrong or incomplete,
even if you think I'll subconsciously hate it.

-- 
-- 
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/groups/opt_out.


Reply via email to