chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] How does Chicken know the # of arguments to a functi


From: felix winkelmann
Subject: Re: [Chicken-users] How does Chicken know the # of arguments to a function
Date: Mon, 20 Dec 2004 07:25:17 +0100

On Sun, 19 Dec 2004 13:30:02 +0000, Joel Reymont <address@hidden> wrote:
> > felix winkelmann wrote:
> 
> >Every primitive Chicken function takes one argument (the first one,
> >actually) that holds the number of arguments passed.
> 
> But how does Chicken know how many arguments _to expect_?
> 

It's compiled into the code:

(define (foo x y)
  (print x y) )

->

/* foo in k18 in k15 in k12 */
static void f_22(C_word c,C_word t0,C_word t1,C_word t2,C_word t3){
C_word tmp;
C_word t4;
C_word *a;
if(c!=4) C_bad_argc(c,4);           /*   <-- check (includes 2 implicit args) */
C_check_for_interrupt;
if(!C_stack_probe(&a)){
C_save_and_reclaim((void*)tr4,(void*)f_22,4,t0,t1,t2,t3);}
C_trace("x.scm: 2    print");
t4=*((C_word*)lf[1]+1);
((C_proc4)C_retrieve_proc(t4))(4,t4,t1,t2,t3);}

Or are you talking about something different?
For C->Scheme callbacks, there is no check, since C doesn't
any argument-count checking anyway.


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]