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