2010/6/3 Meikel Brandmeyer <m...@kotka.de> > Hi, > > Am 03.06.2010 um 21:51 schrieb Laurent PETIT: > > >> (in-ns 'some.other.namespace) > >> > >> (let [orig-x some-x] > >> (defn some-x > >> [foo] > >> (if (my-foo? foo) > >> (do-stuff foo) > >> (orig-x foo)))) > > > > Sorry Meikel, but I'm having trouble following you today. > > Does the above example stand for "pseudo-code" for explaining what > happens when one reimplements a protocol (in which case I'm pretty sure > you're wrong - redefining a protocol extension on a type redefines it for > all following calls, from any thread), or does the above example stand for > pseudo-code for how one would "try" to "break the rule" (mentioned by > Christophe, Rich, and others) in a (hopefully) non-intrusive way ? > > The above is working code (modulo foo related implementations). You can at > any moment change namespaces. Change some function there and go back to your > original namespace. This is effectively monkey-patching. This works now. > > So now suppose seq does not support strings. Someone goes in to "fix" this > in his library. Say, his fix returns (\f \o \o). Someone else also "fixes" > seq: ("f" "o" "o"). You load both libraries and are in trouble. The same > happens if both extend the Sequable protocol for j.l.String. > > So extending a protocol you don't own to a type you don't own is like going > into someone else's namespace and "fixing" things there.
> Not doing so is a question of good manners, which are in general lacking > nowadays… I'm fearing that too, and that's the whole point of me creating this thread to start with. The spirit of clojure will not (probably) be to prevent this (this would remove power from the user, though there is a precedent with the non introduction of reader macros), but I would like at least to know how I could "audit" my project (once all its dependencies have been set up) to spot where the problems (conflicting protocols redefinitions) are. -- 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