numArgs of a lambda procedure

Chuah Teong Leong teongleong@gmail.com
Sun Aug 12 07:10:00 GMT 2012


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



More information about the Kawa mailing list