I'm trying to load a Scheme file into my C source file, but if my Scheme file has syntax errors or undefined variables, nothing happens. The program just returns nothing.
I'm using the code from the example in the manual:
obj1 = sexp_c_string(ctx, "file.scm", -1);
sexp_load(ctx, obj1, NULL);
The entire file is as follows:
#include <chibi/eval.h>
void dostuff(sexp ctx) {
sexp_gc_var2(obj1, obj2);
sexp_gc_preserve2(ctx, obj1, obj2);
obj1 = sexp_c_string(ctx, "file.scm", -1);
sexp_load(ctx, obj1, NULL);
sexp_eval_string(ctx, "(+ 2 2)", -1, NULL);
obj1 = sexp_intern(ctx, "my-pro", -1);
obj2 = sexp_cons(ctx, obj1, SEXP_NULL);
sexp_eval(ctx, obj2, NULL);
sexp_gc_release2(ctx);
}
int main(int argc, char** argv) {
sexp ctx;
sexp_scheme_init();
ctx = sexp_make_eval_context(NULL, NULL, NULL, 0, 0);
sexp_load_standard_env(ctx, NULL, SEXP_SEVEN);
sexp_load_standard_ports(ctx, NULL, stdin, stdout, stderr, 1);
dostuff(ctx);
sexp_destroy_context(ctx);
}
For example, if 'file.scm' holds
(display "hello")
The program will print "hello", however, if the file holds:
(display x)
The program will not print anything at all, and will exit gracefully. I would like to display something like 'Undefined variable x' to the output so users know what's wrong.
I didn't see something about it in the manual, but I might have missed / misunderstood it. I couldn't find the answer in a websearch, but I don't know what keywords I should use.