Re: Finding a function's expected argument list length

2011-10-20 Thread Alex Baranosky
Thanks.  I'm going to have to see if that could help with what I'm trying to
do.

On Thu, Oct 20, 2011 at 11:45 PM, mmwaikar  wrote:

> In a REPL,
>
> user> (defn hello [name]
> (println "hi," name))
> #'user/hello
>
> user> (meta (var hello))
> {:ns #, :name hello, :file "NO_SOURCE_FILE", :line 1,
> :arglists ([name])}
>
> Please also check - http://clojuredocs.org/clojure_core/clojure.core/meta
>
>  --
> 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

Re: Finding a function's expected argument list length

2011-10-20 Thread Alex Baranosky
I figured, but had to ask. I'm looking into adding a feature to Midje to be
able to say:

(defn g [a b c d e f g] nil)

(fact
  (f 1) => 1
  (provided
(g ...) :never ))

instead of what you currently have to say for the equivalent:

(fact
  (f 1) => 1
  (provided
(g anything anything anything anything anything anything anything) =>
anything :never ))

Knowing the arity of the function would have helped with the internals.

On Thu, Oct 20, 2011 at 11:42 PM, Alan Malloy  wrote:

> No. The summary is: from Java's point of view every function is
> "willing" to accept any number of args, but many of the
> implementations throw an exception. Vars have an :arglists metadata
> key, but that is not generally present on functions. I agree it would
> be nice if function objects carried a set of "acceptable arities" with
> them, but I haven't thought very hard about it - perhaps the
> performance implication this imposes on every function isn't worth it
> for the small minority of times when you need to ask the question.
>
> On Oct 20, 5:58 pm, Alex Baranosky 
> wrote:
> > For some work I'm doing it would be very nice to be able to know the
> number
> > of arguments any given function expects to be called with.  Is there
> anyway
> > to get this information at run-time in Clojure?
> >
> > Thanks.
>
> --
> 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

Re: Finding a function's expected argument list length

2011-10-20 Thread mmwaikar
In a REPL,

user> (defn hello [name]
(println "hi," name))
#'user/hello

user> (meta (var hello))
{:ns #, :name hello, :file "NO_SOURCE_FILE", :line 1, 
:arglists ([name])}

Please also check - http://clojuredocs.org/clojure_core/clojure.core/meta

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

Re: Finding a function's expected argument list length

2011-10-20 Thread Alan Malloy
No. The summary is: from Java's point of view every function is
"willing" to accept any number of args, but many of the
implementations throw an exception. Vars have an :arglists metadata
key, but that is not generally present on functions. I agree it would
be nice if function objects carried a set of "acceptable arities" with
them, but I haven't thought very hard about it - perhaps the
performance implication this imposes on every function isn't worth it
for the small minority of times when you need to ask the question.

On Oct 20, 5:58 pm, Alex Baranosky 
wrote:
> For some work I'm doing it would be very nice to be able to know the number
> of arguments any given function expects to be called with.  Is there anyway
> to get this information at run-time in Clojure?
>
> Thanks.

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


Finding a function's expected argument list length

2011-10-20 Thread Alex Baranosky
For some work I'm doing it would be very nice to be able to know the number
of arguments any given function expects to be called with.  Is there anyway
to get this information at run-time in Clojure?

Thanks.

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