how return a data error from a ScriptFu script? from script evaled by embedded TinyScheme to an embedder?
Forgive me if this is not the right forum.
This question may be more about ScriptFu in GIMP than about TinyScheme per se.
What should a script do when it discovers a data error? That is, the data it was passed does not meet expectations. Not errors in the language, but e.g. counting the items in an array that was passed. Specifically, in GIMP 3, a script is expected to count the drawables it was passed.
It seems like some scripts call (gimp-message "error!") but that doesn't seem sufficient, since there may not even be a GUI, and even when there is a GUI, the message sometimes just flashes in the message bar of the GUI. It doesn't convey to anyone but a real person user that an error occurred.
In ScriptFu, scripts return void to the caller of the TinyScheme interpreter. It does no good for a script to evaluate to #f since ScriptFu discards that. A script only has side effects.
In ScriptFu, the caller of the TinyScheme interpreter does check sc->retcode. Where I think 0 means no error, and -1 or any nonzero value means an error.
I think that ScriptFu needs enhancing: define a Scheme function "set-error" to set sc->retcode, or something similar. It could even take a string, and write that string to the output port also, which since in ScriptFu the output port is often redirected to a string which if sc->retcode is not zero, the string is passed on to GIMP to show in an error dialog.
Instead of that, should the embedder always check the value of the eval, and promote #f to an error, at least in this case of ScriptFu? What code in C would determine whether the value of the eval was #f, i.e. compare what field of the sc struct to what C value?
Maybe I am missing something already in TinyScheme, or maybe I misunderstand the ScriptFu code.
Outside the context of ScriptFu (the GIMP embedding) the question can be rephrased, when the embedder is not a REPL, and the embedder discards the value of the embedded TinyScheme interpreter's evaluation, is there any way for the embedded script to signal a data error?