Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-10 Thread Tom Van Cutsem
2011/11/9 Allen Wirfs-Brock al...@wirfs-brock.com On Nov 9, 2011, at 3:53 AM, Tom Van Cutsem wrote: - lots of methods on Array.prototype (map, forEach, filter, some, reduce, reduceRight, reverse, splice, indexOf, lastIndexOf, every, shift, slice, sort, unshift): the only way in which these

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-10 Thread Tom Van Cutsem
2011/11/9 Allen Wirfs-Brock al...@wirfs-brock.com [[Get]] seems to do nothing but redispatch to [[GetP]] so its definition could be replaced with the body of [[GetP]]. [[Puit] does a redispatch to [[SetP]] followed by a mode based conditional throw depending upon the result of the [[SetP]].

Re: `this`: methods versus functions

2011-11-10 Thread Axel Rauschmayer
Clever (took me a moment to figure out what the comma operator does here...). And makes sense: You would not want an invoker to have that kind of power. If it wasn’t so negative for performance, I probably would apply curryThis() to all of my methods: var obj = { method: function

Re: `this`: methods versus functions

2011-11-10 Thread Andreas Rossberg
On 10 November 2011 14:49, Axel Rauschmayer a...@rauschma.de wrote: getX() is designed for a dynamic `this` (i.e. `this` is an instance of InnerPoint). My proposal would allow an external party to switch to lexical `this` (=== function Outer), simply by invoking it as a (non-method) function.

Re: `this`: methods versus functions

2011-11-10 Thread Axel Rauschmayer
Any suggestion for improvement is highly welcome. But it seems like we can’t do better than a construct that declares statically, how its `this` should be passed to it. The cool thing about block lambdas is that you do the right thing without thinking about it. That’s why, if we got arrow

Re: `this`: methods versus functions

2011-11-10 Thread Axel Rauschmayer
I wonder if it made a difference if `this`was always stored in an environment (instead of an execution context). Then block lambdas could find them via the scope chain. If I understand you correctly, then yes, this is definitely possible in principle, and in fact corresponds to the standard

Re: `this`: methods versus functions

2011-11-10 Thread Andreas Rossberg
On 10 November 2011 15:58, Axel Rauschmayer a...@rauschma.de wrote: I wonder if it made a difference if `this`was always stored in an environment (instead of an execution context). Then block lambdas could find them via the scope chain. If I understand you correctly, then yes, this is

What do we still need from a class-like abstraction (was: `this`: methods versus functions)

2011-11-10 Thread Mark S. Miller
Note that the traitsjs library provides: 1) all the safety of the objects-as-closure pattern you show below (and more because it takes care of the needed freezing). 2) still allows intuitive use of this to refer to the instance itself, bound not lexically, but rather at object instantiation time.

Internal and external object APIs (was: [Proxies] Refactoring prototype climbing in the spec)

2011-11-10 Thread David Bruant
Le 10/11/2011 12:28, David Bruant a écrit : (...) but i think [traps] should be a right balance between the internal and external API. Internal object API: * getPropertyDescriptor(propName) * setPropertyDescriptor(propName, desc) (more or less equivalent to the current [[DefineOwnProperty]])

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-10 Thread Allen Wirfs-Brock
On Nov 10, 2011, at 1:36 AM, Tom Van Cutsem wrote: 2011/11/9 Allen Wirfs-Brock al...@wirfs-brock.com [[Get]] seems to do nothing but redispatch to [[GetP]] so its definition could be replaced with the body of [[GetP]]. [[Puit] does a redispatch to [[SetP]] followed by a mode based

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-10 Thread Allen Wirfs-Brock
On Nov 10, 2011, at 1:26 AM, Tom Van Cutsem wrote: Are you sure you want to kill [[HasProperty]] entirely? If we replace it by a conditional [[Get]], wouldn't that mean that the expression |name in obj| might unnecessarily trigger an accessor in obj? Good point, I didn't think about

Re: What do we still need from a class-like abstraction (was: `this`: methods versus functions)

2011-11-10 Thread Andreas Rossberg
I wholeheartedly agree that mixin composition is superior to both prototype and class-based inheritance. I'm not sure I entirely follow your point regarding `this', though. (TBH, I'd prefer not having a `this' keyword at all, because not being alpha-convertible, it doesn't really compose with

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-10 Thread Tom Van Cutsem
2011/11/10 Allen Wirfs-Brock al...@wirfs-brock.com On Nov 10, 2011, at 1:36 AM, Tom Van Cutsem wrote: - Object.getProperty and Object.setProperty built-ins that call [[GetProperty]] and [[SetProperty]] Also, to fully reify property manipulation I think we also need to factor [[Delete]]

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-10 Thread Allen Wirfs-Brock
On Nov 10, 2011, at 3:28 AM, David Bruant wrote: Le 09/11/2011 12:17, Tom Van Cutsem a écrit : 2011/11/8 Allen Wirfs-Brock al...@wirfs-brock.com More generally, I think there should be a 1::1 correspondence between the internal methods in listed in ES5 Table 8 and fundamental proxy

Re: What do we still need from a class-like abstraction (was: `this`: methods versus functions)

2011-11-10 Thread Jake Verbaten
The only value prototype inheritance gives is the fact you can change the prototype and changes are reflected. If you do not want that feature then use mixins. On Thu, Nov 10, 2011 at 4:56 PM, Andreas Rossberg rossb...@google.comwrote: I wholeheartedly agree that mixin composition is superior

Function proxies without explicit construct trap

2011-11-10 Thread Andreas Rossberg
I think the specification of [[Construct]] for function proxies may not currently be doing what it is intended to do. If the proxy does not have a construct trap, the method simply delegates to the [[Construct]] method of the call trap. AFAICS, that has two consequences: 1. The prototype is taken

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-10 Thread Allen Wirfs-Brock
On Nov 10, 2011, at 9:03 AM, Tom Van Cutsem wrote: 2011/11/10 Allen Wirfs-Brock al...@wirfs-brock.com On Nov 10, 2011, at 1:36 AM, Tom Van Cutsem wrote: - Object.getProperty and Object.setProperty built-ins that call [[GetProperty]] and [[SetProperty]] Also, to fully reify property

Re: Minimalist Classes

2011-11-10 Thread Irakli Gozalishvili
Hi, Sorry have not had a chance to reply on this thread earlier. I do really like the direction that Jeremy pushes to, but still I don't understand why do we need to introduce new syntax to the language. I think `class` expression is completely unnecessary, why not a function ? I forked

Re: What do we still need from a class-like abstraction (was: `this`: methods versus functions)

2011-11-10 Thread Brendan Eich
On Nov 10, 2011, at 7:59 AM, Mark S. Miller wrote: My previous proposal for class-like sugar for traits composition was not popular. Whereas, in the absence of problem #5, I suspect the traitsjs library would be. As previously observed on this list, traitsjs is more JavaScripty. Ideal

Re: What do we still need from a class-like abstraction (was: `this`: methods versus functions)

2011-11-10 Thread Brendan Eich
On Nov 10, 2011, at 2:07 PM, Brendan Eich wrote: On Nov 10, 2011, at 7:59 AM, Mark S. Miller wrote: My previous proposal for class-like sugar for traits composition was not popular. Whereas, in the absence of problem #5, I suspect the traitsjs library would be. As previously observed on

Strawman: Decouple [ ] and property access

2011-11-10 Thread Allen Wirfs-Brock
I've posted a new strawman proposal for the ideas originally discussed in this thread. http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation Allen On Nov 3, 2011, at 2:06 PM, Waldemar Horwat wrote: We had this in ES4, together with the provision that you could have

Re: Strawman: Decouple [ ] and property access

2011-11-10 Thread Axel Rauschmayer
I've posted a new strawman proposal for the ideas originally discussed in this thread. http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation Feedback: - I like contrasting the concept “application data domain” with the concept “program definition domain”. Maybe mention

Re: Strawman: Decouple [ ] and property access

2011-11-10 Thread Axel Rauschmayer
I've posted a new strawman proposal for the ideas originally discussed in this thread. http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation I forgot: +1 -- Dr. Axel Rauschmayer a...@rauschma.de home: rauschma.de twitter: twitter.com/rauschma blog: 2ality.com

Re: Strawman: Decouple [ ] and property access

2011-11-10 Thread John J Barton
On Thu, Nov 10, 2011 at 4:58 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: I've posted a new strawman proposal for the ideas originally discussed in this thread. http://wiki.ecmascript.org/doku.php?id=strawman:object_model_reformation Allen A comparison to 'dict' which shares the

Re: Globalization API working draft

2011-11-10 Thread Norbert Lindenberg
A guide and background article is now available: http://norbertlindenberg.com/2011/11/ecmascript-globalization-api/index.html Regards, Norbert On Nov 2, 2011, at 0:10 , Norbert Lindenberg wrote: A working draft of the ECMAScript Globalization API Specification for review at the November TC

(Almost) everything is expression

2011-11-10 Thread Dmitry Soshnikov
Hi, (unfortunately Twitter is again doesn't fit for a more than 140 ch discussion, so moving here) I'd like to still notice the possibility of accepting the almost everything is expression approach for JS. After Erlang I very often miss this possibility. The idea is to make most of

Re: (Almost) everything is expression

2011-11-10 Thread Dmitry Soshnikov
On 11.11.2011 11:07, Dmitry Soshnikov wrote: P.S: Regarding Dave's `do { .. }` -- we may omit `do` and just evaluate the block. let a = { print('doing stuff'); 100; }; It's of course seems ambiguous with an object initialiser (at first glance), but it's only at first glance. Obviously

Re: (Almost) everything is expression

2011-11-10 Thread David Herman
Brendan and Dave mention explicit semicolon. Yes, it's seems so by the grammar (though, have to check more precisely), but it can be acceptable price. It's a serious price, though. Today if I write: if (q) { ... } else { ... } (f()) then ASI kicks in after the else body. If we

Re: (Almost) everything is expression

2011-11-10 Thread Dmitry Soshnikov
On 11.11.2011 11:43, David Herman wrote: Brendan and Dave mention explicit semicolon. Yes, it's seems so by the grammar (though, have to check more precisely), but it can be acceptable price. It's a serious price, though. Today if I write: if (q) { ... } else { ... } (f())