There is a flaw in my approach (I suspected there would be). Once my  
'test-call' function is evaluated, a subsequent error (of any kind)  
will quit TinyScheme. I hope this doesn't mean it is necessary to  
replicate the environment -- that would seem a pretty heavy penalty  
just to call a function.

To summarize what I am seeing...

With scheme_call defined as:

   void scheme_call(scheme *sc, pointer func, pointer args) {
     sc->envir = sc->global_env;
     sc->args = args;
     sc->code = func;
     sc->interactive_repl =0;
     sc->retcode = 0;
     Eval_Cycle(sc, OP_APPLY);

a function called from C will execute and then exit Scheme -- this can  
be shown with the code "(test-call write 1)".

If I save the dump stack before running 'Eval_Cycle' and restore it  
afterwards, TinyScheme will function properly, but will exit on  
encountering an error. My first thought was that this was owing to a  
loss of the 'nesting_stack' state (which, if I understand, maintains  
the input source) but I don't see any relationship in the code.

I guess I will keeping experimenting and perhaps try to contact the  
TinyScheme developers. The functionality of calling Scheme code from a  
foreign function (with return values) would provide a nice way to  
enhance Script-fu without having to alter the TinyScheme core (and  
avoiding the inherent maintenance problems).

Gimp-developer mailing list

Reply via email to