Re: Array Generics and null

2008-03-31 Thread Erik Arvidsson
I agree with Lars (and Mark) on this. It would be best if access to 'this' would throw. Throwing in the actual call to the function seems a bit harsh since the statement that refers to 'this' might never be reached. Making the access throw would allow people to at least catch the error and fall

Re: Array Generics and null

2008-03-30 Thread Mark S. Miller
On Sun, Mar 30, 2008 at 6:54 AM, Lars Hansen <[EMAIL PROTECTED]> wrote: > The third option on the table is that the reference to 'this' > inside the body of topLevel simply throws an error. This has > both less and more utility: the function can't discover if it > was called as a function or a

RE: Array Generics and null

2008-03-30 Thread Lars Hansen
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Brendan Eich > Sent: 29. mars 2008 11:05 > To: Mike Shaver; es4-discuss > Cc: Dean Edwards > Subject: Re: Array Generics and null > We would rather: > > function topLev

Re: Array Generics and null

2008-03-29 Thread Brendan Eich
On Mar 22, 2008, at 10:18 PM, Mike Shaver wrote: > On Sat, Mar 22, 2008 at 4:32 PM, Dean Edwards <[EMAIL PROTECTED]> > wrote: >> Dean Edwards wrote: >>> I think that the problem is that Array generics were added later. >>> >>> From bugzilla: Array.generic(t, ...) is *intended* to be equiva

Re: Array Generics and null

2008-03-24 Thread Dean Edwards
Mark S. Miller wrote: > On Mon, Mar 24, 2008 at 10:31 AM, Dean Edwards <[EMAIL PROTECTED]> wrote: >> It seems we have three choices for Array.forEach(null) >> >> 1) Do nothing >> 2) Throw an exception >> 3) Use the current object and iterate that > > By "current object" do you mean the global

Re: Array Generics and null

2008-03-24 Thread Mike Shaver
On Sat, Mar 22, 2008 at 1:42 PM, Garrett Smith <[EMAIL PROTECTED]> wrote: > Array generic methods will be safer if they check their args and throw > an error - InvalidArgumentError, TypeError, UnlikeError - (whatever). > > Invalid: (this will crash Firefox with endless loop):- > Array.forEach(

Re: Array Generics and null

2008-03-24 Thread Mark S. Miller
On Mon, Mar 24, 2008 at 10:31 AM, Dean Edwards <[EMAIL PROTECTED]> wrote: > It seems we have three choices for Array.forEach(null) > > 1) Do nothing > 2) Throw an exception > 3) Use the current object and iterate that By "current object" do you mean the global object? > I prefer the first on

Re: Array Generics and null

2008-03-24 Thread Dean Edwards
Mike Shaver wrote: > On Sun, Mar 23, 2008 at 2:44 AM, Dean Edwards <[EMAIL PROTECTED]> wrote: >> I'd prefer Array.forEach(null) to do nothing, just like for (var i in >> null) does nothing. I'm prepared to be convinced otherwise. :-) > > forEach isn't like enumeration, though, it's like the more

Re: Array Generics and null

2008-03-24 Thread Mike Shaver
On Sun, Mar 23, 2008 at 2:44 AM, Dean Edwards <[EMAIL PROTECTED]> wrote: > I'd prefer Array.forEach(null) to do nothing, just like for (var i in > null) does nothing. I'm prepared to be convinced otherwise. :-) forEach isn't like enumeration, though, it's like the more common Array pattern of f

Re: Array Generics and null

2008-03-23 Thread Garrett Smith
On Sun, Mar 23, 2008 at 11:53 AM, Mike Shaver <[EMAIL PROTECTED]> wrote: > On Sun, Mar 23, 2008 at 3:45 AM, Garrett Smith <[EMAIL PROTECTED]> wrote: > > I suspected that. It is the problem with Google Mail, which exhibited > > a bug in Firefox. > > Sorry, do you mean that this is caused by Arra

Re: Array Generics and null

2008-03-23 Thread Mike Shaver
On Sun, Mar 23, 2008 at 3:45 AM, Garrett Smith <[EMAIL PROTECTED]> wrote: > I suspected that. It is the problem with Google Mail, which exhibited > a bug in Firefox. Sorry, do you mean that this is caused by Array.generic behaviour? I'm lost as to what bug you're talking about (bug number?). Mik

Re: Array Generics and null

2008-03-23 Thread Garrett Smith
On Sun, Mar 23, 2008 at 12:45 AM, Garrett Smith <[EMAIL PROTECTED]> wrote: > I suspected that. It is the problem with Google Mail, which exhibited > a bug in Firefox. > > Use case: > 0) hit reply > 1) click 'send' > 2) hit 'stop' > 3) click 'reply to all' and watch the To: field change. 3.5):

Re: Array Generics and null

2008-03-22 Thread Dean Edwards
Mike Shaver wrote: > Dean Edwards wrote: >>> Array.prototype.forEach = function(block, context) { >>> Array.forEach(this, block, context); >>> } > > I don't see how that helps, unless you expect A.p.g.c(null, f) to > differ from A.g(null, f) -- the former will need to make a |this| > from null

Re: Array Generics and null

2008-03-22 Thread Mike Shaver
On Sat, Mar 22, 2008 at 4:32 PM, Dean Edwards <[EMAIL PROTECTED]> wrote: > Dean Edwards wrote: > > I think that the problem is that Array generics were added later. > > > > From bugzilla: > >> Array.generic(t, ...) is *intended* to be equivalent to > >> Array.prototype.generic.call(t, .

Re: Array Generics and null

2008-03-22 Thread Dean Edwards
John Resig wrote: > The issue here is that Array.forEach(null, ...) maps to > Array.prototype.forEach.call(null, ...) - and doing a .call() on a > function produces the global object (which, in a browser like > Firefox, is equivalent to window.frames - looping over the iframes on > the page). > >

Re: Array Generics and null

2008-03-22 Thread Garrett Smith
On Sat, Mar 22, 2008 at 9:01 AM, John Resig <[EMAIL PROTECTED]> wrote: > Hello all - > > It seems like there could be a couple solutions: Objects that are not capable of running in an Array-generic should not be attempted to run. Would it make sense to use - like - for all the Array generics?