André Bargull (2013-10-22T14:18:29.000Z)
On 10/22/2013 4:00 PM, Erik Arvidsson wrote:
> The spec for Object.assign,
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign,
> seems to have some issues.
>
> /gotAllNames/ is never read.

It is initialised to false in step 7, read in step 9 and set to true in 
step 9c. That seems to be ok.


>
> What is the intention regarding exceptions? Is the intention to continue
> assigning properties after an exception is thrown. Why is that the
> desired behavior?

I'd guess to align behaviour with Object.mixin, Object.defineProperties, 
(Object.create), Object.is{Sealed,Frozen} and Object.seal/freeze. This 
was also covered in the thread starting at 
https://mail.mozilla.org/pipermail/es-discuss/2012-December/027067.html .


- André

>
> On Tue, Oct 22, 2013 at 6:41 AM, André Bargull <andre.bargull at udo.edu
> <mailto:andre.bargull at udo.edu>> wrote:
> ...
>  > A more conformant implementation should be this one:
>  >
>  > function assign(target, source) {
>  >   function ToObject(o) {
>  >     if (o == null) {
>  >       throw new TypeError();
>  >     }
>  >     return Object(o);
>  >   }
>  >   var to = ToObject(target);
>  >   var from = ToObject(source);
>  >   var keys = $getOwnPropertyNames(from);
>  >   var pendingException = null;
>  >   for (var i = 0, length = keys.length; i < length; ++i) {
>  >     var nextKey = keys[i];
>  >     try {
>  >       var desc = $getOwnPropertyDescriptor(from, nextKey);
>  >       if (desc !== undefined && desc.enumerable) {
>  >         to[nextKey] = from[nextKey];
>  >       }
>  >     } catch (e) {
>  >       if (pendingException !== null) {
>  >         pendingException = e;
>  >       }
>  >     }
>  >   }
>  >   if (pendingException !== null) {
>  >     throw pendingException;
>  >   }
>  >   return to;
>  > }
>  >
>  >
>  > - André
>  >
>
>
> --
> erik
domenic at domenicdenicola.com (2013-10-26T03:23:43.568Z)
On 10/22/2013 4:00 PM, Erik Arvidsson wrote:
> The spec for Object.assign,
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign,
> seems to have some issues.
>
> *gotAllNames* is never read.

It is initialised to false in step 7, read in step 9 and set to true in 
step 9c. That seems to be ok.


> What is the intention regarding exceptions? Is the intention to continue
> assigning properties after an exception is thrown. Why is that the
> desired behavior?

I'd guess to align behaviour with `Object.mixin`, `Object.defineProperties`, 
(`Object.create`), `Object.is{Sealed,Frozen}` and `Object.seal`/`freeze`. This 
was also covered in the thread starting at 
https://mail.mozilla.org/pipermail/es-discuss/2012-December/027067.html .