On Feb 27, 2008, at 6:35 PM, Steven Mascaro wrote:

>>  This is not to knock named parameters, just to explain why they  
>> never
>>  made it into a serious proposal in the modern ES4 era.
>
> That sounds fine. The only thing it misses is interchanging positional
> and named parameters, but that's no big deal. Will default values work
> by doing the following?
>
> function foo({option1, crud2, frob} = {option1: 1, crud2: "dirty",
> frob: "enius"}) { ... }

That should work.

> A bit cumbersome, but otherwise OK. I tried in the RI, but it throws a
> ParseError. Though both the following give the same error as well:
>
> function foo({option1, curd2, frob}) {}
> ({x, y} = {x: 42, y: 37})

That object destructuring shorthand was approved at

http://bugs.ecmascript.org/ticket/111

but I don't see a ticket, or morph of 111, asking for RI  
implementation. It's not yet implemented:

 >> function f({p:x,q:y}) [x,y];
 >> f({p:1,q:2})
1,2
 >> function g({p,q}) [p,q]
**ERROR** ParseError: unknown token in destructuringField (near <no  
filename>:1:1-1.8)

but as shown above, the longhand form works, and so do default  
parameters:

 >> function h({p:x,q:y} = {p:3,q:4}) [x,y]
 >> h()
3,4

/be
_______________________________________________
Es4-discuss mailing list
Es4-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es4-discuss

Reply via email to