Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-09 Thread Tom Van Cutsem
2011/11/8 Allen Wirfs-Brock > I don't think that [[GetP]] and [[PutP]] need to be "internal methods" > In spec'ing this I think I would make them be "abstract operations". > Internal methods are extensions points that can be over-ridden on a per > object basis. That is what [[Get]] and [[Put]] p

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread David Bruant
Le 09/11/2011 02:26, Andrew Paprocki a écrit : On Tue, Nov 8, 2011 at 6:36 PM, Brendan Eich wrote: Ignoring performance, a lot of stylish JS hackers use Object.keys(o).forEach. How many run into the wrong |this| (arguments/break/continue/return)? Not clear. Something to study. I was curious

Re: Security and direct proxies (Was: Re: Lecture series on SES and capability-based security by Mark Miller)

2011-11-09 Thread Andreas Rossberg
On 9 November 2011 00:16, Mark S. Miller wrote: > On Tue, Nov 8, 2011 at 12:50 PM, Andreas Rossberg > wrote: >> >> On 8 November 2011 20:46, Mark S. Miller wrote: >> > Nevertheless, I see your point. Many defensive ES5 abstractions will be >> > less >> > defensive than this. If I understand you

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-09 Thread Tom Van Cutsem
2011/11/8 Allen Wirfs-Brock > On Nov 8, 2011, at 7:33 AM, Andreas Rossberg wrote: > > But I have a follow-up request. :) Regarding redundant trap calls with > > proxies there is another, more pervasive problem with the current > > spec: in lots of places it first calls [[HasProperty]] and then >

Re: Security and direct proxies (Was: Re: Lecture series on SES and capability-based security by Mark Miller)

2011-11-09 Thread Sam Tobin-Hochstadt
On Tue, Nov 8, 2011 at 4:58 PM, Tom Van Cutsem wrote: >> > Perhaps we should >> > be more conservative here, without necessarily backing away from the >> > whole >> > Proxy.attach idea? >> >> Disallowing attaching to functions with your own call/construct traps >> would be the minimal restriction,

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Xavier MONTILLET
for own (i in o) { //body } I'd rather see something like for (i inside o) { //body } And the reason for this is you could then use it in conditions as you use in: if ( 'prop' in obj ) { //body } if ( 'prop' inside obj ) { //body } You would have 'prop' inside obj <=> Object.protot

Re: making |this| an error (was Re: for own(...) loop)

2011-11-09 Thread John J Barton
On Wed, Nov 9, 2011 at 3:41 AM, David Bruant wrote: > Le 09/11/2011 02:26, Andrew Paprocki a écrit : >> >> On Tue, Nov 8, 2011 at 6:36 PM, Brendan Eich  wrote: >>> >>> Ignoring performance, a lot of stylish JS hackers use >>> Object.keys(o).forEach. How many run into the wrong |this| >>> (argument

Re: making |this| an error (was Re: for own(...) loop)

2011-11-09 Thread Peter van der Zee
The forEach method might not do what you expect it to. This can not be statically determined. - peter On 9 Nov 2011 16:10, "John J Barton" wrote: > On Wed, Nov 9, 2011 at 3:41 AM, David Bruant wrote: > > Le 09/11/2011 02:26, Andrew Paprocki a écrit : > >> > >> On Tue, Nov 8, 2011 at 6:36 PM, Br

Re: making |this| an error (was Re: for own(...) loop)

2011-11-09 Thread John J Barton
On Wed, Nov 9, 2011 at 7:22 AM, Peter van der Zee wrote: > The forEach method might not do what you expect it to. This can not be > statically determined. And if forEach is not what you expect, that function may bind its argument: foo(function() { do something with |this| });

Re: making |this| an error (was Re: for own(...) loop)

2011-11-09 Thread Quildreen Motta
2011/11/9 John J Barton > I'm sure this has been discussed before, but isn't is possible and > desirable to make |this| illegal in "using strict;" when it can be > determined from the AST alone that |this| will bind to |window|? eg: > > Object.keys(foo).forEach(function(key) { > // this is

Re: making |this| an error (was Re: for own(...) loop)

2011-11-09 Thread Andreas Rossberg
On 9 November 2011 16:10, John J Barton wrote: > I'm sure this has been discussed before, but isn't is possible and > desirable to make |this| illegal in "using strict;" when it can be > determined from the AST alone that |this| will bind to |window|?  eg: > >   Object.keys(foo).forEach(function(k

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-09 Thread Allen Wirfs-Brock
On Nov 9, 2011, at 3:53 AM, Tom Van Cutsem wrote: > 2011/11/8 Allen Wirfs-Brock > On Nov 8, 2011, at 7:33 AM, Andreas Rossberg wrote: > > But I have a follow-up request. :) Regarding redundant trap calls with > > proxies there is another, more pervasive problem with the current > > spec: in lots

Re: [Proxies] Refactoring prototype climbing in the spec

2011-11-09 Thread Allen Wirfs-Brock
On Nov 9, 2011, at 3:17 AM, Tom Van Cutsem wrote: > 2011/11/8 Allen Wirfs-Brock > I don't think that [[GetP]] and [[PutP]] need to be "internal methods" > In spec'ing this I think I would make them be "abstract operations". Internal > methods are extensions points that can be over-ridden on a p

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Jorge
On 08/11/2011, at 22:17, John J Barton wrote: > Just as a point of comparison, I use this form: > Object.keys(o).forEach( function(key) { > body > }); By the way, isn't that above a(nother) good use case for a goto, given that there's no (easy) way to break out of a forEach 'loop' ? --

supporting ES upgrading with a programming pattern repo?

2011-11-09 Thread Claus Reinke
Both the committee and JS coders could profit from examples. The committee wants to ensure that their design decisions lead to improvements in language usage, JS coders want to know what those semi-formal proposals mean for their day-to-day use of the language. Both parties want to be sure that t

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Dean Landolt
On Wed, Nov 9, 2011 at 3:40 PM, Jorge wrote: > On 08/11/2011, at 22:17, John J Barton wrote: > > Just as a point of comparison, I use this form: > > Object.keys(o).forEach( function(key) { > > body > > }); > > By the way, isn't that above a(nother) good use case for a goto, given > that

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Brendan Eich
On Nov 9, 2011, at 12:40 PM, Jorge wrote: > On 08/11/2011, at 22:17, John J Barton wrote: >> Just as a point of comparison, I use this form: >> Object.keys(o).forEach( function(key) { >> body >> }); > > By the way, isn't that above a(nother) good use case for a goto, given that > there's n

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Dean Landolt
On Wed, Nov 9, 2011 at 4:05 PM, Brendan Eich wrote: > On Nov 9, 2011, at 12:40 PM, Jorge wrote: > > > On 08/11/2011, at 22:17, John J Barton wrote: > >> Just as a point of comparison, I use this form: > >> Object.keys(o).forEach( function(key) { > >> body > >> }); > > > > By the way, isn't

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Brendan Eich
On Nov 9, 2011, at 1:15 PM, Dean Landolt wrote: > On Wed, Nov 9, 2011 at 4:05 PM, Brendan Eich wrote: > On Nov 9, 2011, at 12:40 PM, Jorge wrote: > > > On 08/11/2011, at 22:17, John J Barton wrote: > >> Just as a point of comparison, I use this form: > >> Object.keys(o).forEach( function(key) {

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Dean Landolt
On Wed, Nov 9, 2011 at 4:20 PM, Brendan Eich wrote: > On Nov 9, 2011, at 1:15 PM, Dean Landolt wrote: > > On Wed, Nov 9, 2011 at 4:05 PM, Brendan Eich wrote: > >> On Nov 9, 2011, at 12:40 PM, Jorge wrote: >> >> > On 08/11/2011, at 22:17, John J Barton wrote: >> >> Just as a point of comparison,

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Quildreen Motta
On 09/11/11 19:20, Brendan Eich wrote: And if you need to break out of forEach, just, umm, don't use forEach. It's the wrong tool for the job. Clearly people like the forEach array extra in conjunction with Object.keys. With block-lambdas they could have their cake and break from it too (an

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread David Herman
On Nov 9, 2011, at 1:33 PM, Quildreen Motta wrote: > On 09/11/11 19:20, Brendan Eich wrote: >> >>> And if you need to break out of forEach, just, umm, don't use forEach. It's >>> the wrong tool for the job. >> >> Clearly people like the forEach array extra in conjunction with Object.keys. >> W

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Brendan Eich
On Nov 9, 2011, at 1:33 PM, Dean Landolt wrote: >> And if you need to break out of forEach, just, umm, don't use forEach. It's >> the wrong tool for the job. > > Clearly people like the forEach array extra in conjunction with Object.keys. > > > Aye, but I suspect that's because many people don

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Axel Rauschmayer
>> And if you need to break out of forEach, just, umm, don't use forEach. It's >> the wrong tool for the job. > > Clearly people like the forEach array extra in conjunction with Object.keys. > With block-lambdas they could have their cake and break from it too (and the > call would be paren-fre

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Brendan Eich
On Nov 9, 2011, at 2:43 PM, Axel Rauschmayer wrote: > Do block-lamdbas count as a fix for the dynamic this problem? Definitely. > Or are there other plans to get it solved? I would still love to see that > happen, it’s a remarkably subtle source of errors. Could functions adopt the > block-la

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Andy Earnshaw
Should ES.next provide sugar for the recommended pattern? To make it compose with declarations and destructuring in the for head, it should use a contextual keyword immediately after 'for': for own (i in o) { body } This is a small thing but it might pay off in the long run. I

`this`: methods versus functions

2011-11-09 Thread Axel Rauschmayer
>> Or are there other plans to get it solved? I would still love to see that >> happen, it’s a remarkably subtle source of errors. Could functions adopt the >> block-lambda semantics of picking up the `this` of the surrounding scope >> when not invoked as methods? It seems like that could work i

Re: `this`: methods versus functions

2011-11-09 Thread Brendan Eich
On Nov 9, 2011, at 3:48 PM, Axel Rauschmayer wrote: >>> Or are there other plans to get it solved? I would still love to see that >>> happen, it’s a remarkably subtle source of errors. Could functions adopt >>> the block-lambda semantics of picking up the `this` of the surrounding >>> scope whe

Re: `this`: methods versus functions

2011-11-09 Thread Brendan Eich
On Nov 9, 2011, at 4:00 PM, Brendan Eich wrote: > On Nov 9, 2011, at 3:48 PM, Axel Rauschmayer wrote: > Or are there other plans to get it solved? I would still love to see that happen, it’s a remarkably subtle source of errors. Could functions adopt the block-lambda semantics of

Re: `this`: methods versus functions

2011-11-09 Thread Mark S. Miller
On Wed, Nov 9, 2011 at 4:00 PM, Brendan Eich wrote: > On Nov 9, 2011, at 3:48 PM, Axel Rauschmayer wrote: > > We talked about lexical this for functions long ago (Jan. 2008? at Google > anyway) and IIRC Mark found a subtler flaw. > I think my original example was smaller and more elegant. But t

Re: `this`: methods versus functions

2011-11-09 Thread Axel Rauschmayer
>>> Got it. I’m assuming that’s a performance issue? >> >> You could say that. If we inherit by default but it's a "soft binding", then >> the inner function has to carry that reference with it, but in a way that >> can be overridden. >> >> We talked about lexical this for functions long ago (J

Re: `this`: methods versus functions

2011-11-09 Thread Brendan Eich
On Nov 9, 2011, at 4:15 PM, Mark S. Miller wrote: > On Wed, Nov 9, 2011 at 4:00 PM, Brendan Eich wrote: > On Nov 9, 2011, at 3:48 PM, Axel Rauschmayer wrote: > > We talked about lexical this for functions long ago (Jan. 2008? at Google > anyway) and IIRC Mark found a subtler flaw. > > > I thi

Re: supporting ES upgrading with a programming pattern repo?

2011-11-09 Thread Axel Rauschmayer
On Nov 9, 2011, at 10:55 , Claus Reinke wrote: > Both the committee and JS coders could profit from examples. Amen to that. JavaScript seems worse than any other language when it comes to finding correct information on the web. For example, I trust StackOverflow for many topics, but for JavaSc

Fwd: supporting ES upgrading with a programming pattern repo?

2011-11-09 Thread Axel Rauschmayer
Oops, I think I partially misread your email: You were talking about upcoming changes and new patterns enabled by ES.next. But some of my observations should still hold: You probably need a single person to write such material (or at least to curate it). Begin forwarded message: > From: Axel R

Re: supporting ES upgrading with a programming pattern repo?

2011-11-09 Thread Rick Waldron
> > > Amen to that. JavaScript seems worse than any other language when it comes > to finding correct information on the web. For example, I trust > StackOverflow for many topics, but for JavaScript, it’s often shockingly > wrong. Half-truths are even worse than information that is completely wrong

Re: for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

2011-11-09 Thread Jorge
On 09/11/2011, at 22:05, Brendan Eich wrote: > On Nov 9, 2011, at 12:40 PM, Jorge wrote: >> On 08/11/2011, at 22:17, John J Barton wrote: >>> Just as a point of comparison, I use this form: >>> Object.keys(o).forEach( function(key) { >>>body >>> }); >> >> By the way, isn't that above a(nother)