Rest parameter syntax

Felix Böhm esdiscuss at feedic.com
Tue Jun 12 07:38:48 PDT 2012


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.

This change would require two additions: Every Identifier past rest can't
be another rest parameter or have a default value specified.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120612/b6c3284a/attachment-0001.html>


More information about the es-discuss mailing list