Structured clones

# Anne van Kesteren (6 years ago)

The platform has the capability to make a structured clone of an object (and primitives): www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#safe-passing-of-structured-data

This is used for history traversal as well as passing data between global objects that cannot reach other synchronously (e.g. a document and worker environment).

Should this capability become part of JavaScript? When new objects such as Map are defined or such an object is implemented by a JavaScript library they can then "automatically" participate in the structured clone fun.

# Mark S. Miller (6 years ago)

For those new to these lists, < lists.w3.org/Archives/Public/public-script-coord/2011JulSep/0055.html>

may provide some context. The structured clone algorithm has changed since then. But looking this over, I think most of these points are still relevant. See also the rest of the thread starting at this message.

# Anne van Kesteren (6 years ago)

With to #4 in that message, Blob/File/FileList are readonly, so there is no writing to the same object.

Given that workers and indexed DB depend on this feature it is not going away. We could rebrand it as marshalling as suggested in that thread I suppose, but I was mostly interested if this was something we should be able to express in JavaScript as well.

There's also a concept of transferable objects for objects to which you can write, such as ArrayBuffer.

# Anne van Kesteren (5 years ago)

This has come up again: lists.w3.org/Archives/Public/public-whatwg-archive/2013Sep/0023.html

This concept will keep growing and is used by multiple APIs these days. I don't really have any concrete proposals, but it seems like something we should solve at the language level and not monkey patch on top of it. It's probably late again as with ArrayBuffer to design something from the ground up, but maybe there's still salvageable bits.

# Anne van Kesteren (5 years ago)

On Wed, Sep 4, 2013 at 4:18 PM, Anne van Kesteren <annevk at annevk.nl> wrote:

This has come up again: lists.w3.org/Archives/Public/public-whatwg-archive/2013Sep/0023.html

This concept will keep growing and is used by multiple APIs these days. I don't really have any concrete proposals, but it seems like something we should solve at the language level and not monkey patch on top of it. It's probably late again as with ArrayBuffer to design something from the ground up, but maybe there's still salvageable bits.

strawman:embracing_workers

# Dmitry Lomov (5 years ago)