Hi,
On Aug 19, 10:24 am, lancecarlson <[email protected]> wrote:
> Is there a way to introspect a function to get its arity? I know some
> functions have an arbitrary amount of arguments, but knowing the count
> on finite argument lists and whether or not a function accepts an
> infinite list would be very useful.
I'm not aware, that such functionality exists. Also a function
might have many arities. Which to choose?
You might get that from metadata of functions stored in a Var.
user=> (:arglists (meta (var reduce)))
([f coll] [f val coll])
> Also, hints on what types a functions arguments accept would be
> nice to parse through. I don't need the docs for particular functions,
> but to be able to use this information in my code. Ideas?
You can't tell a priori, which types a function takes. For example:
(defn call-f-on
[f a b]
(f a b))
(call-f-on + 1 2)
(call-f-on dissoc {:foo #"bar" "yoyo" 'dyne} :foo)
What is the type signature of call-f-on? I mean something
more informative than:
call-f-on :: (Object -> Object -> Object) -> Object -> Object
As I (completely non-representative) never needed such
functionality, could you describe some use case for what
you have in mind?
Sincerely
Meikel
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---