Object.is steps are very thing

Allen Wirfs-Brock allen at wirfs-brock.com
Sat Mar 16 17:09:07 PDT 2013


On Mar 16, 2013, at 5:02 PM, Tom Schuster wrote:

> Also note that with the current definition Object.is() should return
> true. I am not really a big fan of that ;)

All standard function have a well specified, but perhaps odd, behavior when no arguments are passed to them.  It's just how JavaScript works.  Better to have a simple rule to learn than dozens of exceptions.

Allen






> 
> On Sun, Mar 17, 2013 at 12:56 AM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
>> 
>> On Mar 16, 2013, at 4:42 PM, Tom Schuster wrote:
>> 
>>> I would argue that the disclaimer makes this more confusing. I am
>>> aware of the behavior that not passed parameters are undefined. But It
>>> sounded like we would never execute step 1. when the parameter count
>>> doesn't match. And thus leaving the result of the call not defined.
>> 
>> I see...it certainly isn't intended for those preambles to be interpreted in that way.  They really are just boiler plate for inducing the the italic parameter names.
>> 
>> If there is an actual overload based upon the number of passed arguments we are much more explict.   See for example, 15.4.1.1 and 15.4.1.2.
>> 
>> Nobody had previously brought this particular point of confusion to may attention.  It should like I shold change the standard boiler plate preamble to something slike:
>> 
>> The *is* function takes parameters /value1/ and /value2/ and performs the following steps when called:
>> 
>> Allen
>> 
>> 
>> 
>>> 
>>> On Sun, Mar 17, 2013 at 12:06 AM, Allen Wirfs-Brock
>>> <allen at wirfs-brock.com> wrote:
>>>> 
>>>> On Mar 16, 2013, at 3:40 PM, David Bruant wrote:
>>>> 
>>>>> Le 16/03/2013 19:18, Tom Schuster a écrit :
>>>>>> Hey!
>>>>>> 
>>>>>> Looking at the the steps for Object.is the first sentence just says:
>>>>>>> "When the is function is called with arguments value1 and value2 the following steps are taken:"
>>>>>> I don't remember other functions being defined like that. It should at
>>>>>> least say something along the lines of
>>>>>> "When called with less than 2 parameters return false."
>>>>> I'd throw a TypeError. Calling Object.is with strictly more or less than 2 parameters is most likely an error, akin to === with which something different than strictly 2 operands resultsis a SyntaxError.
>>>> 
>>>> 
>>>> ECMAScript has a well established convention of using undefined for any non-supplied argument values.  It's preferable to consistently follow such conventions.
>>>> 
>>>> Allen
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>> 
> 



More information about the es-discuss mailing list