undefined being treated as a missing optional argument

Allen Wirfs-Brock allen at wirfs-brock.com
Fri Apr 13 11:46:08 PDT 2012


On Apr 13, 2012, at 11:22 AM, David Herman wrote:

> On Apr 13, 2012, at 10:53 AM, Allen Wirfs-Brock wrote:
> 
>> On Apr 13, 2012, at 10:10 AM, Brendan Eich wrote:
>> 
>>> In general, delegation (depth D) plus optionality (degree N paramters) makes an (2N)^D worst-case combinatorial explosion.
>>> 
>>> This is IMHO a strong argument for a sentinel in-language to mean "missing actual".
>> 
>> That sentinel could simply be a empty argument position:
>> 
>>         new Intl.Collator( , {usage: "search"});
> 
> That's not enough. It doesn't allow you to make a dynamic decision as to whether or not to pass that argument, which still leaves you in general with the combinatorial explosion.

sure you can

Intl.Collator = function(...args) {
   let [locale=defaultLocale, options={}] = args;
   let localeDefaulted = args.hasOwnProperty("0")
   ...
 }








> 
> I'm very much in favor of defaults treating undefined exactly the same as no argument.
> 
> Dave
> 
> 



More information about the es-discuss mailing list