Re: Refutable destructuring

2013-08-16 Thread Kevin Smith
My understanding was that pretty much everyone in the room, at least those who participated in the conversation, felt that refutable destructuring was a mistake, Can you elaborate, please? Why? { Kevin } ___ es-discuss mailing list es-discuss

Re: Refutable destructuring

2013-08-16 Thread Allen Wirfs-Brock
On Aug 15, 2013, at 9:27 PM, David Herman wrote: This is *not* what I remember of the conversation, at all. My understanding was that pretty much everyone in the room, at least those who participated in the conversation, felt that refutable destructuring was a mistake, but that we

Re: Refutable destructuring

2013-08-16 Thread Dmitry Soshnikov
that refutable destructuring was a mistake, but that we couldn't really come to any conclusions without Brendan and Andreas there, since the two of them had championed refutable destructuring. IOW, we don't have consensus about this issue. Personally, I think there is all too much confusion over

Re: Refutable destructuring

2013-08-16 Thread Kevin Smith
And for the strict match one could introduce match(...) function which already would throw providing exactly matching procedure first, and then destructuring as a consequence. Do you not think that it would be awkward to have the exact same pattern syntax for these two cases (matching and

Re: Refutable destructuring

2013-08-16 Thread Dmitry Soshnikov
On Fri, Aug 16, 2013 at 11:26 AM, Kevin Smith zenpars...@gmail.com wrote: And for the strict match one could introduce match(...) function which already would throw providing exactly matching procedure first, and then destructuring as a consequence. Do you not think that it would be

Re: Refutable destructuring

2013-08-16 Thread Kevin Smith
Do you not think that it would be awkward to have the exact same pattern syntax for these two cases (matching and destructuring), but with different semantics? Yes, I don't think so. Hmmm... Let me rephrase. It would be awkward and confusing to have divergent semantics for the same

Re: Refutable destructuring

2013-08-16 Thread Dmitry Soshnikov
On Fri, Aug 16, 2013 at 12:38 PM, Kevin Smith zenpars...@gmail.com wrote: Do you not think that it would be awkward to have the exact same pattern syntax for these two cases (matching and destructuring), but with different semantics? Yes, I don't think so. Hmmm... Let me rephrase. It

Re: Refutable destructuring

2013-08-16 Thread Allen Wirfs-Brock
On Aug 16, 2013, at 12:18 PM, Dmitry Soshnikov wrote: On Fri, Aug 16, 2013 at 11:26 AM, Kevin Smith zenpars...@gmail.com wrote: And for the strict match one could introduce match(...) function which already would throw providing exactly matching procedure first, and then destructuring as

Re: Refutable destructuring

2013-08-16 Thread Brandon Benvie
On 8/16/2013 12:56 PM, Allen Wirfs-Brock wrote: However, I think throwing is like to reveal bugs that might otherwise be missed prior to deployment and as a code reader I would prefer to encounter let {x=undefined) = {}; which communicates much more clearly that there is an expectation that

RE: Refutable destructuring

2013-08-16 Thread Domenic Denicola
Actually, I think it'd be fantastic to have an easy way to communicate required parameters in an options object. It's a fairly common pattern; for example in the S3 library knox that I maintain we require bucket, key, and secret, but everything else has defaults.

Re: Refutable destructuring

2013-08-16 Thread Brandon Benvie
. TypeScript is to ECMAScript as refutable destructuring is to Axel's proposal. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Refutable destructuring

2013-08-16 Thread Brendan Eich
TypeScript exists, and has gained such a following. TypeScript is to ECMAScript as refutable destructuring is to Axel's proposal. Again, this works except in a match construct, where failure to trigger next-pattern attempt must be the default

Re: Refutable destructuring

2013-08-15 Thread David Herman
was that pretty much everyone in the room, at least those who participated in the conversation, felt that refutable destructuring was a mistake, but that we couldn't really come to any conclusions without Brendan and Andreas there, since the two of them had championed refutable destructuring. IOW, we

Re: Refutable destructuring

2013-08-15 Thread David Herman
On Aug 15, 2013, at 9:27 PM, David Herman dher...@mozilla.com wrote: we couldn't really come to any conclusions without Brendan and Andreas there My mistake, Brendan was there. It was only Andreas who wasn't there. Dave ___ es-discuss mailing list

Re: Refutable destructuring

2013-08-14 Thread Dmitry Soshnikov
On Tuesday, August 13, 2013, Allen Wirfs-Brock wrote: On Aug 13, 2013, at 2:31 PM, Brendan Eich wrote: Andreas Rossberg wrote: As I said in my reply, I'm totally fine with what you describe in that mail. But correct me if I'm wrong, that_is_ refutable destructuring, isn't it? All you

Re: Refutable destructuring

2013-08-13 Thread Andreas Rossberg
with a couple slight modification that I had previously described in a private email exchange with you (which I've copied below). As I said in my reply, I'm totally fine with what you describe in that mail. But correct me if I'm wrong, that _is_ refutable destructuring, isn't it? All you seem

Re: Refutable destructuring

2013-08-13 Thread Brendan Eich
Andreas Rossberg wrote: As I said in my reply, I'm totally fine with what you describe in that mail. But correct me if I'm wrong, that_is_ refutable destructuring, isn't it? All you seem to drop is the optional irrefutable part (the '?' feature). That's why I am quite confused about Brendan's

Re: Refutable destructuring

2013-08-13 Thread Allen Wirfs-Brock
On Aug 13, 2013, at 2:31 PM, Brendan Eich wrote: Andreas Rossberg wrote: As I said in my reply, I'm totally fine with what you describe in that mail. But correct me if I'm wrong, that_is_ refutable destructuring, isn't it? All you seem to drop is the optional irrefutable part

Re: Refutable destructuring

2013-08-13 Thread Brendan Eich
Allen Wirfs-Brock wrote: On Aug 13, 2013, at 2:31 PM, Brendan Eich wrote: Andreas Rossberg wrote: As I said in my reply, I'm totally fine with what you describe in that mail. But correct me if I'm wrong, that_is_ refutable destructuring, isn't it? All you seem to drop is the optional

Re: Refutable destructuring

2013-08-12 Thread Andreas Rossberg
On 10 August 2013 22:15, Brendan Eich bren...@mozilla.com wrote: Pattern matching is more precise and flexible, and that's why we considered changing destructuring (which uses the pattern subgrammar) to refutable from irrefutable. Even now with destructuring irrefutable, patterns in catch

Re: Refutable destructuring

2013-08-12 Thread Allen Wirfs-Brock
On Aug 12, 2013, at 2:22 AM, Andreas Rossberg wrote: On 10 August 2013 22:15, Brendan Eich bren...@mozilla.com wrote: Pattern matching is more precise and flexible, and that's why we considered changing destructuring (which uses the pattern subgrammar) to refutable from irrefutable. Even now

Re: Refutable destructuring

2013-08-10 Thread Brian Di Palma
It looks to me like there are people who want a sort of ducktypeof operator. arg1 ducktypeof MyClass Which would return true if the shape of arg1 where the same as MyClass. If I wanted to write as a refutable pattern I could end up with a large block that may be repeated in several class

Re: Refutable destructuring

2013-08-10 Thread Brendan Eich
ES4 had this as like (at one point is like): (arg1 like MyClass) How deep this goes is one design decision; there are lots of others. Pattern matching is more precise and flexible, and that's why we considered changing destructuring (which uses the pattern subgrammar) to refutable from

Re: Refutable destructuring

2013-08-10 Thread Rick Waldron
On Fri, Aug 9, 2013 at 11:52 PM, Brendan Eich bren...@mozilla.com wrote: Rick Waldron wrote: My argument was specifically about the current meaning of the ascii exclamation ! and that assigning it an additional context-based meaning that's quite the opposite of the current unary operator

Refutable destructuring

2013-08-09 Thread Axel Rauschmayer
AFAICT, there is no current consensus on whether destructuring assignment is refutable by default or not: https://github.com/rwldrn/tc39-notes/blob/master/es6/2013-07/july-23.md#44-consider-deferring-es6-refutable-matching Could we make destructuring assignment fail soft and introduce a marker

RE: Refutable destructuring

2013-08-09 Thread Domenic Denicola
Woah. I was sad about the loss of refutable destructuring, i.e. I would rather have had it by default, but this idea is a pretty brilliant way to make lemonade out of lemons. I would *love* a way to declaratively specify required parameters. ___ es

Re: Refutable destructuring

2013-08-09 Thread Rick Waldron
On Fri, Aug 9, 2013 at 5:54 PM, Axel Rauschmayer a...@rauschma.de wrote: AFAICT, there is no current consensus on whether destructuring assignment is refutable by default or not:

Re: Refutable destructuring

2013-08-09 Thread Axel Rauschmayer
While I agree this is interesting and should be explored further, I reject the proposal to add more meaning to the ! character. Given this proposal, ! would sometimes mean not or negate (as in it's current form) and sometimes mean a required thing. Meanwhile, refute is a synonym for

Re: Refutable destructuring

2013-08-09 Thread Brandon Benvie
On 8/9/2013 3:36 PM, Axel Rauschmayer wrote: let { +a: foo, b: bar } = { a: 1 }; // foo = 1, b = undefined let { +a: foo, b: bar } = { }; // exception function bla(+mandatoryArg, optionalArg1, optionalArg2 = 123) { ... } I presume these would also be valid, and do

Re: Refutable destructuring

2013-08-09 Thread Brendan Eich
On Aug 9, 2013, at 3:32 PM, Rick Waldron waldron.r...@gmail.com wrote: On Fri, Aug 9, 2013 at 5:54 PM, Axel Rauschmayer a...@rauschma.de wrote: AFAICT, there is no current consensus on whether destructuring assignment is refutable by default or not:

Re: Refutable destructuring

2013-08-09 Thread Allen Wirfs-Brock
On Aug 9, 2013, at 2:58 PM, Domenic Denicola wrote: Woah. I was sad about the loss of refutable destructuring, i.e. I would rather have had it by default, but this idea is a pretty brilliant way to make lemonade out of lemons. I would *love* a way to declaratively specify required

Re: Refutable destructuring

2013-08-09 Thread Rick Waldron
On Fri, Aug 9, 2013 at 6:40 PM, Brendan Eich bren...@mozilla.com wrote: On Aug 9, 2013, at 3:32 PM, Rick Waldron waldron.r...@gmail.com wrote: On Fri, Aug 9, 2013 at 5:54 PM, Axel Rauschmayer a...@rauschma.de wrote: AFAICT, there is no current consensus on whether destructuring assignment

Re: Refutable destructuring

2013-08-09 Thread Brandon Benvie
On 8/9/2013 4:03 PM, Allen Wirfs-Brock wrote: const MUST = () = {throw TypeError(Missing required parameter}; function foo (a=MUST(), b, c) {...} But that doesn't work for: ```js function foo({ a } = { a: MUST() }){} foo({}); // doesn't throw function bar({ +a }){} bar({}); // would throw

Re: Refutable destructuring

2013-08-09 Thread Allen Wirfs-Brock
On Aug 9, 2013, at 4:21 PM, Brandon Benvie wrote: On 8/9/2013 4:03 PM, Allen Wirfs-Brock wrote: const MUST = () = {throw TypeError(Missing required parameter}; function foo (a=MUST(), b, c) {...} But that doesn't work for: ```js function foo({ a } = { a: MUST() }){} this would

Re: Refutable destructuring

2013-08-09 Thread Allen Wirfs-Brock
On Aug 9, 2013, at 5:37 PM, Allen Wirfs-Brock wrote: On Aug 9, 2013, at 4:21 PM, Brandon Benvie wrote: On 8/9/2013 4:03 PM, Allen Wirfs-Brock wrote: const MUST = () = {throw TypeError(Missing required parameter}; function foo (a=MUST(), b, c) {...} But that doesn't work for:

Re: Refutable destructuring

2013-08-09 Thread Brandon Benvie
On 8/9/2013 5:45 PM, Allen Wirfs-Brock wrote: and if we make U+2639 a special token that evaluated to throw TypeError we could say function foo( {a=☹ }) {} This would be awesome. ___ es-discuss mailing list es-discuss@mozilla.org

Re: Refutable destructuring

2013-08-09 Thread Brendan Eich
Rick Waldron wrote: My argument was specifically about the current meaning of the ascii exclamation ! and that assigning it an additional context-based meaning that's quite the opposite of the current unary operator meaning, Ok, and I'm with you (recall Mark M. wants ! as