Hi Basile, You're right that the string needs to be parsed into an s-expression before being evaluated. You have:
SCM guilexp = scm_from_utf8_string(optarg); SCM resguile = scm_primitive_eval(guilexp); The first call converts the C string into a Scheme string. But the step which parses the string is missing. So, the eval will end up evaluating the string to itself. Try replacing scm_from_utf8_string with scm_c_read_string. Best regards, Mikael On Sun, May 4, 2025 at 1:50 PM Basile Starynkevitch < bas...@starynkevitch.net> wrote: > Hello all, > > I'm using GNU guile 3.0 packaged in Debian in some C++ (GPL licensed) > utility > > https://github.com/RefPerSys/RefPerSys/blob/master/do-build-refpersys-plugin.cc > > (in commit e2351bafcef, near line 354). Encoding is of course UTF-8. > > I want to find the GNU Guile C functions to transform a string into a > GUILE s- > expression (so SCM type in C) but that string has to be parsed. > > For example the C string "(+ 2 3)" should be parsed as a GUILE list which I > would later evaluate to 5. > > For example, my ./do-build-refpersys-plugin executable (GPL licensed) > could be > invoked as > > ./do-build-refpersys-plugin -v -G '(bpscm:git_id)' > > and I expect the bpscm_git_id primitive (near line 461 of > do-build-refpersys- > plugin.cc) to be invoked. > > I'm obviously misunderstanding GNU guile. > > Perhaps I am misunderstanding scm_c_define_gsubr.... > > Should I have to make some R5RS port to convert a string and parse it. > > Any simple open source example, or reference to GNU guile source code > file, is > welcome. > > Respectful regards from France. > -- > Basile STARYNKEVITCH <bas...@starynkevitch.net> > 8 rue de la Faïencerie > http://starynkevitch.net/Basile/ > 92340 Bourg-la-Reine https://github.com/bstarynk > France > https://github.com/RefPerSys/RefPerSys > >