[Gimp-developer] Script-Fu/tinyscheme: using scheme_call?
saulgoode at flashingtwelve.brickfilms.com
saulgoode at flashingtwelve.brickfilms.com
Thu Jul 19 07:48:41 PDT 2007
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) {
dump_stack_reset(sc);
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).
More information about the Gimp-developer
mailing list