Re: Merge map values

2015-04-28 Thread Andrea Giammarchi
Moreover `undefined|0` is exactly 0. The `|0` is used in asm.js because it explicitly declares the intent. So again, no error in there ;-) Regards On Tue, Apr 28, 2015 at 1:58 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: Now you read again the exercise and realize that's

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Kevin Smith
So, ES6 Promises reflect a specific set of design decisions, including a specific definition of same type that appears to exist solely for use by Promise.resolve. All that design guarantees is that the object has an certain specific internal slot whose value is tested in a specific way by

Re: is an iterator allowed to reuse the same state object?

2015-04-28 Thread Allen Wirfs-Brock
On Apr 28, 2015, at 4:21 PM, John Lenz wrote: You would hope that the engines might be able to create these objects on the stack but I don't think anyone does that yet and the result is a flood of eden objects. I would like to know I'm wrong about this. did you see

Re: is an iterator allowed to reuse the same state object?

2015-04-28 Thread John Lenz
I missed it, thanks.I know things will improve in time but I'm just coming from a discussion with folks complaining about the performance of generators and GC overhead in real code with Chrome and Firefox relative to simple hand written loops. On Tue, Apr 28, 2015 at 4:28 PM, Allen

Re: is an iterator allowed to reuse the same state object?

2015-04-28 Thread John Lenz
You would hope that the engines might be able to create these objects on the stack but I don't think anyone does that yet and the result is a flood of eden objects. I would like to know I'm wrong about this. On Apr 27, 2015 4:59 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Apr 27,

Re: Merge map values

2015-04-28 Thread Kevin Smith
Another option: var map = new Map; Array.from(mainn) .map(c = c.toLowerCase()) .forEach(c = map.set(c, (map.get(c) | 0) + 1)); This kind of question is probably better left for StackOverflow, however. ___ es-discuss mailing list

RE: Merge map values

2015-04-28 Thread Mohan.Radhakrishnan
I agree this is not about the ES6 spec. But the answers helped because I was trying to understand ES6’s arrow function that is similar to lambdas. Thanks. From: Andrea Giammarchi [mailto:andrea.giammar...@gmail.com] Sent: Tuesday, April 28, 2015 6:02 PM To: Kevin Smith Cc: Axel Rauschmayer;

Re: Merge map values

2015-04-28 Thread Andrea Giammarchi
Now you read again the exercise and realize that's impossible to have as a piutfall ... no, I just used a KISS approach for what I can tell, no pitfalls with one single surrogate could happen by specs. Best Regards On Tue, Apr 28, 2015 at 1:57 PM, Axel Rauschmayer a...@rauschma.de wrote: With

Re: Merge map values

2015-04-28 Thread Axel Rauschmayer
The best I can come up with is a totally different, less functional approach: ```js const s = 'mainn'; let map = new Map(); for (let ch of s) { ch = ch.toLowerCase(); const prevCount = map.get(ch) || 0; map.set(ch, prevCount+1); } ``` On 28 Apr 2015, at 10:52 ,

Re: Merge map values

2015-04-28 Thread Andrea Giammarchi
Not sure why everyone went for the `Map` version when in JS every object is basically the equivalent of a `Map` already :-) ```js let m = Array.from(mainn).reduce((m,k) = ((m[k] = 1 + (m[k] | 0)), m), {}); ``` looks a win to me, if you need to check or drop chars from the string I would probably

Re: Merge map values

2015-04-28 Thread Andrea Giammarchi
Sorry Axel, I was rushing, it sounded over-rude ... so, yes, Map are better for words, **but** in this specific case it was about all chars/surrogate pairs, that's why I've said Objects where safe ... plus the rest, reduce also is very handy for this exact kind of things ;-) But yes, if it was a

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Claude Pache
Le 26 avr. 2015 à 00:58, Kevin Smith zenpars...@gmail.com a écrit : If we used x.constructor to determine the actual constructor, then someone could just change the constructor property for x and fool someone who wrote C.resolve(x) and expected to get an instance of C back. Note that if

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Kevin Smith
Domenic, Kevin: the concern about Reflect.construct seems misplaced, but in any event, the issue C. Scott raises wants addressing on its own. WDYT? Yeah, sorry for dwelling on Reflect.construct so much (it's in my mind for other reasons). So what would the ideal Promise.resolve semantics do?

Declaration binding instationationing

2015-04-28 Thread Garrett Smith
There is an English problem here: Let existingProp be the resulting of calling the [[GetProperty]] internal method of go with argument fn. Can the spec be made easier to read? -- Garrett @xkit ChordCycles.com garretts.github.io personx.tumblr.com ___

Re: {Spam?} Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Brendan Eich
Kevin Smith wrote: So what would the ideal Promise.resolve semantics do? I'm not sure, maybe use SpeciesConstructor instead of [[PromiseConstructor]]? This removes the wart in my view, has no less integrity. C. Scott? /be ___ es-discuss mailing

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Brendan Eich
C. Scott Ananian wrote: It seems to me that this is an incomplete feature that should have been dropped from the spec. Seems like. I apologize for not noticing this sooner. No need -- thanks for finding it. Domenic, Kevin: the concern about Reflect.construct seems misplaced, but in any

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Allen Wirfs-Brock
On Apr 28, 2015, at 1:08 PM, Kevin Smith wrote: What is the use case for third argument to Reflect.construct? The primary use case is emulating the super() call semantics in a Proxy construct trap handler. Allen ___ es-discuss mailing list

Merge map values

2015-04-28 Thread Mohan.Radhakrishnan
Hi, I am using ES6 by transpiling. The features remind me of Java lambdas. If I have a string 'mainn' then my map should contain this. [a=1, i=1, m=1, n=2] Java : Example. I may not need the TreeMap here. String s = __mainn__.replaceAll([^a-z\\s], ); final MapCharacter, Integer count =

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Tom Van Cutsem
2015-04-28 5:01 GMT+02:00 Kevin Smith zenpars...@gmail.com: Looking over the Reflect namespace, I also see that Reflect.get and Reflect.set have been given powers not expressible with syntax: the receiver does not have to be a prototype parent of the target. Did you mean the receiver does

Re: Merge map values

2015-04-28 Thread Jordan Harband
Would `new Map(maps.reduce((e, m) = e.concat(Array.from(m)), []))` not create a new Map from merging an array of `maps`? (It relies on the `Map.prototype.[Symbol.iterator]` which is `Map#entries`, and the `iterable` argument of the `Map` constructor) On Tue, Apr 28, 2015 at 6:06 AM, Andrea

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread Allen Wirfs-Brock
On Apr 27, 2015, at 8:01 PM, Kevin Smith wrote: x = Reflect.construct(Promise, x, C); is another fine way to fool someone who wrote C.resolve(x) and expected to get an instance of C back. Thanks for pointing this out. I believe the ability to use an arbitrary newTarget parameter for

RE: Merge map values

2015-04-28 Thread Mohan.Radhakrishnan
It could be something like this. But if this is done internall then we don't need code to explicitly manipulate the Map. let m = new Map(); m.set(x,1); //set other keys //for (let value of m.entries()){ //if (Object.keys(m).every((key) = m[key] == value[key])){ //Merge //} //}

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-28 Thread C. Scott Ananian
On Tue, Apr 28, 2015 at 2:41 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: So, ES6 Promises reflect a specific set of design decisions, including a specific definition of same type that appears to exist solely for use by Promise.resolve. All that design guarantees is that the object has