The expression

(clojure.core.incubator/-?> 1 identity identity)

fails with

Unable to resolve symbol: -?> in this context

unless -?> is referred into the local namespace. Why it fails is clear:

(macroexpand-1 `(clojure.core.incubator/-?> 1 identity identity))

outputs

(-?> (-?> 1 clojure.core/identity) clojure.core/identity)

It expands to unqualified symbols. This is because the *defnilsafe* macro 
uses

~'~nil-safe-name

in its expansion so no syntax-quoting occurs. A solution would be to define 
it as

(defmacro defnilsafe [docstring non-safe-name nil-safe-name 
simple-nil-safe-name]
  `(defmacro ~simple-nil-safe-name ~docstring
     {:arglists '([~'x ~'form] [~'x ~'form ~'& ~'forms])}
   ([x# form#]
     `(let [~'i# ~x#] (when-not (nil? ~'i#) (~~non-safe-name ~'i# ~form#))))
   ([x# form# & more#]
     `(~~nil-safe-name (~~nil-safe-name ~x# ~form#) ~@more#))))

and invoke with

(defnilsafe "...doc..." `-> `-?> -?>)

I didn't find a more direct way to move between qualified and unqualified 
symbols.

In normal use this weakness is not a major problem, but it becomes one when 
trying to use the nilsafe operators in macros, in eval'd forms, etc.

-- 
-- 
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/groups/opt_out.


Reply via email to