(define (foo x) body ...)
==>
SCM foo(int nr, SCM k, SCM x)
{
if (nr != 1) arity_error();
body ...
}
(define (foo* . x) body ...)
==>
SCM foo_star(int nr, SCM k, SCM a, SCM b, SCM c, SCM d, SCM rest)
{
SCM x;
switch (nr) {
case 0:
x = NIL;
break;
case 1:
x = SCM_cons(a, NIL);
break;
case 2:
x = SCM_cons(a, SCM_cons(b, NIL));
break;
case 3:
x = SCM_cons(a, SCM_cons(b, SCM_cons(c, NIL)));
break;
case 4:
x = SCM_cons(a, SCM_cons(b, SCM_cons(c, SCM_cons(d, NIL))));
break;
default:
x = SCM_cons(a, SCM_cons(b, SCM_cons(c, SCM_cons(d, rest))));
break;
}
body ...
}
global or some other "known" function
(foo x)
==>
foo(1, k, x);
f
is a SCM value unknown what it calls.
(f x)
==>
// SCM_PROC_UNWRAP checks that f is an SCM procedure and extracts the function
// pointer.
SCM (*fun1)(int, SCM, SCM) = SCM_PROC_UNWRAP(f);
fun1(1, k, x);