[Bug 27008] "Initializing objects from iterables" needs syntax

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27008

Boris Zbarsky <bzbarsky@mit.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |domenic@domenicdenicola.com

--- Comment #3 from Boris Zbarsky <bzbarsky@mit.edu> ---
Oh, I see.

I don't think it does, in fact, since it assumes that you have an iterable and
just want to initialize from it.  But that's not what you have.  You have
either an iterable or a random non-iterable object, no?

So ignoring web idl for now, how would one implement this?  First check for a
Headers instance, fine.  Then check whether your object is iterable.  If so,
you have two choices.  You can do the sequence thing, which will snapshot the
iterable, and then you init from that snapshot.  Or you could do the "add map
elements from iterable" thing, which will redo some observable work (like
getting @@iterator from the object, though we could maybe change that to pass
in the iterator getter, like we do for "creating a sequence from an iterable"),
right?

Lastly, if your thing is not iterable, then you treat it as an
OpenEndedDictionary.

So in terms of syntax, we'd basically need to introduce some "live iterator"
type which would check whether the object has a non-undefined @@iterator and
then either pass through just that object or that object and the @@iterator
value, right?  And then you'd replace the sequence you have here with this
"live iterator" type and perform "add map elements from an iterable" in prose?

We _could_ try to jam everything that "add map elements from an iterable" wants
(at least the method name, but it's not clear to me how it should guess the
destination object, or whether it should be explicitly specified) in the
syntax, but then it ends up being pretty weird if someone uses that type in,
say, a dictionary: at that point, what is the destination object?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Received on Thursday, 9 October 2014 15:19:24 UTC