I think the reason is in macroexpand-1 result:

user=> (macroexpand-1 '(mac1 1))
(clojure.core/locking #<Object java.lang.Object@7ec0762> 1)

It's not a valid form to be read and eval by clojure reader,the object form
can't be parsed.

If define obj to be a map {}, it works fine:

user=> (def obj {})
#'user/obj
user=> (mac1 1)
1
user=> (macroexpand-1 '(mac1 1))
(clojure.core/locking {} 1)


2015-11-16 13:55 GMT+08:00 Alice <dofflt...@gmail.com>:

> user=> (def obj (Object.))
> #'user/obj
> user=> (defmacro mac1 [& body] `(locking ~obj ~@body))
> #'user/mac1
> user=> (mac1 nil)
> CompilerException java.lang.RuntimeException: Can't embed object in code,
> maybe print-dup not defined: java.lang.Object@2a747a37,
> compiling:(NO_SOURCE_PATH:1:1)
>
>
> Why am I getting the error?
>
> --
> 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.
>



-- 
庄晓丹
Email:        killme2...@gmail.com xzhu...@avos.com
Site:           http://fnil.net
Twitter:      @killme2008

-- 
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.

Reply via email to