I'd have thought the idiomatic way of doing this would be:

(ns my-namespace
  (:refer-clojure :exclude [println]))

(defn println [s]
  (clojure.core/println s)
  (clojure.core/println "tacked on"))

- James

On 8 March 2010 03:57, CuppoJava <patrickli_2...@hotmail.com> wrote:
> So I just stumbled across this bug in my code, and it arose very
> innocently so I wonder if anyone has an elegant solution to this
> problem.
>
> There is already a function called (println).
>
> Now I would like to write another version of it, which just tacks some
> stuff at the end of what it normally does:
>
> (defn myprintln [str]
>  (println str)
>  (println "tacked on"))
>
> And now, I would like to run some code using my version of println,
> rather than the original.
>
> (binding [println myprintln]
>  (println "Some code"))
>
> Do you see the bug?
>
> Is there an elegant solution to this problem? I'm working around it by
> saving the original println in another variable before creating
> myprintln, but this isn't very clean.
>
> Thanks for your help
>  -Patrick
>
> --
> 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 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

Reply via email to