Right, and that is what the comments in array.js says. :) -- Mads
On Wed, Feb 17, 2010 at 10:53 AM, Lasse R.H. Nielsen <[email protected]> wrote: >> The spec itself is silent on this, as it only specifies what happens when >> called with two or more arguments. > That's actually wrong. The spec does say that when calling with less than > the specified number of arguments, it should be treated as being called with > the correct number of arguments having the value undefined. > I.e., it's not spec-conforming. > /L > On Wed, Feb 17, 2010 at 10:38, Lasse R.H. Nielsen <[email protected]> wrote: >> >> A quick test of Opera, Firefox, Safari and IE shows that only IE differ >> from the rest. Everybody else lets an omitted argument default to length, >> but an explicit undefined counts as zero. >> The spec itself is silent on this, as it only specifies what happens when >> called with two or more arguments. >> The ES5 spec should probably have codified this behavior (4 out of 5 >> agrees). I have no idea whether they ever looked at it. >> /L >> >> On Wed, Feb 17, 2010 at 10:29, <[email protected]> wrote: >>> >>> Thanks a lot, Lasse. I too checked if Safari behaves this way. Mildly >>> curious >>> who cares about 15.4.4.12 though :) Jokes aside, is there an important >>> ECMAScript implementation which implements it right? Any chances that >>> standard >>> should be amended? Or all the implementations are different enough to >>> never >>> find the common ground? >>> >>> yours, >>> anton. >>> >>> >>> http://codereview.chromium.org/618002/diff/1/3 >>> File src/builtins.cc (right): >>> >>> http://codereview.chromium.org/618002/diff/1/3#newcode548 >>> src/builtins.cc:548: // but current implementation behaves differently. >>> On 2010/02/17 09:11:46, Lasse Reichstein wrote: >>>> >>>> This is also Safari compatible. >>>> (Arguably it's also consistent with slice and with String's substring >>> >>> when >>>> >>>> omitting the second parameter). >>> >>> I'm somewhat surprised that undefined here is treated differently than >>> argument omission---undefined behaves like 0 (which is expected), but >>> single arg form behaves like len (which is slice compatible as you say). >>> >>> http://codereview.chromium.org/618002 >> >> >> >> -- >> Lasse R.H. Nielsen >> [email protected] >> 'Faith without judgement merely degrades the spirit divine' >> Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - >> Denmark - CVR nr. 28 86 69 84 > > > > -- > Lasse R.H. Nielsen > [email protected] > 'Faith without judgement merely degrades the spirit divine' > Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 København K - > Denmark - CVR nr. 28 86 69 84 > -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
