Default argument values

Brendan Eich brendan at mozilla.org
Wed Feb 27 17:52:24 PST 2008


On Feb 27, 2008, at 5:22 PM, Steven Mascaro wrote:

> Anyway, I'm sure you know the advantages (and disadvantages?) to
> optional named arguments. I was just wondering whether they had been
> considered for ES4, or if considered and rejected, then why. I've
> searched the wiki and mailing list, but couldn't find anything. I also
> remember some brief comments on it a short while ago, but can't find
> them now.

I search like so:

http://www.google.com/search?hl=en&q=site%3Amail.mozilla.org+es4- 
discuss+%22named+parameters%22+brendan

and found a thread where I sounded off on named parameters:

https://mail.mozilla.org/pipermail/es4-discuss/2007-March/000548.html

Already you see people burning an object per call to simulate named  
parameters:

   foo({option1: "on", crud2: "dunno", frob: 42})

With destructuring parameters and unambiguous callsites, the object  
can be optimized away. There are other ways to optimize such objects  
away, for the sake of ES3 code. Point is we have never mustered a  
named parameter proposal in the face of existing practice that makes  
do without, and new forms such as destructuring parameters:

   function foo({option1, crud2, frob}) { ... }

that reduce the pressure for named parameters, and have their own  
wins and motivations aside from named parameter ones.

This is not to knock named parameters, just to explain why they never  
made it into a serious proposal in the modern ES4 era.

/be



More information about the Es4-discuss mailing list