Hello everybody.
lately i have been programming in scheme, but i'm usually obligated to use C++ for school.
So i try to use guile inside C++ programs.
I wrote two little classes for simplifying the initialization of guile and evaluating expressions, and i have a couple of questions regarding how can i enhance the implementation.
The two classes are:
- GuileApplication (does the scm_boot_guile and other stuff)
- GuileEvaluator (has an eval function that gets a _expression_ as an std::string and returns the result as an std::string)
Questions about the GuileApplication class:
1.- How can a send scm_boot_guile a member function? (relevant functions are init, initializationHack and guileMain)
[Explanation: the scm_boot_guile is called from a member function of GuileApplication and i want to send another member function as the "inner_main", my half-solution was to use a normal function that received a GuileApplication* casted as a void* and dereferencing that to call the other member function (i had to friend this function and pass the instance as the void * data )]
2.- Is the "(use-modules (system repl server)) (spawn-server)" a good way of getting access to the program with emacs and geiser's 'connect-to-guile'? (relevant functions are guileMain)
[Explanation: i like to use an external repl to test functions with emacs and geiser, the only way i know to make this happen is to eval those two expressions, but i don't know if it is the right way to do it]
Questions about the GuileEvaluator class:
3.- How can i handle better the possible errors from evaluating expressions from C++? (relevant functions are evalString, guileEvalHandler, handler_message, guileEvalBody)
[Explanation: i think the curren way i'm handling errors is a bit clumsy, i wanted to show the error message but don't exit the entire program, so i had to copy the handler_message from the guile source, but i'm sure there is a better way of doing this]
4.- How can i avoid having to close the output string port and creating a new one each time i convert an SCM value to an std::string? (relevant functions are scmToString)