Re: Re: Proposal: The Conditional Fail and Recover Operators; or: a more generic Existential Operator

2014-05-31 Thread Cesar Andreu
At JSConf there was a talk about using macros to experiment with new language features. The library mentioned is sweet.js (http://sweetjs.org/). Maybe you could implement it as a macro for developers to play around? ___ es-discuss mailing list

Using destructuring for function arguments

2014-05-31 Thread Nicholas C. Zakas
I've been playing around with using destructuring as function arguments and have come across some odd behaviors that I'm not sure are intentional (or perhaps, not to spec). For context, consider the following function: ``` function setCookie(name, value, { secure, path, domain, expires }) {

Re: Using destructuring for function arguments

2014-05-31 Thread Matthew Robb
Seems like any identifiers in the arguments should always be defined in scope before ever considering what they will be assigned. On May 31, 2014 11:59 AM, Nicholas C. Zakas standa...@nczconsulting.com wrote: I've been playing around with using destructuring as function arguments and have come

Re: Using destructuring for function arguments

2014-05-31 Thread Dmitry Soshnikov
On Sat, May 31, 2014 at 11:59 AM, Nicholas C. Zakas standa...@nczconsulting.com wrote: I've been playing around with using destructuring as function arguments and have come across some odd behaviors that I'm not sure are intentional (or perhaps, not to spec). For context, consider the

Re: Using destructuring for function arguments

2014-05-31 Thread Brendan Eich
Nicholas C. Zakas wrote: ``` function setCookie(name, value, { secure, path, domain, expires } = {}) { console.log(secure); // ... } ``` Unfortunately, that resulted in a syntax error in Firefox. Could you please file a bug against SpiderMonkey? Thanks, /be

Re: Using destructuring for function arguments

2014-05-31 Thread Brendan Eich
Matthew Robb wrote: Seems like any identifiers in the arguments should always be defined in scope before ever considering what they will be assigned. Right, and they are in scope no matter what. Seems to me that an implementation bug (can't have parameter default value for destructuring

Re: Using destructuring for function arguments

2014-05-31 Thread Allen Wirfs-Brock
On May 31, 2014, at 8:59 PM, Nicholas C. Zakas standa...@nczconsulting.com wrote: I've been playing around with using destructuring as function arguments and have come across some odd behaviors that I'm not sure are intentional (or perhaps, not to spec). Argument binding initialization

Re: Using destructuring for function arguments

2014-05-31 Thread Jason Orendorff
On Sat, May 31, 2014 at 1:59 PM, Nicholas C. Zakas standa...@nczconsulting.com wrote: 1. Who is right about assigning a default value to a destructured parameter, Firefox or Traceur? Traceur is right. 2. Is the behavior of not having any bindings for destructured parameter properties

Re: Using destructuring for function arguments

2014-05-31 Thread Kevin Smith
In addition to what Allen said, you could also do something like this: function setCookie(name, value, { secure, path, domain, expires } = cookieDefaults) { } where `cookieDefaults` is defined elsewhere. Or you could do something like: function setCookie(name, value, { secure = false,

Re: Using destructuring for function arguments

2014-05-31 Thread Kevin Smith
Or, for more readable code: function setCookie(name, value, options = {}) { let { secure = false, path = , domain = , expires = whenever() } = options; // Do stuff } Kevin ​

Re: Using destructuring for function arguments

2014-05-31 Thread Dmitry Soshnikov
On Sat, May 31, 2014 at 1:41 PM, Brendan Eich bren...@mozilla.org wrote: Matthew Robb wrote: Seems like any identifiers in the arguments should always be defined in scope before ever considering what they will be assigned. Right, and they are in scope no matter what. Seems to me that an