* testing arity
@ 2006-07-22 16:19 Jon Wilson
2006-07-22 21:27 ` rm
2006-07-23 5:04 ` tomas
0 siblings, 2 replies; 7+ messages in thread
From: Jon Wilson @ 2006-07-22 16:19 UTC (permalink / raw)
Hi,
Is there a good way to determine the number of arguments that a given
procedure will take? I suppose I can look at
(source proc)
and extract the list of formals, and write a procedure which does this
automatically, but I'd hate to reinvent the wheel. Also, I'm not sure how
well using source will work when we have optional or keyword arguments.
Also, on an unrelated note, is it possible to define values (as in (lambda
() (values 1 2)) ) in terms of McCarthy's original seven lisp primitives?
Or would this question be better asked somewhere else (like c.l.scheme)?
Regards,
Jon
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: testing arity
2006-07-22 16:19 testing arity Jon Wilson
@ 2006-07-22 21:27 ` rm
2006-07-23 5:49 ` Jon Wilson
2006-07-23 5:04 ` tomas
1 sibling, 1 reply; 7+ messages in thread
From: rm @ 2006-07-22 21:27 UTC (permalink / raw)
Cc: guile-user
On Sat, Jul 22, 2006 at 11:19:28AM -0500, Jon Wilson wrote:
> Hi,
> Is there a good way to determine the number of arguments that a given
> procedure will take? I suppose I can look at
> (source proc)
> and extract the list of formals, and write a procedure which does this
> automatically, but I'd hate to reinvent the wheel. Also, I'm not sure how
> well using source will work when we have optional or keyword arguments.
What doesn't work with 'arity'?
guile> (define (myne n m) (* n m))
guile> (arity myne)
2 arguments: `n' and `m'.
Cheers, Ralf Mattes
> Also, on an unrelated note, is it possible to define values (as in (lambda
> () (values 1 2)) ) in terms of McCarthy's original seven lisp primitives?
> Or would this question be better asked somewhere else (like c.l.scheme)?
> Regards,
> Jon
>
>
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-user
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: testing arity
2006-07-22 16:19 testing arity Jon Wilson
2006-07-22 21:27 ` rm
@ 2006-07-23 5:04 ` tomas
2006-07-23 7:58 ` Neil Jerram
1 sibling, 1 reply; 7+ messages in thread
From: tomas @ 2006-07-23 5:04 UTC (permalink / raw)
Cc: guile-user
[-- Attachment #1.1: Type: text/plain, Size: 792 bytes --]
On Sat, Jul 22, 2006 at 11:19:28AM -0500, Jon Wilson wrote:
> Hi,
> Is there a good way to determine the number of arguments that a given
> procedure will take?
Here's a fishing rod ;-)
| tomas@herr-turtur:~$ guile
| guile> (apropos "arity")
| (ice-9 session): arity #<procedure arity (obj)>
| guile> (arity apropos)
| 1 or more arguments: `rgx', the rest in `options'.
| guile>
> Also, on an unrelated note, is it possible to define values (as in (lambda
> () (values 1 2)) ) in terms of McCarthy's original seven lisp primitives?
> Or would this question be better asked somewhere else (like c.l.scheme)?
I don't understand exactly what you mean here. There is values and
call-with-values in guile -- but maybe my answer is way off...
Regards
-- toms
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 140 bytes --]
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: testing arity
2006-07-22 21:27 ` rm
@ 2006-07-23 5:49 ` Jon Wilson
0 siblings, 0 replies; 7+ messages in thread
From: Jon Wilson @ 2006-07-23 5:49 UTC (permalink / raw)
Hi Ralf,
rm@tuxteam.de wrote:
> What doesn't work with 'arity'?
Ah. The answer to that question is "It is not documented in the guile
manual, nor in R5RS.".
Regards,
Jon
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: testing arity
2006-07-23 5:04 ` tomas
@ 2006-07-23 7:58 ` Neil Jerram
2006-07-23 22:50 ` Kevin Ryde
2006-07-24 1:01 ` Jon Wilson
0 siblings, 2 replies; 7+ messages in thread
From: Neil Jerram @ 2006-07-23 7:58 UTC (permalink / raw)
Cc: tomas
tomas@tuxteam.de writes:
> On Sat, Jul 22, 2006 at 11:19:28AM -0500, Jon Wilson wrote:
>> Hi,
>> Is there a good way to determine the number of arguments that a given
>> procedure will take?
>
> Here's a fishing rod ;-)
>
> | tomas@herr-turtur:~$ guile
> | guile> (apropos "arity")
> | (ice-9 session): arity #<procedure arity (obj)>
> | guile> (arity apropos)
> | 1 or more arguments: `rgx', the rest in `options'.
> | guile>
And if you're not keen on parsing arity's output, see its definition
in (ice-9 session) for the procedure properties that it queries to
produce this.
>> Also, on an unrelated note, is it possible to define values (as in (lambda
>> () (values 1 2)) ) in terms of McCarthy's original seven lisp primitives?
>> Or would this question be better asked somewhere else (like c.l.scheme)?
Yes, sounds to me like a question for c.l.scheme.
Regards,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: testing arity
2006-07-23 7:58 ` Neil Jerram
@ 2006-07-23 22:50 ` Kevin Ryde
2006-07-24 1:01 ` Jon Wilson
1 sibling, 0 replies; 7+ messages in thread
From: Kevin Ryde @ 2006-07-23 22:50 UTC (permalink / raw)
Cc: guile-user
Neil Jerram <neil@ossau.uklinux.net> writes:
>
> And if you're not keen on parsing arity's output, see its definition
> in (ice-9 session) for the procedure properties that it queries to
> produce this.
(procedure-property obj 'arity) being the operative part, it gives a
list of "(required-count optional-count more?)". "required-count"
many arguments required, plus up to "optional-count" further, or if
the "more?" flag is #t then an arbitrary number more.
I've been using it in my lint program (gratuitous plug). A few funcs
defined in scheme code take "(foo bar . rest)" style rather than have
an "optional-count", eg. `atan'.
http://www.geocities.com/user42_kevin/guile-lint/index.html
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: testing arity
2006-07-23 7:58 ` Neil Jerram
2006-07-23 22:50 ` Kevin Ryde
@ 2006-07-24 1:01 ` Jon Wilson
1 sibling, 0 replies; 7+ messages in thread
From: Jon Wilson @ 2006-07-24 1:01 UTC (permalink / raw)
Thanks, Neil. Sounds like an excellent answer!
Regards,
Jon
Neil Jerram wrote:
> tomas@tuxteam.de writes:
>
>
>>On Sat, Jul 22, 2006 at 11:19:28AM -0500, Jon Wilson wrote:
>>
>>>Hi,
>>>Is there a good way to determine the number of arguments that a given
>>>procedure will take?
>>
>>Here's a fishing rod ;-)
>>
>> | tomas@herr-turtur:~$ guile
>> | guile> (apropos "arity")
>> | (ice-9 session): arity #<procedure arity (obj)>
>> | guile> (arity apropos)
>> | 1 or more arguments: `rgx', the rest in `options'.
>> | guile>
>
>
> And if you're not keen on parsing arity's output, see its definition
> in (ice-9 session) for the procedure properties that it queries to
> produce this.
>
>
>>>Also, on an unrelated note, is it possible to define values (as in (lambda
>>>() (values 1 2)) ) in terms of McCarthy's original seven lisp primitives?
>>>Or would this question be better asked somewhere else (like c.l.scheme)?
>
>
> Yes, sounds to me like a question for c.l.scheme.
>
> Regards,
> Neil
>
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-07-24 1:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-22 16:19 testing arity Jon Wilson
2006-07-22 21:27 ` rm
2006-07-23 5:49 ` Jon Wilson
2006-07-23 5:04 ` tomas
2006-07-23 7:58 ` Neil Jerram
2006-07-23 22:50 ` Kevin Ryde
2006-07-24 1:01 ` Jon Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).