2.99 ScriptFu: enhance: run-time choice of language version
#8404 and #9608 propose changes to the ScriptFu language re returned scheme object from PDB calls. Those simplify the language, making it more Scheme-like, removing ugly warts from the original design.
This enhancement proposes that the changes be a script run-time choice instead of an API-breaking change at build time of Gimp 3.
Details
A new function:
(script-fu-v3)
early in a script would make subsequent calls to the PDB return what is proposed in #8404 and #9608, i.e. #t or #f for boolean PDB functions, and a single value for PDB functions returning a single value (instead of wrapping them in a list.)
Discussion
Good
Backward compatibility: existing scripts would work as is but new scripts could be shorter: without (= (gimp- ...) 1) and (car (gimp- ..)) baggage.
Bad
This slightly affects performance. Each call to the PDB would execute a few more instructions, branching on a global flag while marshalling return values.
Most scripts do not iterate over calls to the PDB. The performance hit might be significant when a script does.
Other
#8457 proposes to eliminate TRUE and FALSE (C-isms) as symbols from the language. We wouldn't do that, but new scripts would not need them.
Pragmatics
Needed changes are few and compact, mainly in the code that marshals return values from the PDB (recently refactored.) Changes are only in the ScriptFu wrapper of TinyScheme, not in TinyScheme.
Other
There might be a precedent in other Lisp dialects which we should model. The new function is not quite a macro or cond-expand. Suggestions are welcome.