Felix Böhm wrote:
Per definition, rest parameters always need to be at the end of a FormalParameterList. I was wondering if this limitation could be liftet. Use-case: Most SQL libraries for node support passing query arguments to the query function (so SQL injections are avoided). The usual syntax is db.run("SELECT * FROM t WHERE foo=? AND cbar=?", "bar", "cfoo", function(err, row){…}); The number of arguments passed after the query depends on the number of question marks inside the query. It would be nice when an implementation could simply write db.run = function(query, ...params, cb){…} and avoid using the arguments object or Array#poping the last element of params.
BTW, isn't this possible with comprehensions in parameter list: db.run = function (query, ...[...params, cb]) { /* body */ } If yes, problem solved.
This change would require two additions: Every Identifier past rest can't be another rest parameter or have a default value specified.
Herby _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss