Lastest ES6 draft (rev 14) now available

Rick Waldron waldron.rick at gmail.com
Fri Mar 8 15:42:16 PST 2013


On Fri, Mar 8, 2013 at 6:31 PM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:

> also .. how that happened that Array.from is basically the equivalent of
>
> Array.from = Function.call.bind(Array.prototype.map); ?
>
> Wasn't the initial reason to Array.from avoid the repeated all over
> everywhere [].slice.call(arguments) where a signature slice-alike would be
> more suitable so instead of Array.from(arguments).slice(1), as example, one
> would Array.from(arguments, 1) ?
>

The addition of a "map callback" is to give subclasses, that inherit
Array.from() a way of creating new "collection likes", of their _own_ type.
You wouldn't want subclasses to return the parent classes type:

class Vector extends Array {}

Vector.from( ... ) // I want a new Vector, not an Array.

The example I gave during Allen's presentation:

var nodelist = NodeList.from(["div"], nodeName =>
document.createElement(nodeName) );

Full discussion:
https://github.com/rwldrn/tc39-notes/blob/master/es6/2013-01/jan-29.md#48-refactored-new-operator-and-the-create-method(search
for "Conclusion/Resolution, Bullet 2")

The proposed and accepted solution:
https://github.com/rwldrn/tc39-notes/blob/master/es6/2013-01/jan-30.md#revising-the-array-subclassing-kind-issue

Rick



>
> Thanks again :-)
>
>
>
> On Fri, Mar 8, 2013 at 3:26 PM, Andrea Giammarchi <
> andrea.giammarchi at gmail.com> wrote:
>
>> am I understanding mixin correctly?
>>
>> 'mixin' in Object || (Object.mixin = function mixin(
>>   target, source
>> ) {
>>   for(var
>>     keys = Object.getOwnPropertyNames(source),
>>     i = keys.length; i--; Object.defineProperty(
>>       target,
>>       keys[i],
>>       Object.getOwnPropertyDescriptor(
>>         source,
>>         keys[i]
>>       )
>>     )
>>   );
>>   return target;
>> });
>>
>> thanks
>>
>>
>> On Fri, Mar 8, 2013 at 2:35 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:
>>
>>> The March 8, 2013 Rev 14 draft is now available at the usual place:
>>> http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts
>>>
>>> Changes include:
>>>
>>>    - Class bodies are now always string
>>>     - *static* methods may now be defined in *ClassBody*
>>>     - Updated comprehension syntax to use left-to-right order
>>>     - Eliminated *is* and *isnt* operators
>>>     - added grammar productions to allow unqualified super to be used
>>>    after new operator
>>>     - expression to the right of *of* in *for-of* now restricted to
>>>    being *AssignmentExpression*
>>>     - Almost all Chapter 15 constructors are now specified to have an
>>>    @@create methid and are initialized in a manner that supports subclassing.
>>>    (still need to work on Function)
>>>     - Added Object.getOwnPropertyKeys function
>>>     - Added Object.is function
>>>     - Tentatively added Object.mixin function
>>>     - Array.from now takes an optional map function
>>>     - Added String.prototype.normalize method
>>>     - All String.prototype methods that accept RegExp arguments will
>>>    now work with subclasses of RegExp
>>>     - Renamed Number.prototype.toInt to Number.prototype.toInteger
>>>     - RegExp global, ignoreCase, multiline, source, sticky are now
>>>    prototype accessor properties rather than instance own data properties.
>>>    This is needed to support adding web compatible compile method.
>>>     - Added new RegExp.prototype methods that allow string methods to
>>>    work with RegExp subclasses: match, replace, search, split, @@isRegExp
>>>     - Map and Set constructors now accept a =n optional comparator
>>>    parameter. Only value currently allowed is “is”
>>>     - ArrayBuffer and *Typed*Array object length no long restricted to 2
>>>    32 limit
>>>     - Eliminated all remaining references to [[Class]] and
>>>    [[NativeBrand]] (except for in some DataView code that needs rewritting
>>>    anyway)
>>>     - Added SameValueZero abstraction operation that considers -0 and
>>>    +0 to be the same value.
>>>     - Rename [[GetP]] to [[Get]] and [[SetP]] to [[Set]]
>>>     - Specified that unless otherwise indicated, internal data
>>>    properties are created when an object is allocated. Internal data
>>>    properties are now explicitly listed in ObjectCreate abstract operation
>>>    calls.
>>>     - internally consolidated [[IsExtensible]]/[[IsSealed]/[[IsFrozen]]
>>>    and [[PreventExtensions]]/[[Seal]]/[[Freeze]] into two MOP operations
>>>    [[HasIntegrity]] and [[SetIntegrity]]. However, no public APIs (Proxy traps
>>>    and Reflect functions) changed.
>>>     - Numerous editorial and technical corrections, clarifications, and
>>>    bug fixes
>>>
>>>
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130308/ff5c584e/attachment.html>


More information about the es-discuss mailing list