Thanks for your tips, Ken and Meikel.

Both of them were helpful, and helped me resolve my problem.  First I tried:

user=> (defmacro my-with-cl [spec] `(with-command-line args "desc" ~spec
(prn foo)))

This almost works:

user=> (macroexpand-1 '(my-with-cl [[foo "something about foo" nil]
remaining]))
(clojure.contrib.command-line/with-command-line
  user/args
  "desc"
  [[foo "something about foo" nil] remaining]
  (clojure.core/prn user/foo))

But breaks:

user=> (my-with-cl [[foo "something about foo" nil]
remaining])
java.lang.Exception: No such var: user/foo (NO_SOURCE_FILE:88)

This makes sense, as the backtick quote in my defmacro qualified foo under
ns user.  But I really need foo to be unqualified, so it refers to the foo
defined by with-command-line.  This variation worked:

(defmacro my-with-cl [spec] `(with-command-line args "desc" ~spec (prn
~'foo)))

Open to suggestions if there's a better way to do this.

Thanks,
Marc

On Mon, Jun 27, 2011 at 4:05 AM, Meikel Brandmeyer <m...@kotka.de> wrote:

> Hi,
>
> Am Sonntag, 26. Juni 2011 17:22:14 UTC+2 schrieb mlimotte:
>
>
> user> (my-with-cl '[[foo "something about foo" nil]])
>> ; Evaluation aborted.
>> Exception: Unsupported binding form: something about foo
>>
>
> Leave out the ' in front of the vector. with-command-line quotes it for
> you. Adding the quote makes it see (quote [[...]]) instead of [[...]].
>
> Sincerely
> Meikel
>
>
> --
> 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