On Nov 13, 2011, at 9:24 AM, Jake Verbaten wrote:

> On Sun, Nov 13, 2011 at 4:51 PM, Rick Waldron <waldron.r...@gmail.com> wrote:
> 
> 
> On Nov 13, 2011, at 11:03 AM, Jake Verbaten <rayn...@gmail.com> wrote:
> 
>>> However having a deep copy mechanism that works without obscure edge-cases 
>>> would be great.
>> 
>> Can you be specific? What obscure edge cases have you previously encountered?
>> 
>> 
>> I don't have a list at hand, last time we talked about what it means to deep 
>> copy an arbitary ES-next structure we ran into questions of what it means to 
>> deep copy functions, closures and proxies.
> 
> Can you point me to existing discussion threads? 
> 
> The only thing I can find is 
> https://mail.mozilla.org/pipermail/es-discuss/2011-October/017337.html

Quoting with s/identify/identity/g:

No, generalized object clone is relatively hard.  Some other issues:

It isn't just the [[Class]] internal property.  It is all the other 
representational and behavior invariants implied by [[Class]]
What if the object is a Proxy instance?
How should private name properties be handled.
What if there are identity based internal state relationships within the object.
What if there are identity bases external relationships about the object (eg, 
it's used as a key in a WeakMap)
etc.

In other language "clone" has generally evolved into a little frame that allows 
application level control of some or all of these decisions. 

I'm not saying that some sort of generalized clone wouldn't be useful.  Just 
that it's not so simple.

Allen


> This particular thread talked about <| and how to make it work on object 
> references rather then object literals. Since <| returns a new object it 
> would have to "clone" the object reference in some "correct" manner.
>  
> 
>> 
>> Deep copying "data", i.e. anything that can be represented by JSON doesn't 
>> have too many edgecases.
>> 
>> It would actually be nice to have an open lists of unsolved edge cases with 
>> generic deep copying.
> 
> This would definitely be useful.

See above!

The hard cases include:

1. Closures.
2. Proxies.
3. Private names.
4. Internal hidden state.
5. Side-table entries mapped to the object's identity.

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to