This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

max # of args in gsubr?


Valentin Kamyshenko writes:
 > Hello,
 > 
 > I'm writing a small wrapper for fortran routines, and faced with the
 > above limitation. After quick look through the guile sources I
 > have found the evident place, where it is defined/used -- the
 > libguile/gsubr.h. But, so far as I understood, the limitation
 > SCM_GSUBR_MAX = 10 is quite arbitrary, and, as it is used in
 > SCM_GSUBR_MAKTYPE and SCM_GSUBR_REQ() ..., I could use up to 15
 > required, and up to 15 optional parameters. Is it true? Also, may I
 > use (in principle) more than 17 bits for having, let say, 31 required,
 > 31 optional and 1 'rest' parameter (that is, SCM_GSUBR_MAKTYPE would 
 > return 0x7ff) after evident changes in gsubr.h and having all the
 > other code untouched?

Why not packaging all the arguments into one scm object, an alist or vector
or the like, and parse the vector on the C side,such as:

int foo (int blandy, char *stachowiak, double galassi, unsigned urban, char 
stallman, int Tendys, WINDOW *humeniuk, float boekemeier, int vollmer, FILE *
djurfeld, DBM_FILE * thi, int matzigkeit)

gets wrapped as 

SCM
wrapper_foo (SCM arglist)
{
int result;
int blandy, Tendys, vollmer,matzigkeit;
double galassi;
float boekemeier;
char * stallman;
WINDOW *humeniuk;
DBM_FILE * thi;
FILE *djurfeld;
ulong urban;

blandy = gh_scm2int (scm_assoc_ref (arglist, gh_symbol2scm ("blandy")));
/* and so on */
result = foo (blandy, stachowiak, /* and so on*/);
return gh_scm2int (result);
}

gh_new_procedure ("foo", wrapper_foo, 1, 0, 0);



(foo (list (cons 'blandy 42)(cons 'stachowiak "scwm")(cons 'galassi 3.141592)))

Klaus Schilling