Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ease-dev] Rhino JavaScript Version

Hi Martin,

I think it is a good idea to set the language version by default to 170 for Rhino engines. We just have to check that it does not break compatibility of older scripts, but so far I cannot see anything blocking here. Please raise a bug request for that.

In the meantime you could help yourself by providing a plugin that adds an extension to o.e.e.language.launchExtension. There you may register code that will be executed whenever an engine is launched. It binds on an engineID, so you can bind it directly to rhino and its according debugger engine. It then will be executed automatically whenever a rhino engine is created.

HTH
Christian

On 04/07/2016 11:50 AM, Martin Klösch wrote:
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




_______________________________________________
ease-dev mailing list
ease-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ease-dev


Back to the top