The spec is correct; your code is wrong and I don't know how you got your
expansion there.

$ lein try org.clojure/clojure 1.9.0
nREPL server started on port 55018 on host 127.0.0.1 - nrepl://
127.0.0.1:55018
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_144-b01
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (defmulti mycomp (fn [v] v))
#'user/mycomp
user=> (defmacro defcomp [m]
  #_=>   `(defmethod mycomp ~m
  #_=>      [_]
  #_=>      ~m
  #_=>     )
  #_=>   )
#'user/defcomp
user=> (defcomp :test)

CompilerException java.lang.RuntimeException: Can't use qualified name as
parameter: user/_, compiling:(null:1:1)
user=> (macroexpand '(defcomp test))
(. user/mycomp clojure.core/addMethod test (clojure.core/fn [user/_] test))
user=>

The problem is that you have not protected the _, so it gets expanded to
the local namespace (user/_ in my case here, com.mxsys.psql.component/_ in
yours). You want:

user=> (defmacro defcomp [m] `(defmethod mycomp ~m [~'_] ~m))
#'user/defcomp
user=> (defcomp :test)
#multifn[mycomp 0x545609d8]
user=> (macroexpand '(defcomp :test))
(. user/mycomp clojure.core/addMethod :test (clojure.core/fn [_] :test))
user=>

Notice how the underscore is escaped as ~'_ to escape from the syntax quote
and place a literal underscore symbol.

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