Actually I propose a change in texts in the specification.
>CheckIterable ( obj )>1. If obj is `undefined` or `null`, then return 
>`undefined`.>2. If type(obj) is Object, then return Get(obj, @@iterator).>3. 
>Let box be ToObject(obj).>4. ReturnIfAbrupt(box).>5. Return the result of 
>calling the [[Get]] internal method of box passing @@iterator and obj as the 
>arguments.
This is way more too complex. We know that there are three situation:1. obj is 
`undefined` or `null`2. obj is of a primitive type3. obj is an object
In 1, we don't care if it returns undefined or throw a TypeError. In ES6 spec, 
there are two uses of the undefined returned. One of them passes it as F to 
Call, the other passes it to ToObject. Both of them will result in TypeError. 
So we can just let this step throw TypeError instead of return `undefined`.
I suggest we can a little bit combine these steps:
>CheckIterable (obj)>1. Let box be ToObject(obj).>2. ReturnIfAbrupt(box).>3. 
>Return the result of calling the [[Get]] internal method of box passing 
>@@iterator and obj as the arguments.
If obj is `undefined` or `null`, the first step will fail and throw TypeError. 
If obj is primitive, it's boxed. If obj is an object, it is no-op in ToObject.




                                          
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to