MerelyAPseudonym <merelyapseudo...@gmail.com> writes:

Hi!

> When abstracting out common behavior by creating higher-order
> functions, I would like the resulting function to retain the arglist
> metadata. Has anyone already solved this problem?

Right now, if I define public functions in terms of comp or partial, I
add the metadata manually, e.g.,

  (def ^{:arglists '([coll])}
     filter-even
     "Filters the even elements of coll."
     (partial filter even?))

So your idea is to have a defpartial for automating that?  Something
like

  (defpartial filter-even [filter even?]
     "Filters the even elements of coll.")

I think that should be doable.  There might be some complexities when
the function uses varargs, say, the only arglist of foo is [a & more],
then the arglist of (defpartial foofoo [foo 1 2 3]) is still [& more],
so you cannot simply drop the first n args.  And if the function is
overloaded, you have to strip the arglists that are too short.  But
again, I don't see a strict reason that this cannot work.

Bye,
Tassilo

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