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