The Spread operator is super convenient in the JavaScript world and would be a great addition to the modern trend of functions/syntaxes being adopted by cfscript.
I would suggest implementing it in the same way as JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax
The return from a spread operation would be a new array or struct containing the items that were spread out. Would allow for much cleaner functional programming style where avoiding mutating data is key.
Merging objects is another benefit:
var obj1 = { foo: 'bar', x: 42 };
var obj2 = { foo: 'baz', y: 13 };
var mergedObj = { ...obj1, ...obj2 };
// Object { foo: "baz", x: 42, y: 13 }
Oh, and another, converting a string into array:
var myArray = [..."12345"];
// ["1", "2", "3", "4", "5"]
As a side effect, this could eliminate the need to do things like
myFunction( argumentCollection=args )
and instead you'd be able to do
myFunction( ...args )
Attachments:
Comments: