public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* numArgs of a lambda procedure
@ 2012-08-12  7:10 Chuah Teong Leong
  2012-08-12  7:22 ` Per Bothner
  0 siblings, 1 reply; 2+ messages in thread
From: Chuah Teong Leong @ 2012-08-12  7:10 UTC (permalink / raw)
  To: kawa

Is there a simple way to get the number of required arguments from a
procedure object?

I tried the following

(define lamb0 (lambda () #f)
(define lamb1 (lambda (a) #f)
(define lamb2 (lambda (a b) #f)
(define lamb3 (lambda (a b c) #f)
(define lamb4 (lambda (a b c d) #f)

(display lamb0:numArgs)(newline)

(display lamb1:numArgs)(newline)

(display lamb2:numArgs)(newline)

(display lamb3:numArgs)(newline)

(display lamb4:numArgs)(newline)

0
4097
8094
12291
16388

Through this i can just match the value for 0 to 4 but I'm thinking
there must be a more orthodox means to do this.

Is there something I can do like
(procedure-property lamb0 'num-args)
to get the number of arguments?

Thank you in advance

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: numArgs of a lambda procedure
  2012-08-12  7:10 numArgs of a lambda procedure Chuah Teong Leong
@ 2012-08-12  7:22 ` Per Bothner
  0 siblings, 0 replies; 2+ messages in thread
From: Per Bothner @ 2012-08-12  7:22 UTC (permalink / raw)
  To: Chuah Teong Leong; +Cc: kawa

On 08/12/2012 12:10 AM, Chuah Teong Leong wrote:
> Is there a simple way to get the number of required arguments from a
> procedure object?

Use minArgs() and MaxArgs().

numArgs is just an (unfriendly) "encoding".

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-12  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-12  7:10 numArgs of a lambda procedure Chuah Teong Leong
2012-08-12  7:22 ` Per Bothner

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