[plt-scheme] compiled Scheme code in C

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu May 31 00:45:04 EDT 2007

At Wed, 30 May 2007 09:49:01 -0500, "Chongkai Zhu" wrote:
>  proc = scheme_eval_string_all( "a big String of Scheme code", e, 1);
> [...]
>
> I want it to be compiled. Now I managed to do
> 
>  proc = scheme_eval_string( "(eval (load/use-compiled (string->path 
> \"d:/bar.scm\")))", e);
> 
> where d:/bar.scm is exactlly that big string, and actually the .zo file of it 
> is loaded. Here I want to ask whether I could do better? Should I use a unit 
> inside of a module for this bar.scm? Must I use a separate file for Scheme 
> code? It will be nice if I can just put compiled Scheme code directly in the 
> .c file (say, a C String start with #~), so that I don't have to specify the 
> absolute path of the scm/zo file.

scheme_eval_string_all() should work fine with a string containing
bytecode.

MzScheme's own "startup.ss" is compiled to bytecode, then embedded in
the program as a big string constant; see "cstartup.inc".

Matthew



Posted on the users mailing list.