RE: Having a non-enumerable Array.prototype.contains may not beweb-compatible

2014-10-01 Thread Andrea Giammarchi
many MDN examples are on jsfiddle ...maybe one of the reasons? Although I wasn't suggesting to break everything, rather saying that changing name should not be an option. -Original Message- From: John-David Dalton john.david.dal...@gmail.com Sent: ‎01/‎10/‎2014 00:54 To: Jason

Re: Array.prototype.contains solutions

2014-10-01 Thread Brendan Eich
Mark S. Miller wrote: On Tue, Sep 30, 2014 at 4:58 PM, Domenic Denicola dome...@domenicdenicola.com mailto:dome...@domenicdenicola.com wrote: I see a few options: 1. Rename. The leading candidate would be `Array.prototype.has`. I outlined in [1] why `contains` is better; note

Re: Array.prototype.contains solutions

2014-10-01 Thread Andrea Giammarchi
1. I wasn't advocating to break the web but to **not** change the name because of a library bug, the initial thread spoiler was not needed 2. the `@@enumerableWhenAssigned` might lead to shenanigans but it's *polyfillable* which is IMO preferable if it can solve somehow the problem ```js

Re: Toplevel 'let' binding can be left permanently uninitialized after an error

2014-10-01 Thread Andreas Rossberg
On 30 September 2014 22:38, David Herman dher...@mozilla.com wrote: On Sep 30, 2014, at 4:03 AM, Andreas Rossberg rossb...@google.com wrote: On 30 September 2014 12:52, Jason Orendorff jason.orendo...@gmail.com wrote: I just realized this has an unfortunate implication for REPLs. Suppose

Re: Array.prototype.contains solutions

2014-10-01 Thread Brendan Eich
Andrea Giammarchi wrote: 1. I wasn't advocating to break the web but to **not** change the name because of a library bug, the initial thread spoiler was not needed I wasn't responding to you, here on this thread (where you hadn't posted till now) or on the other one, so why are you jumping

Re: Array.prototype.contains solutions

2014-10-01 Thread Claude Pache
Le 1 oct. 2014 à 04:43, Mark S. Miller erig...@google.com a écrit : I suggest we focus on the override mistake. If we come up with a way of fixing it and .contains with one new kernel mechanism, that would be great. If we only fix the override mistake, still likely worth it. But if a new

RE: Array.prototype.contains solutions

2014-10-01 Thread Domenic Denicola
Thanks Claude for filling in some of the details in my vague thinking. I guess I/we should try to come up with something more detailed, and see how/if it is able to address Mark's use cases, and how implementable it would be, and how extensively it would help (or not). I tend to agree with

Re: Array.prototype.contains solutions

2014-10-01 Thread Claude Pache
The more I consider the issue, the more I think that the most elegant solution is to complete data properties with an additional overridable attribute, whose purpose is to refine the meaning of the writable attribute in the manner sketched below (in opposition of having an @@unscopables-like

Re: Array.prototype.contains solutions

2014-10-01 Thread Mark Miller
On Wed, Oct 1, 2014 at 12:21 AM, Brendan Eich bren...@mozilla.org wrote: The most painful use case is the existence of perfectly reasonable ES5 code like: function Point(x, y) { this.x = x; this.y = y; } Point.prototype.toString() { return `${x},${y}`; }; You mean

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Erik Arvidsson
The static error is problematic. I'm pretty sure that engines that do lazy parsing of functions is not going to report static errors before doing a full parse of the function. I think we need to either enforce this or remove this restriction. Anything in between will lead to inconsistent behavior

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Oliver Hunt
JSC does lazy parsing of nested functions and we have no problem reporting static errors, so i’m not sure what you believe is the problem here. —Oliver On Oct 1, 2014, at 7:09 AM, Erik Arvidsson erik.arvids...@gmail.com wrote: The static error is problematic. I'm pretty sure that engines

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Mark S. Miller
On Wed, Oct 1, 2014 at 8:20 AM, Oliver Hunt oli...@apple.com wrote: JSC does lazy parsing of nested functions and we have no problem reporting static errors, so i’m not sure what you believe is the problem here. Hi Oliver, First, I agree with you. This shouldn't be a problem. However, both

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Allen Wirfs-Brock
On Oct 1, 2014, at 7:09 AM, Erik Arvidsson wrote: The static error is problematic. I'm pretty sure that engines that do lazy parsing of functions is not going to report static errors before doing a full parse of the function. I think we need to either enforce this or remove this

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Allen Wirfs-Brock
On Oct 1, 2014, at 8:39 AM, Mark S. Miller wrote: ... I was with you until you got to the following point If there is an intervening with or sloppy direct eval, then there is not a statically apparent assignment to a const variable. Since this can only occur in sloppy code anyway, it

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Till Schneidereit
On Wed, Oct 1, 2014 at 5:39 PM, Mark S. Miller erig...@google.com wrote: On Wed, Oct 1, 2014 at 8:20 AM, Oliver Hunt oli...@apple.com wrote: JSC does lazy parsing of nested functions and we have no problem reporting static errors, so i’m not sure what you believe is the problem here. Hi

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Mark S. Miller
Good point. If we can require all such assignments to be rejected statically, why is a runtime assignment to a const variable even possible? Can't we just assert that this cannot occur? On Wed, Oct 1, 2014 at 8:59 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Oct 1, 2014, at 8:39 AM,

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Allen Wirfs-Brock
On Oct 1, 2014, at 9:05 AM, Mark S. Miller wrote: Good point. If we can require all such assignments to be rejected statically, why is a runtime assignment to a const variable even possible? Can't we just assert that this cannot occur? The runtime cases I meant are the ones you mentioned.

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Allen Wirfs-Brock
On Oct 1, 2014, at 9:43 AM, Oliver Hunt wrote: On Oct 1, 2014, at 9:05 AM, Mark S. Miller erig...@google.com wrote: Good point. If we can require all such assignments to be rejected statically, why is a runtime assignment to a const variable even possible? Can't we just assert that

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Mark Miller
On Wed, Oct 1, 2014 at 9:15 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Oct 1, 2014, at 9:05 AM, Mark S. Miller wrote: Good point. If we can require all such assignments to be rejected statically, why is a runtime assignment to a const variable even possible? Can't we just assert

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Allen Wirfs-Brock
On Oct 1, 2014, at 10:30 AM, Mark Miller wrote: On Wed, Oct 1, 2014 at 9:15 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Oct 1, 2014, at 9:05 AM, Mark S. Miller wrote: Good point. If we can require all such assignments to be rejected statically, why is a runtime

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Jason Orendorff
I think there is a way that the error could occur at runtime even in all-strict-mode code: when a new const is added at toplevel in a second script. script use strict; function f(value) { x = value; } /script script use strict; const x = 0; f(1);

Map: filter/map and more

2014-10-01 Thread Dmitry Soshnikov
Hi, (Maps are awesome!) 1. Transforming iteration methods We're currently polyfillying the `Map`, and got some questions form devs. One of them is about transforming iteration methods, like `map` and `filter`. Unfortunately I missed that part of the spec when it was approved, so can someone

Re: Array.prototype.contains solutions

2014-10-01 Thread Brendan Eich
Claude Pache wrote: The more I consider the issue, the more I think that the most elegant solution is to complete data properties with an additional overridable attribute, whose purpose is to refine the meaning of the writable attribute in the manner sketched below (in opposition of having an

Re: Array.prototype.contains solutions

2014-10-01 Thread Mark S. Miller
Does the [[Overridable]] you have in mind also fix the override mistake? It sounds like it should. Regarding shadowable, is there any better documentation than the doc-comment: /* * For ES5 compatibility, we allow properties with PropertyOp-flavored * setters to be shadowed when set. The

Re: Map: filter/map and more

2014-10-01 Thread Dmitry Soshnikov
On Wed, Oct 1, 2014 at 11:57 AM, Rick Waldron waldron.r...@gmail.com wrote: On Wed, Oct 1, 2014 at 2:50 PM, Dmitry Soshnikov dmitry.soshni...@gmail.com wrote: Hi, (Maps are awesome!) 1. Transforming iteration methods We're currently polyfillying the `Map`, and got some questions form

Re: Array.prototype.contains solutions

2014-10-01 Thread Brendan Eich
Mark S. Miller wrote: Does the [[Overridable]] you have in mind also fix the override mistake? It sounds like it should. Yes, definitely. Regarding shadowable, is there any better documentation than the doc-comment: |/*| | * For ES5 compatibility, we allow properties with

Re: Map: filter/map and more

2014-10-01 Thread Axel Rauschmayer
Then thing is: if we'd like to use maps for such use-case, it brings us back to that inconvenient imperative style of assignments (even worse, since you have to repeat that `.set(...)` constantly): ``` var requestData = new Map(); requestData.set(Names.ID, id);

Re: Map: filter/map and more

2014-10-01 Thread Jeremy Martin
Not sure if this is sufficient motivation to accelerate the timeline for adding suitable parallels from Array.prototype, but it may be worth recalling what developers did last time there were obvious gaps in what a native prototype provided. Array#contains, anyone? On Wed, Oct 1, 2014 at 3:28

Re: Map: filter/map and more

2014-10-01 Thread Rick Waldron
On Wed, Oct 1, 2014 at 3:51 PM, Jeremy Martin jmar...@gmail.com wrote: Not sure if this is sufficient motivation to accelerate the timeline It's not about motivation, it's about realistic time constraints. TC39 has already had to push out 6 months and that was not taken well by both the

Re: Map: filter/map and more

2014-10-01 Thread Dmitry Soshnikov
On Wed, Oct 1, 2014 at 12:59 PM, Rick Waldron waldron.r...@gmail.com wrote: On Wed, Oct 1, 2014 at 3:51 PM, Jeremy Martin jmar...@gmail.com wrote: Not sure if this is sufficient motivation to accelerate the timeline It's not about motivation, it's about realistic time constraints. TC39

Re: Map: filter/map and more

2014-10-01 Thread Rick Waldron
On Wed, Oct 1, 2014 at 3:51 PM, Jeremy Martin jmar...@gmail.com wrote: Not sure if this is sufficient motivation to accelerate the timeline for adding suitable parallels from Array.prototype, but it may be worth recalling what developers did last time there were obvious gaps in what a native

Re: Map: filter/map and more

2014-10-01 Thread Rick Waldron
On Wed, Oct 1, 2014 at 4:17 PM, Axel Rauschmayer a...@rauschma.de wrote: On Oct 1, 2014, at 22:12 , Axel Rauschmayer a...@rauschma.de wrote: 1. Transforming iteration methods We're currently polyfillying the `Map`, and got some questions form devs. One of them is about transforming

Re: Map: filter/map and more

2014-10-01 Thread Axel Rauschmayer
Ah, thanks! Then I’d wrap the result of `entries()` in `Array.from()`. In ES7, we’ll hopefully be able to use comprehensions or iterator helper functions. On Oct 1, 2014, at 22:27 , Rick Waldron waldron.r...@gmail.com wrote: On Wed, Oct 1, 2014 at 4:17 PM, Axel Rauschmayer

Re: Map: filter/map and more

2014-10-01 Thread Kevin Smith
```js let map2 = new Map(map1.entries().filter((key, value) = key = 0)); let map2 = new Map(map1.entries().map((key, value) = [key * 2, value * 2])); entries() returns an iterator, not an array. let map2 = new Map([...map1].map(([k, v]) = [k, v * 2])

Re: Map: filter/map and more

2014-10-01 Thread Brendan Eich
Kevin Smith wrote: entries() returns an iterator, not an array. let map2 = new Map([...map1].map(([k, v]) = [k, v * 2]) Sweet! /be ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Map: filter/map and more

2014-10-01 Thread Rick Waldron
On Wed, Oct 1, 2014 at 4:38 PM, Axel Rauschmayer a...@rauschma.de wrote: Ah, thanks! Then I’d wrap the result of `entries()` in `Array.from()`. In ES7, we’ll hopefully be able to use comprehensions or iterator helper functions. Don't need to do that either. let map1 = new Map([[-1, -1], [0,

Re: Map: filter/map and more

2014-10-01 Thread Rick Waldron
On Wed, Oct 1, 2014 at 4:41 PM, Kevin Smith zenpars...@gmail.com wrote: ```js let map2 = new Map(map1.entries().filter((key, value) = key = 0)); let map2 = new Map(map1.entries().map((key, value) = [key * 2, value * 2])); entries() returns an iterator, not an array. let map2 = new

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Brendan Eich
Right. Need a complete semantics: static and runtime. News at 11, /be Jason Orendorff wrote: I think there is a way that the error could occur at runtime even in all-strict-mode code: when a new const is added at toplevel in a second script. script use strict; function

Re: Throwing errors on mutating immutable bindings

2014-10-01 Thread Brendan Eich
Yup, and we've talked about this at TC39 meetings. We need a simple-enough static analysis, and runtime errors for the residue that escapes that analysis. I hope this is not controversial! /be Erik Arvidsson wrote: The static error is problematic. I'm pretty sure that engines that do lazy

Re: Array.prototype.contains solutions

2014-10-01 Thread Jason Orendorff
I'd love to be able to get rid of SHADOWABLE, actually! I just recently found out we can do it with a little rearranging. Extra state-space in property attributes is unavoidable complexity for us. My own preference would be not to standardize it. :) There's also the [Replaceable] attribute in

Re: Map: filter/map and more

2014-10-01 Thread Dmitry Soshnikov
On Wed, Oct 1, 2014 at 1:26 PM, Dmitry Soshnikov dmitry.soshni...@gmail.com wrote: On Wed, Oct 1, 2014 at 12:59 PM, Rick Waldron waldron.r...@gmail.com wrote: On Wed, Oct 1, 2014 at 3:51 PM, Jeremy Martin jmar...@gmail.com wrote: Not sure if this is sufficient motivation to accelerate

Re: Map: filter/map and more

2014-10-01 Thread Dmitry Soshnikov
On Wed, Oct 1, 2014 at 12:28 PM, Axel Rauschmayer a...@rauschma.de wrote: Then thing is: if we'd like to use maps for such use-case, it brings us back to that inconvenient imperative style of assignments (even worse, since you have to repeat that `.set(...)` constantly): ``` var

Re: Array.prototype.contains solutions

2014-10-01 Thread Brendan Eich
Jason Orendorff wrote: I'd love to be able to get rid of SHADOWABLE, actually! I just recently found out we can do it with a little rearranging. Extra state-space in property attributes is unavoidable complexity for us. My own preference would be not to standardize it.:) There's also the

Re: Map: filter/map and more

2014-10-01 Thread Dmitry Soshnikov
On Wed, Oct 1, 2014 at 1:38 PM, Rick Waldron waldron.r...@gmail.com wrote: On Wed, Oct 1, 2014 at 4:26 PM, Dmitry Soshnikov dmitry.soshni...@gmail.com wrote: On Wed, Oct 1, 2014 at 12:59 PM, Rick Waldron waldron.r...@gmail.com wrote: On Wed, Oct 1, 2014 at 3:51 PM, Jeremy Martin

Re: Map: filter/map and more

2014-10-01 Thread Brendan Eich
Dmitry Soshnikov wrote: Not ideal either. Usually langs provide nice declarative syntax for such things. E.g. we have[1] the same in the HACK language, and use it well everyday when need a map. But this part is of course not for ES6, hope ES7-ish. [1]

Re: Map: filter/map and more

2014-10-01 Thread Dmitry Soshnikov
On Wed, Oct 1, 2014 at 4:51 PM, Brendan Eich bren...@mozilla.org wrote: Dmitry Soshnikov wrote: Not ideal either. Usually langs provide nice declarative syntax for such things. E.g. we have[1] the same in the HACK language, and use it well everyday when need a map. But this part is of

Re: Map: filter/map and more

2014-10-01 Thread Axel Rauschmayer
We could definitely have Map and Set literals: const map = {1 = one, two = true, false = three}; Would that be tricky to parse if keys can be arbitrary expressions (incl. array literals)? const set = {1, two, false}; If you still buy Harmony of My Dreams, prefix # before { to get

Re: Map: filter/map and more

2014-10-01 Thread Brendan Eich
Axel Rauschmayer wrote: We could definitely have Map and Set literals: const map = {1 = one, two = true, false = three}; Would that be tricky to parse if keys can be arbitrary expressions (incl. array literals)? The issue would be arrow function expression keys: const map = {x = x*x =