Hello!

Leon Henrik Plickat <leonhenrik.plic...@stud.uni-goettingen.de> writes:
> [...]
>
> Must the program run in guile mode the entire time, or can I enter
> it only temporarily for eval'ing the script and calling the function?

I think 'scm_init_guile' is for the entire time, and 'scm_with_guile'
is for the temporarily usage.

> What is the canonical way of eval'ing a script to get a function
> definition from C?

Use 'scm_c_primitive_load' to load and eval a script, if the script
return a function as its last value, then it's done.
Else use 'scm_c_lookup' to get the function as a varaible.

> Can I check after eval'ing the script whether the function I want the
> user to define exists? Probably with scm_c_eval_string() again, but
> I wonder if there is some other more way that is considered to be
> better.

It seems 'scm_module_variable' returns '#f' when the variable binding
doesn't exist.

>
> I am working my way through the API reference, but decided to ask
> for some input in the meantime.

Procedures needed are described in manual section "6.18.10 Accessing
Modules from C".  The flow are:

- Enter guile mode via 'scm_init_guile', 'scm_boot_guile', or 'scm_with_guile'.
- Load and eval script via 'scm_c_primitive_load'.
- Get SCM variables via 'scm_c_lookup', 'scm_module_variable'
- Dereference variables via 'scm_variable_ref' to procedures SCM.
- Call procedures via 'scm_call', 'scm_call_1, etc.

Hope it helps!

Reply via email to