Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for ScriptingContainer.runScriptlet ambiguous #3583

Open
rovf opened this issue Jan 7, 2016 · 1 comment
Open

Documentation for ScriptingContainer.runScriptlet ambiguous #3583

rovf opened this issue Jan 7, 2016 · 1 comment

Comments

@rovf
Copy link

rovf commented Jan 7, 2016

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.

@kares
Copy link
Member

kares commented Jan 18, 2017

a PR would be good, otherwise this will just ripe here forever and ever ... until someone does so :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants