IRC channel logs
2026-03-10.log
back to list of logs
<loquatdev>I'm writing a program in C that uses Guile as a scripting language. How might I define an SRFI-9 record from C? <ekaitz>loquatdev: the easy answwer is to eval a piece of scheme with that record <loquatdev>Sure, that makes sense. I'm curious though, what would be the "manual" way to do it? <ekaitz>loquatdev: the difficult answer is that records are internally `struct`s <ekaitz>you can make guile structs from C, using: <ekaitz>> C Function: SCM scm_make_struct (SCM vtable, SCM tail_size, SCM init_list) <loquatdev>The reason I'm asking is because I'm evaluating a scheme file that will return a configuration value. I know I can just do an a-list but it seems like the "proper" way to do it would be to return a record/struct of some kind. Would I even need a record or is there a simpler / more idiomatic way to do that? <loquatdev>I should not that the configuration will contain lambdas that will be called from C later on. <ekaitz>it depends on what you'd like to do <ekaitz>in some programs I take the config, `read` it and parse the list <ekaitz>in some others you could do like guix does, evaluate the file, having some environment around the file <ekaitz>meaning, you give the configuration a couple of record definitions, and make the user use them and return the values <loquatdev>Yeah, I'm currently evaluating the file and using its return value from C. <ekaitz>loquatdev: if you are doing that, defining a record and including that in the environment that evaluates the user's code is a good way to go