On Aug 5, 11:24 pm, Richard Newman <holyg...@gmail.com> wrote:
> > Bah! I tried to simplify the example code, and missed conveying the
> > actual problem.  Your example code (and sadly, mine) pulls *ns* at
> > runtime, the logging macro doesn't; it writes the value of the *ns* at
> > macro-expansion-time precisely so that it will be the "right" value
> > when called.
>
> Are you sure?
>
>  From logging.clj:
>
> (defmacro log
>    "Logs a message, either directly or via an agent. See also the  
> level-specific
>    convenience macros."
>    ([level message]
>      `(log ~level ~message nil))
>    ([level message throwable]
>      `(log ~level ~message ~throwable (str *ns*)))
>    ([level message throwable log-ns]
>      `(if (and @*allow-direct-logging*
>                (not (clojure.lang.LockingTransaction/isRunning)))
>          (do-log *log-system* ~level (delay ~message) ~throwable ~log-
> ns)
>          (send-off *log-system-agent*
>            do-log ~level (delay ~message) ~throwable ~log-ns))))
>
> user=> (use 'clojure.contrib.logging)
> nil
>
> user=> (macroexpand-1 '(log :info "Hello, world"))
> (clojure.contrib.logging/log :info "Hello, world" nil)
>
> user=> (macroexpand-1 *1)
> (clojure.contrib.logging/log :info "Hello, world" nil
>    (clojure.core/str clojure.core/*ns*))
>
> user=> (macroexpand-1 *1)
> (if (clojure.core/and (clojure.core/deref clojure.contrib.logging/
> *allow-direct-logging*) (clojure.core/not  
> (clojure.lang.LockingTransaction/isRunning))) (clojure.contrib.logging/
> do-log clojure.contrib.logging/*log-system* :info (clojure.core/delay  
> "Hello, world") nil (clojure.core/str clojure.core/*ns*))  
> (clojure.core/send-off clojure.contrib.logging/*log-system-agent*  
> clojure.contrib.logging/do-log :info (clojure.core/delay "Hello,  
> world") nil (clojure.core/str clojure.core/*ns*)))
>
> Looks like you want to unquote (str *ns*) in your definition... if I  
> do that and rebuild, the REPL looks much happier --
>
> Clojure 1.1.0-alpha-SNAPSHOT
> user=> (use 'clojure.contrib.logging)
> nil
> user=> (macroexpand-1 '(log :info "Hello, world"))
> (clojure.contrib.logging/log :info "Hello, world" nil)
>
> user=> (macroexpand-1 *1)
> (clojure.contrib.logging/log :info "Hello, world" nil "user")
>
> -R

Hmm, yep looks that way.  Then how the heck does that code I pasted
above manage to work?  It may be time for bed...
--~--~---------~--~----~------------~-------~--~----~
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