[email protected] (Phillip Lord) writes:
>> Well, that's nothing special wrt. higher-order functions, but a
>> limitation when you define functions with `def`. E.g.,
>>
>> (def my-function (fn [x y]))
>
> Yes, of course. But I have defn to use an option in this case.
Sure. `defn` can walk the forms given to it to extract the argument
vectors automatically.
>> But since you have to add the docstring by hand anyway, I don't think
>> that's much of an issue:
>>
>> (def ^{:doc "Applies my-function to 10 and y."
>> :arglists '([y])}
>> my-partial-function (partial my-function 10))
>
> Sure this is what I have been doing. But when the arglist is more
> complex it is a pain and results in a lot of duplication.
The problem is that you can't get the arglists of `my-function` here,
because :arglists is metadata of the var #'my-function, not of the
function being its value. If :arglists was metadata of functions, then
`partial`, `comp` and friends could return functions with correctly
generated :arglists (given that those are correct).
BTW: At least with complex macros, the real arglists are often very
different than what's in :arglists for documentation purposes. For
example, look at what `(doc fn)` shows, yet its only real arglist is
just `[& sigs]`.
Bye,
Tassilo
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.