Chakracore: Implement Object Rest & Spread

Created on 20 Jul 2017  路  19Comments  路  Source: chakra-core/ChakraCore

The proposal is stage 3 and will very likely be in ES2018. Object rest and spread are very useful tools (especially in some ecosystems like React) and idioms from it are becoming more common (eg. shallow copy via let copy = { ... otherObj };)

Specification text: https://github.com/tc39/proposal-object-rest-spread

ECMAScript Spec Implemented-Experimental Task

Most helpful comment

Stage 4 and merged 馃帀
It is in the EcmaScript 2018 spec 馃憟

All 19 comments

Do any engines or compilers support this currently?

Babel, TypeScript, Chrome, Firefox all implement. Not sure about JSC.

Oh I see it in the proposal now, my bad: https://github.com/tc39/proposal-object-rest-spread#transpilers

If somebody can point me to the relevant location, I'm happy to take a look.

PR is being reviewed now which will soon make it Stage 4 https://github.com/tc39/ecma262/pull/1048

Stage 4 and merged 馃帀
It is in the EcmaScript 2018 spec 馃憟

Is this work in progress?

If not I鈥檇 be keen on making an attempt at it. I figure i should be able to create a pull request to implement this in my free time over next 5 weeks or do.

(Can鈥檛 guarantee I can do it but I think I have a working knowledge of most relevant parts of CC now)

Yes, this is in progress, so I'd recommend choosing a different feature to work on, but thanks for your interest!

@sethbrenith @tcare We are all looking forward to this feature, thanks! 馃憤

Even though there are only 8 upvotes on this issue, there are over 400 upvotes on MS Edge UserVoice.

uservoice

So you have quite the fanbase here 馃槃

5268 implemented object spread. @huaiyudavid is implementing object rest at the moment. Assigning to him.

@tcare Isn't object rest also implemented already? https://github.com/Microsoft/ChakraCore/pull/5498

O_O how did I unassigned someone? Looks like a bug. Forgive me if it's not. IDK how this happened.

Anyway, it looks like both rest and spread for object are implemented and issue could be closed :)

@chicoxyzzy No worries about unassigning. Object spread and rest are implemented, but not yet enabled by default, so I'd personally prefer to leave the issue open until they're enabled. A feature that exists in the code but is inaccessible doesn't seem like it should be marked as complete.

This feature is still experimental and needs additional work

See this comment for more info: https://github.com/Microsoft/ChakraCore/pull/5268#issuecomment-411438657

Perf looks fine compared to other engines, at least based on a very simple test.

(function () {
    var obj = { a: 1, b: new Date(), c: [] };
    var now = Date.now();
    var sum = 0;
    for (var i = 0; i < 1e6; ++i) {
        sum += {i, ...obj}.i;
    }
    print(Date.now() - now);
    var now = Date.now();
    for (var i = 0; i < 1e6; ++i) {
        let {b, ...x} = obj;
        sum -= x.a;
    }
    print(Date.now() - now);
})();
>eshost -h * \scripts\spread.js
#### jsvu-sm
385
199

#### ch-local-build
392
342

#### jsvu-d8
578
498

#### jsvu-jsc
794
553

@sethbrenith The quote about "additional work" needed was from @MSLaguana

It looks like you are both "members" so I assume you have discussed what work is needed to move this forward. Can you give an update here? 馃槃

Yes, there's still some work to do on this feature. In particular, we need to update our internal fuzzing tools so that they exercise object spread and rest, so we get some additional test coverage. We also need to verify interaction with the debug tools.

I assume this can be closed now? https://github.com/microsoft/ChakraCore/pull/6130

Good point, thanks

Was this page helpful?
0 / 5 - 0 ratings