Skip to content

Instantly share code, notes, and snippets.

@hsjunnesson
Created October 1, 2019 19:06
Show Gist options
  • Save hsjunnesson/847927b2c48074457d99003c6cec263a to your computer and use it in GitHub Desktop.
Save hsjunnesson/847927b2c48074457d99003c6cec263a to your computer and use it in GitHub Desktop.
Embedded Racket in C
#include "scheme.h"
#include "base.c"
static int run(Scheme_Env* e, int argc, char* argv[]) {
scheme_env = e;
declare_modules(e);
scheme_namespace_require(scheme_intern_symbol("racket/base"));
Scheme_Config* config = scheme_current_config();
Scheme_Object *curout = scheme_get_param(config, MZCONFIG_OUTPUT_PORT);
Scheme_Object* v = scheme_eval_string("(+ 1 2)", scheme_env);
scheme_display(v, curout);
scheme_display(scheme_make_char('\n'), curout);
scheme_eval_string("(require \"test.rkt\")", scheme_env);
return 0;
}
int main(int argc, char* argv[]) {
scheme_main_setup(1, run, argc, argv);
return 0;
}
#lang racket
(printf "Hello World!\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment