This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
numArgs of a lambda procedure
- From: Chuah Teong Leong <teongleong at gmail dot com>
- To: kawa at sourceware dot org
- Date: Sun, 12 Aug 2012 15:10:33 +0800
- Subject: numArgs of a lambda procedure
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