-
-
Notifications
You must be signed in to change notification settings - Fork 938
Documentation for ScriptingContainer.runScriptlet ambiguous #3583
Description
The documentation for ScriptingContainer.runScriptlet says:
public Object runScriptlet(String script)
Evaluates a script under the current scope (perhaps the top-level scope) and returns a result only if a script returns a value. Right after the parsing, the script is evaluated once.
The wording "returns a result only if a script returns a value" is fuzzy and doesn't really tell us what is going on, for the following reasons:
(1) "if a script returns a value" -> Under what condition does a script NOT return a value? Every Ruby Script returns a value (even if the value is nil), However, we have three cases, where the effect needs to be clarified (and which might, or might not, fall under the case "not returning a value":
- An empty script (i.e. consisting of white space only); maybe it returns nil, but this is not necessary the case and should be documented.
- A script with a syntax error
- The case where the script can't be found
(2) "returns a result only" -> Assuming that (1) does not hold, i.e. the script "does not return a value" for whatever reason. Does this mean that the returned Java Object is null, or does it mean that a RuntimeException is thrown?
(3) Consider a Ruby script which explicitly returns nil (i.e. its last statement evaluates to nil). Will then the return value in Java null, or will the object be in fact a RubyObject, which contains the value null?
The documentation should give clear answers to these three points.