guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calling user defined guile functions from C?


From: Leon Henrik Plickat
Subject: Calling user defined guile functions from C?
Date: Thu, 23 Nov 2023 15:53:06 +0100

I intend on using guile as a scripting language in a C program (a
Wayland client in this case). All documentation and tutorials I have
found focus on extending guile with C code, however I explicitly want
to drive the code from C.

What I ideally want to do is to eval a guile script on startup of the
program in which a user can define a function. The script basically
functions as configuration. Afterwards, enter the main loop and in
response to certain events call the function defined by the user
(with scm_c_eval_string("(name-of-function)") I suppose) and use its
return value (a list of lists containg 4 integers each) to respond to
the event.

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?
What is the canonical way of eval'ing a script to get a function
definition from C?
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.

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

Friendly greetings,
Leon Henrik Plickat

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]