Looks good! A naive question: how does C behave if you assume that the called function has a signature of (s7_scheme* sc) and you try to pass (s7_scheme* sc, s7_pointer args) ?
If the extra argument doesn't cause trouble I guess the init_args could be always passed (defaulting to s7_nil if not existing in the passed environment) Slightly out of topic: just notice the snake case How come it's not "init-func"? On Thu, 22 Oct 2020 at 19:17, <[email protected]> wrote: > It looks like init_args can work: > > tlib.c (using linux below): > > #include <stdio.h> > #include <stdlib.h> > #include "s7.h" > > static s7_pointer a_function(s7_scheme *sc, s7_pointer args) > { > return(s7_car(args)); > } > > void tlib_init(s7_scheme *sc, s7_pointer args); > void tlib_init(s7_scheme *sc, s7_pointer args) > { > fprintf(stderr, "tlib_init: %s\n", s7_object_to_c_string(sc, args)); > s7_define_function(sc, "a-function", a_function, 0, 0, true, ""); > } > > > gcc -fPIC -c tlib.c > gcc tlib.o -shared -o tlib.so -ldl -lm -Wl,-export-dynamic > > /home/bil/cl/ repl > <1> (load "tlib.so" (inlet 'init_func 'tlib_init 'init_args (list 1 2 > 3))) > tlib_init: (1 2 3) > #f > <2> (a-function 1 2 3) > 1 > > > I think you'll need to remember which form you're using -- if you > call the no-args init func with args or vice versa, all bets are off. > > >
_______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
