Hi,
I would like to ask if it would be okay to set the
_javascript_ language version for the Rhino engine to 1.7?
The Rhino interpreter itself supports _javascript_ 1.7
features as of rhino 1.7r1 [1]. Among these new features are
list comprehensions (non-standard), generators with 'yield'
statement, scoping using the 'let' statement and destructing
assignments. (Not just) for a guy coming from Python these
features would come in very handy.
I can easily set the language version from the Script
Shell and use these features but have some issues when it
comes to running scripts. I would need to set the language
version before I call the script but thats not possible
directly. I wrote a simple wrapper that first sets the
version and then calls a file using asyncExecute(). This
works but lacks all other benefits of a normal EASE launch.
The command to patch the version would be
org.mozilla._javascript_.Context.setLanguageVersion(170).
The Rhino script engine offers a getter method for this
context so if you want to give it a try do something like
this in the Rhino Script Shell:
getScriptEngine().getContext().setLanguageVersion(170);
There are some potential downsides to this though:
- Scripts using these features will not run with
Nashorn.
- JSDT only supports ES3 so highlighting and error
checks are off:
- The 'let' and 'yield' keywords do not exist and are
therefore not highlighted.
- The 'let' statement in for-loop initializers is
marked as an error.
- List comprehensions are marked as errors.
- Destructing assignments are marked as errors.
From what I found the version increase should not break
existing scripts because it only extends the _javascript_
functionality.
I could personally live with increasing the language
version, marking the new features as experimental and
letting the users decide if they want to use them.
What do you think? Would these new features be useful to
someone besides me? Do you see any other potential issues?
Best regards,
Martin