On 19 Sep 2010, at 07:21, Stuart Campbell wrote:
In this method, the first two parameters may be null. So, my fn
looks like this:
(defn exported-keys
([table]
(exported-keys nil table))
([schema table]
(exported-keys nil schema table))
([catalog schema table]
(fetch-metadata-rs .getExportedKeys catalog schema table)))
I was trying to automatically generate the final function body since
it duplicates the parameter list, and I expect to have a lot of
these kinds of methods. Although, it's not too bad as it is (I've
already pulled some common bits into fetch-metadata-rs).
You could have a macro
(defmacro make-wrapper
[name method & args]
...)
and call it
(make-wrapper exported-keys getExportedKeys catalog schema table)
or something like that. You might have to add some indication about
the order in which the arguments become optional if that's not always
the same. The essential point is to generate the whole function from
one macro, rather than try to generate pieces of the function body by
some macro.
Konrad.
--
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