Re: Using destructuring for function arguments

2014-05-31 Thread Dmitry Soshnikov
On Sat, May 31, 2014 at 1:41 PM, Brendan Eich 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 implemen

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 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, p

Re: Using destructuring for function arguments

2014-05-31 Thread Jason Orendorff
On Sat, May 31, 2014 at 1:59 PM, Nicholas C. Zakas 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 correct? And if so, is it desir

Re: Using destructuring for function arguments

2014-05-31 Thread Allen Wirfs-Brock
On May 31, 2014, at 8:59 PM, Nicholas C. Zakas 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 takes place as part of htt

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 forma

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 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 fol

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" wrote: > I've been playing around with using destructuring as function arguments > and have come across some odd behavior

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: 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 es-disc