[plt-scheme] Calling scheme_loaded functions

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Mar 10 10:34:43 EST 2004

At Tue, 9 Mar 2004 23:14:57 -0700, Richard Cleis wrote:
> I have abstracted portions of legacy c-code to a degree that permits me 
> to write and test functions in DrScheme and then 'scheme_load' them 
> into c from the source file.  However, I am confused about how to call 
> the scheme functions.  I have been using 'scheme_eval_string' after 
> printing expressions into text, but suspect that using Scheme_Object* 
> references would be more efficient.
>
> Chapter 6 of InsideMz gives me great hope, but the statement
> "The scheme_eval_function actually calls scheme_compile followed by 
> scheme_eval_compiled" convinces me that I am in for a long day of 
> experimenting to unravel the relationship of these three layers with 
> the environment produced by scheme_load.
> 
> If a function is scheme_loaded, can it be scheme_eval'd?  That would 
> imply that it could be scheme_compiled once, then scheme_eval_compiled 
> forever more.  If that is true, then is it possible to scheme_compile 
> an entire file?

Calling scheme_eval_string() is essentially the same as typing an
expression in a read-eval-print loop. The expression that you type is
compiled, but not any functions that the expression might call (which
were compiled once by scheme_load()). For example, typing

 > (f 1 2 3)

compiles the function call "(f 1 2 3)", but it doesn't compile `f'
itself.

So, most likely, scheme_eval_string() is fine for your purposes.

Matthew



Posted on the users mailing list.