bunny icon indicating copy to clipboard operation
bunny copied to clipboard

Support for...of array iteration

Open kmhernan opened this issue 7 years ago • 7 comments

Could we support javascript for/of loops like:

for( i of inputs.children ) {
    // do stuff
}

Currently we get exception:

Caused by: org.rabix.bindings.cwl.expression.CWLExpressionException: missing ; after for-loop initializer (script#5) encountered while resolving expression:

kmhernan avatar Feb 13 '18 00:02 kmhernan

Got interested in this because we had some similar issues with js. Seems that the default js version in our interpreter is ancient and stuff like this goes away when it's changed to ES6. Pushed directly to develop with this change for v1.0 expressions.

milos-ljubinkovic avatar Feb 13 '18 12:02 milos-ljubinkovic

Oh great! Thanks.

kmhernan avatar Feb 13 '18 12:02 kmhernan

v1.0.4-5 is ES56 but i'm still getting the error, is this expected?

kmhernan avatar Mar 01 '18 21:03 kmhernan

Seems like rhino doesn't support all ES6 features http://mozilla.github.io/rhino/compat/engines.html

When we switch to nashorn it might work

milos-ljubinkovic avatar Mar 06 '18 13:03 milos-ljubinkovic

Ah, good to know thanks @milos-ljubinkovic

kmhernan avatar Mar 06 '18 15:03 kmhernan

I've checked and for (var i in x) is supported in rhino currently and java 9.01's nashorn doesn't support for ... of but might in the future

milos-ljubinkovic avatar Mar 06 '18 16:03 milos-ljubinkovic

FYI: CWL v1.0 expressions are ECMAScript 5.1 only, not ES6.

https://www.commonwl.org/v1.0/CommandLineTool.html#Expressions

mr-c avatar May 29 '18 15:05 mr-c