ri...@happyleptic.org writes: > (define (hook-helper %s) (lambda () #\t)) > > where %s is the long list of parameters (foo bar baz...) that's inserted by > the C program. > And : > > (define (hook . args) (local-eval (cons print-user-fields user-fields) > (procedure-environment (apply hook-helper args))))
Using local-eval and procedure-environment like this won't work in Guile 1.9/2.0, I believe. But you could get a similar effect - which I think will still work in 1.9/2.0 - by creating a module, defining values in it, and then evaluating in that module. (In Guile, module == top level environment.) (Note that the bindings in a module are conceptually similar to an alist, so this is actually not so different from what Thien-Thi suggested.) To create a module, in Scheme: (define-module (xxx)) Then your C code would access that using SCM module = scm_c_resolve_module ("xxx"); and define each value in it using scm_c_module_define (module, name, value); and finally evaluate in that module using scm_c_eval_string_in_module (expression, module); It would also seem (at least to me) a bit less magical to define the user-fields as a procedure, e.g.: (define (calc-user-fields) (list foo bar (+ baz foo) (if (> foo bar) 1 2))) and then the "expression" above would be "(calc-user-fields)". All completely untested, of course! :-) Regards, Neil