-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "initializing objects from iterables" section. #13
Conversation
<li>If <var>next</var> is <span class='esvalue'>false</span>, then return <a class='external' href='http://people.mozilla.org/~jorendorff/es6-draft.html#sec-normalcompletion'>NormalCompletion</a>(<var>destination</var>).</li> | ||
<li>Let <var>nextItem</var> be <a class='external' href='http://people.mozilla.org/~jorendorff/es6-draft.html#sec-iteratorvalue'>IteratorValue</a>(<var>next</var>).</li> | ||
<li><a class='external' href='http://people.mozilla.org/~jorendorff/es6-draft.html#sec-returnifabrupt'>ReturnIfAbrupt</a>(<var>nextItem</var>).</li> | ||
<li>If <a class='external' href='http://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-data-types-and-values'>Type</a>(<var>nextItem</var>) is not Object, then <a class='external' href='#ecmascript-throw' class='dfnref external'>throw a <span class='estype'>TypeError</span> exception</a>.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's throwing in a repeat loop, but it's not clear if the "repeat" needs to terminate repeating.
Very useful addition 👍 |
Thanks for the PR! Do you have an example of a spec that's going to use this? Sorry to hear you had trouble building the spec locally. I just tried this in my Windows installation and was able to successfully fetch and build the spec:
The algorithm deals with completion values explicitly, like in the ES spec, but unlike the other algorithms in this spec where exceptions are caught/propagated with higher level text (e.g. like in the #es-operations algorithm). This is just a stylistic concern though. |
an object <var>destination</var> with adder method name <var>adder</var>, perform the following steps: | ||
</p> | ||
<ol class='algorithm'> | ||
<li>If <a class='external' href='http://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-data-types-and-values'>Type</a>(<var>destination</var>) is not Object, then, <a class='external' href='#ecmascript-throw' class='dfnref external'>throw a <span class='estype'>TypeError</span> exception</a>.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "throw a TypeError" link and the other two in the patch have a duplicate class=""
attribute.
@heycam |
@domenic |
Nah. My intention is that you have to explicitly invoke the algorithm (since, in the fulness of time, we will get one that works for set-esque iterables too). So this is meant to be used from the prose description of the constructor, and not as a generic way of consuming all iterables. |
Okay, I guess we could invoke it if the passed object is not a |
Initially allows you to initialize an object from an iterable in the same fashion as a map.
Updated, including build output from a cygwin copy and some step-order-switching from https://bugs.ecmascript.org/show_bug.cgi?id=3000 |
Looks good, thank you! I forgot to ask for, and will add myself, an entry in the Changes appendix. |
Add "initializing objects from iterables" section.
You say to invoke this algorithm from the constructor, but that would mean we'd have to effectively allow |
Initially allows you to initialize an object from an iterable in the same fashion as a map.
I couldn't get the XSLT toolchain running on Windows after ~2 hours of trying, so I didn't get a chance to compile this to HTML and test it.