Re: *.empty Idea

2015-02-23 Thread Andrea Giammarchi
quick one to whoever will write the proposal: please bear in mind the empty function **must** have a frozen prototype too Regards On Sun, Feb 22, 2015 at 11:18 PM, Jordan Harband ljh...@gmail.com wrote: I'd love to bring a proposal to the committee for this since it seems like there's

Re: How would we copy... Anything?

2015-02-23 Thread Andreas Rossberg
On 23 February 2015 at 10:37, David Bruant bruan...@gmail.com wrote: Le 23/02/2015 10:10, Michał Wadas a écrit : Cloning objects is long requested feature. clone object javascript yields 1 480 000 results in Google. I'd like to share this as an answer

RE: Global method calls

2015-02-23 Thread Domenic Denicola
(es-discuss to bcc) I see the attraction of having [Global] do all the work for us, for all the logistical reasons you mention. But I still really don't like the action-at-a-distance on EventTarget. Maybe this is a happy medium? - [Global]/[PrimaryGlobal] = operations from the interface or

Re: short-circuiting Array.prototype.reduce

2015-02-23 Thread Mark S. Miller
We still an an option open to us, that would merely compatibly remove a restriction from the language rather than add a feature: Allow labels to remain visible across function boundaries, or at least across arrow function boundaries. Then one could break-to-label to a label of a lexically

Re: short-circuiting Array.prototype.reduce

2015-02-23 Thread Allen Wirfs-Brock
On Feb 23, 2015, at 7:22 AM, Mark S. Miller wrote: We still an an option open to us, that would merely compatibly remove a restriction from the language rather than add a feature: Allow labels to remain visible across function boundaries, or at least across arrow function boundaries. Then

Re: State of the Loader API

2015-02-23 Thread Ian MacLeod
I think its latest home is https://github.com/whatwg/loader/ On Mon, Feb 23, 2015, 02:03 David Bruant bruan...@gmail.com wrote: Hi, I was trying to find the module Loader in the latest draft, but found out that it's been removed from it [1][2]. YK: The loader pipeline will be done in a

A Declarative replacement for toMethod

2015-02-23 Thread Allen Wirfs-Brock
Here is a new proposal for a declarative replacement for Function.prototype.toMethod which was dropped from ES6 earlier this year https://github.com/allenwb/ESideas/blob/master/dcltomethod.md I've added this to the agenda for next months TC39 meeting but pre-meeting discussion is welcomed

Re: How would we copy an iterator?

2015-02-23 Thread Salvador de la Puente González
El 23/02/2015 20:29, Brendan Eich bren...@mozilla.org escribió: Benjamin (Inglor) Gruenbaum wrote: Of course this example is contrived! It's the simplest example I could think of. I do think it stands for every example of any iterator that takes any input from `.send` or `.throw`. I have

Re: short-circuiting Array.prototype.reduce

2015-02-23 Thread Dmitry Soshnikov
On Mon, Feb 23, 2015 at 10:09 AM, Andreas Rossberg rossb...@google.com wrote: On 23 February 2015 at 16:22, Mark S. Miller erig...@google.com wrote: We still an an option open to us, that would merely compatibly remove a restriction from the language rather than add a feature: Allow labels to

Re: How would we copy an iterator?

2015-02-23 Thread Benjamin (Inglor) Gruenbaum
Why not? The generator would switch on sent value, in a loop. Well, let's say we have an iterator that does nothing once, returns what was sent to it the first 5 times and then is done: ```js function* gen(){ var res = yield; for(var i = 0; i 5; i++){ res = yield res; } } var iter =

Re: short-circuiting Array.prototype.reduce

2015-02-23 Thread Brendan Eich
Mark S. Miller wrote: My other suspicion: The previous failure of this proposal was before many people had much hands on experience using higher order functions in JS as a normal alternative to control structures. Now that we all have, the need for a non-local escape may be more visceral.

Re: How would we copy an iterator?

2015-02-23 Thread Brendan Eich
Benjamin (Inglor) Gruenbaum wrote: Of course this example is contrived! It's the simplest example I could think of. I do think it stands for every example of any iterator that takes any input from `.send` or `.throw`. I have plenty of other contrived examples (implementing `fork` like this by

Re: Array.prototype change (Was: @@toStringTag spoofing for null and undefined)

2015-02-23 Thread Brendan Eich
No one has taken my bet :-P. /be Mark S. Miller wrote: On Sun, Feb 22, 2015 at 3:12 PM, Mark S. Miller erig...@google.com mailto:erig...@google.com wrote: Array.prototype has reverted to being an empty initially empty exotic array object. Function.prototype remains a no-op

Re: How would we copy an iterator?

2015-02-23 Thread Benjamin (Inglor) Gruenbaum
Of course this example is contrived! It's the simplest example I could think of. I do think it stands for every example of any iterator that takes any input from `.send` or `.throw`. I have plenty of other contrived examples (implementing `fork` like this by using generators for coroutines with

Re: Array.prototype change (Was: @@toStringTag spoofing for null and undefined)

2015-02-23 Thread Mark S. Miller
Since gambling with real money is technically still illegal, I have responded to Brendan privately. On Mon, Feb 23, 2015 at 10:35 AM, Brendan Eich bren...@mozilla.org wrote: No one has taken my bet :-P. /be Mark S. Miller wrote: On Sun, Feb 22, 2015 at 3:12 PM, Mark S. Miller

Re: short-circuiting Array.prototype.reduce

2015-02-23 Thread Andreas Rossberg
On 23 February 2015 at 16:22, Mark S. Miller erig...@google.com wrote: We still an an option open to us, that would merely compatibly remove a restriction from the language rather than add a feature: Allow labels to remain visible across function boundaries, or at least across arrow function

Re: How would we copy an iterator?

2015-02-23 Thread Brendan Eich
Salvador de la Puente González wrote: Yep. This was already discussed in the topic I mentioned before. Just to remember, the real problem with tee() is that the generators are not actually independent as you can not .send() different information to each one to make them diverge. Why not?

Re: *.empty Idea

2015-02-23 Thread Isiah Meadows
On Feb 23, 2015 6:06 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: quick one to whoever will write the proposal: please bear in mind the empty function **must** have a frozen prototype too Regards Andrea, good catch. On Sun, Feb 22, 2015 at 11:18 PM, Jordan Harband

Re: *.empty Idea

2015-02-23 Thread Mark S. Miller
On Mon, Feb 23, 2015 at 11:59 AM, Isiah Meadows isiahmead...@gmail.com wrote: On Feb 23, 2015 6:06 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: On Sun, Feb 22, 2015 at 11:18 PM, Jordan Harband ljh...@gmail.com wrote: [...] - We'd definitely want `Map.empty` and `Set.empty`

Re: How would we copy an iterator?

2015-02-23 Thread Tab Atkins Jr.
On Mon, Feb 23, 2015 at 10:34 AM, Brendan Eich bren...@mozilla.org wrote: Salvador de la Puente González wrote: Yep. This was already discussed in the topic I mentioned before. Just to remember, the real problem with tee() is that the generators are not actually independent as you can not

Re: A Declarative replacement for toMethod

2015-02-23 Thread Fabrício Matté
``` PostfixExpression : [...] MixinExpression [no LineTerminator here] ++ MixinExpression [no LineTerminator here] -- ``` Is this a typo? What is the point of the `++`/`--` postfix operators after a `MixinExpression`? /fm ___ es-discuss

Re: A Declarative replacement for toMethod

2015-02-23 Thread Kevin Smith
``` PostfixExpression : [...] MixinExpression [no LineTerminator here] ++ MixinExpression [no LineTerminator here] -- ``` Is this a typo? What is the point of the `++`/`--` postfix operators after a `MixinExpression`? It's establishing the precedence of the MixinExpression

Re: A Declarative replacement for toMethod

2015-02-23 Thread Brendan Eich
Minor wording nit-pick/question: In what sense is an operator form declarative? I get that it's not an API -- special form is special ;-). But what's being declared if the only grammar extension is to the expression grammar? /be Allen Wirfs-Brock wrote: Here is a new proposal for a

Re: A Declarative replacement for toMethod

2015-02-23 Thread Fabrício Matté
It's establishing the precedence of the MixinExpression between PostfixExpression and LeftHandSideExpression. Thanks Kevin, I thought it could be the case, but I still can't see when that is relevant -- as far as I can see, the resulting value of a mixinExpression is always an object (or a

Re: A Declarative replacement for toMethod

2015-02-23 Thread Allen Wirfs-Brock
On Feb 23, 2015, at 2:44 PM, Brendan Eich wrote: Minor wording nit-pick/question: In what sense is an operator form declarative? I get that it's not an API -- special form is special ;-). But what's being declared if the only grammar extension is to the expression grammar? I know, one

Re: A Declarative replacement for toMethod

2015-02-23 Thread Claude Pache
Le 23 févr. 2015 à 21:47, Allen Wirfs-Brock al...@wirfs-brock.com a écrit : Here is a new proposal for a declarative replacement for Function.prototype.toMethod which was dropped from ES6 earlier this year https://github.com/allenwb/ESideas/blob/master/dcltomethod.md

Re: How would we copy an iterator?

2015-02-23 Thread Brendan Eich
Tab Atkins Jr. wrote: (Not saying anything needs to be added right now. Just pointing out the specifics, as it seemed you were talking past each other.) Thanks, I was thinking beyond tee as a generic, which copies (requiring a set-aside, could be a lot of memory). If the cliff leads to

Re: How would we copy... Anything?

2015-02-23 Thread Anne van Kesteren
On Mon, Feb 23, 2015 at 10:10 AM, Michał Wadas michalwa...@gmail.com wrote: My proposition is to create a new well known Symbol - Symbol.clone and corresponding method on Object - Object.clone. Anything that does not deal with https://github.com/dslomov-chromium/ecmascript-structured-clone

How would we copy... Anything?

2015-02-23 Thread Michał Wadas
Cloning objects is long requested feature. clone object javascript yields 1 480 000 results in Google. My proposition is to create a new well known Symbol - Symbol.clone and corresponding method on Object - Object.clone. Default behavior for an object is to throw on clone try.

Re: How would we copy... Anything?

2015-02-23 Thread David Bruant
Hi, Le 23/02/2015 10:10, Michał Wadas a écrit : Cloning objects is long requested feature. clone object javascript yields 1 480 000 results in Google. I'd like to share this as an answer http://facebook.github.io/immutable-js/#the-case-for-immutability If an object is immutable, it can be

State of the Loader API

2015-02-23 Thread David Bruant
Hi, I was trying to find the module Loader in the latest draft, but found out that it's been removed from it [1][2]. YK: The loader pipeline will be done in a living spec (a la HTML5) so that Node and the browser can collaborate on shared needs. I haven't been able to find this new document

Re: How would we copy... Anything?

2015-02-23 Thread Michał Wadas
I'm aware about structured clone, but there is a basic difference - structured clone is a way to copy object to other Realm, Symbol.clone would be a more powerful (supporting constructors, classes and functions) way to clone objects. On Feb 23, 2015 10:29 AM, Anne van Kesteren ann...@annevk.nl

Re: A Declarative replacement for toMethod

2015-02-23 Thread Mark S. Miller
I'm not sure I get it. I am very impressed by Allen's point about using lambda abstraction (Allen said procedural abstraction) to parameterize a super binding. Could you show a small self contained example that uses toMethod to do some metaprogramming that cannot be done with Allen's mixin, where

Re: A Declarative replacement for toMethod

2015-02-23 Thread Brendan Eich
Allen Wirfs-Brock wrote: Note that the lambda abstraction technique also can support a dynamically provided method name: let aVarNamedMixin = (obj, name) = obj mixin { [name] () { //do something super[name]() } } That's not bad. Never reach for eval where a function will do.

Re: A Declarative replacement for toMethod

2015-02-23 Thread Isiah Meadows
What about this? Would this satisfy the metaprogramming problem? ```js Object.getOwnPropertyNames(obj) .map(name = [name, obj[name]]) .filter(keepCorrectFunctions) .map(([name, f]) = { obj mixin { [name + 'Async'](...args) { return new Promise((resolve, reject) = f.call(this,

Re: A Declarative replacement for toMethod

2015-02-23 Thread Brendan Eich
I wonder why we cannot have toMethod, in due course. You had suggested the ES6 signature with a second parameter, with default value: Function.prototype.toMethod(homeObject, methodName = this.name); With a function.name spec'ed in ES6, that might be enough to address the concerns raised by

Re: A Declarative replacement for toMethod

2015-02-23 Thread Kevin Smith
Doh! Nevermind. I get it. Can you explain what you realized, briefly? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: *.empty Idea

2015-02-23 Thread Isiah Meadows
On Feb 23, 2015 3:31 PM, Mark S. Miller erig...@google.com wrote: On Mon, Feb 23, 2015 at 11:59 AM, Isiah Meadows isiahmead...@gmail.com wrote: On Feb 23, 2015 6:06 AM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: On Sun, Feb 22, 2015 at 11:18 PM, Jordan Harband ljh...@gmail.com

Re: A Declarative replacement for toMethod

2015-02-23 Thread Mark S. Miller
That if you are given a method with an already bound super, toMethod allows you to create a method like it with a different super binding -- without source manipulation. mixin does not -- again, without source manipulation. I like Allen's point about [[HomeObject]] being like [[Scope]]. They are

Re: A Declarative replacement for toMethod

2015-02-23 Thread Allen Wirfs-Brock
On Feb 23, 2015, at 4:24 PM, Brendan Eich wrote: I wonder why we cannot have toMethod, in due course. You had suggested the ES6 signature with a second parameter, with default value: Function.prototype.toMethod(homeObject, methodName = this.name); With a function.name spec'ed in ES6,

Re: A Declarative replacement for toMethod

2015-02-23 Thread Mark S. Miller
Doh! Nevermind. I get it. On Mon, Feb 23, 2015 at 4:13 PM, Mark S. Miller erig...@google.com wrote: I'm not sure I get it. I am very impressed by Allen's point about using lambda abstraction (Allen said procedural abstraction) to parameterize a super binding. Could you show a small self

Re: *.empty Idea

2015-02-23 Thread Mark S. Miller
Only that the proxy can detect each of the operations as a distinct trap, and do something weird. A proxy that intend to emulate anything like a normal object would choose not to, preserving by convention this equivalence. It becomes a matter of informal unchecked contract conformance, rather than

Re: A Declarative replacement for toMethod

2015-02-23 Thread Allen Wirfs-Brock
On Feb 23, 2015, at 3:40 PM, Domenic Denicola wrote: Allen and I have been discussing this on Twitter. I thought I’d bring my thoughts to list to get them somewhere with less of a character limit. In general, I think this is a pretty nice syntax for authors. However, I'm concerned that

Re: A Declarative replacement for toMethod

2015-02-23 Thread Benjamin (Inglor) Gruenbaum
A programmer who wrote the assignment aPusher.push = MyArray.prototype.push was probably thinking that they could just reuse the push method from MyArray.prototype and that the super.push call within it would start searching for a push method at the [[Prototype]] of aPusher. But it doesn't. As a

Re: How would we copy an iterator?

2015-02-23 Thread Brendan Eich
Benjamin (Inglor) Gruenbaum wrote: Why not? The generator would switch on sent value, in a loop. Well, let's say we have an iterator that does nothing once, returns what was sent to it the first 5 times and then is done: ```js function* gen(){ var res = yield; for(var i = 0; i 5; i++){

RE: A Declarative replacement for toMethod

2015-02-23 Thread Domenic Denicola
Allen and I have been discussing this on Twitter. I thought I’d bring my thoughts to list to get them somewhere with less of a character limit. In general, I think this is a pretty nice syntax for authors. However, I'm concerned that it doesn't satisfy the metaprogramming use case that