Enhance script calls to PDB not wrap single return values in list
Now, in a script, a call to a PDB procedure always returns a list, even when the PDB procedure returns a single value. Most scripts have many ugly and confusing "(car (gimp-... ))".
The enhancement is, when the signature of the called PDB procedure has a single returned value, to return that value without wrapping it in a list.
This makes the Scheme signature of a PDB call similar to the signature declared in the PDB. ScriptFu is a binding to the PDB as library, and bindings should have similar signatures to the library.
The benefits are: shorter scripts and scripts without a quirk that is hard to understand.
The changes to ScriptFu binding code are trivial: a few lines in scheme-marshal.c.
If we are going to do it, now is the time, for Gimp 3, while the API is breaking for other reasons.
Changing existing scripts
A downside is that many existing scripts would need changing.
We can either:
-
Manually make the changes. Most editors can find most places needing changing, searching for "(car (gimp-". That regular expression might miss some places that cross newlines. It would miss places where the result was stored in a variable (let and set) and later car'd. And you would need to manually delete a matching right paren. Since we don't have test plans for existing scripts, this is likely to introduce bugs that would only be found by users.
-
Or automate the changes. Provide a tool that converts scripts. The tool could be written in ScriptFu language i.e. Lisp, which is good at treating programs as data.
Backward compatibility
To soften the blow of this API breaking change, we could build components of ScriptFu to use two different dialects of ScriptFu language:
-
extension-script-fu and all older scripts installed in /scripts would use the current binding,
-
the independent script-fu-interpreter and all newish scripts installed to /plug-ins would use the new binding.
Other little-used components (Console, Server, Eval, and TextConsole) would also use the new binding.
The changes are so small that you could make this a choice at build time.