[plt-scheme] keywords with C API

From: gabor papp (gabor.lists at mndl.hu)
Date: Sat Aug 8 10:06:41 EDT 2009

Hi all,

I'm trying to write a 3m function that can take keyword arguments, but 
I'm not sure how to do it.

I create the function like this:

scheme_add_global("test-function", 
scheme_make_prim_w_arity(test_function, "test-function", 0, -1), env);

trying to get the keyword as a string:

Scheme_Object *test_function(int argc, Scheme_Object **argv)
{
     MZ_GC_DECL_REG(1);
     MZ_GC_VAR_IN_REG(0, argv);
     MZ_GC_REG();

     char *keyword = SCHEME_KEYWORD_VAL(argv[0]);
     MZ_GC_UNREG();
     return scheme_void;
}

when I try to call the function from scheme by typing (test-function 
#:test 0), I receive the following error:
test-function: does not accept keyword arguments; arguments were: #:test 0

Is there another way to register these kind of funtions?

Thanks,
Gabor


Posted on the users mailing list.