Re: __proto__ security

2012-01-29 Thread Gavin Barraclough
On Jan 28, 2012, at 3:58 PM, Allen Wirfs-Brock wrote: Since most implementations already seem to have special mechanism for giving magic behavior to certain properties I would expect them to use some of those mechanisms here. No - in JSC I'm pretty sure it's going to be faster and cleaner to

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread Peter van der Zee
Why can't we define a JSON.clone() or .deepClone() which would only clone properties that are primitives, object or array. If they are (instanceof) array, copy index properties and length value and create new array with that information. If object, create new object and copy all properties with

Re: Let's kill terms native and host

2012-01-29 Thread Wes Garland
On 28 January 2012 22:51, Mark S. Miller erig...@google.com wrote: Just because an object is provided as part of the host environment does *not* make it a host object. Given your statements above, I suspect that the Node objects you have in mind are all simply native objects provided by the

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread Mark S. Miller
Since all these candidates can be provided by libraries, this seems like an area where libraries can explore and compete. If/once a consensus emerges from such a competition, then we can revisit whether there's really any reason to standardize. If we were talking about this in time to prevent or

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread David Bruant
Le 29/01/2012 19:05, Peter van der Zee a écrit : Why can't we define a JSON.clone() or .deepClone() which would only clone properties that are primitives, object or array. If they are (instanceof) array, copy index properties and length value and create new array with that information. If

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread Mark S. Miller
On Sun, Jan 29, 2012 at 1:23 PM, David Bruant bruan...@gmail.com wrote: Based on your description, it seems that the definition would be: JSON.clone = function(o){ return JSON.parse(JSON.stringify(o)); } Or possibly: JSON.clone = function(o, opt_reviver, opt_replacer) { return

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread Peter van der Zee
On Sun, Jan 29, 2012 at 7:23 PM, David Bruant bruan...@gmail.com wrote: Based on your description, it seems that the definition would be: JSON.clone = function(o){  return JSON.parse(JSON.stringify(o)); } Yes. You can debate whether it should remove properties it can't serialize completely,

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread Xavier MONTILLET
With your last two implementations, you don't keep cyclic references. On Sun, Jan 29, 2012 at 7:39 PM, Peter van der Zee e...@qfox.nl wrote: On Sun, Jan 29, 2012 at 7:23 PM, David Bruant bruan...@gmail.com wrote: Based on your description, it seems that the definition would be: JSON.clone =

Re: Let's kill terms native and host

2012-01-29 Thread Allen Wirfs-Brock
Here is a first cut at some improved terminology: ECMAScript Object - an object whose primitive semantics are specified by the ECMAScript specification Foreign Object - an object whose primitive semantics differ from those specified by the ECMAScript specification By primitive semantics I mean

Re: Let's kill terms native and host

2012-01-29 Thread David Herman
On Jan 28, 2012, at 8:04 PM, Mark S. Miller wrote: Can we leave magical out of a spec convo? It was intended only for humorous emphasis. But even magical and non magical would be less confusing than the current terminology! In some PL research circles, they use exotic as a somewhat less

Re: __proto__ security

2012-01-29 Thread Allen Wirfs-Brock
On Jan 29, 2012, at 12:40 AM, Gavin Barraclough wrote: On Jan 28, 2012, at 3:58 PM, Allen Wirfs-Brock wrote: Since most implementations already seem to have special mechanism for giving magic behavior to certain properties I would expect them to use some of those mechanisms here. No -

Re: (How) does proto operator distiguish between function and non-function in LHS?

2012-01-29 Thread Allen Wirfs-Brock
On Jan 28, 2012, at 12:28 AM, Herby Vojčík wrote: The proposal for | cites these usage examples: - Setting the prototype of a function to something other than Function.prototype let f = EnhancedFunctionPrototype | function () {} - Parrallel constructor/instance prototype chains

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread Peter van der Zee
On Sun, Jan 29, 2012 at 7:50 PM, Xavier MONTILLET xavierm02@gmail.com wrote: With your last two implementations, you don't keep cyclic references. I did not intend to. In fact, my intention was to have a clean object with just structure (objects and arrays) and primitives. Nothing else,

Re: Deep cloning objects defined by JSON.

2012-01-29 Thread Xavier MONTILLET
I think it should keep it. Douglas did something to allow cyclic references ( https://github.com/douglascrockford/JSON-js/blob/master/cycle.js ) and he probably wouldn't have done that if it had no use. Plus you're talking of cloning data structures and a graph is one. And if you do not allow

Re: __proto__ security

2012-01-29 Thread Gavin Barraclough
Hi Allen, On Jan 29, 2012, at 4:25 PM, Allen Wirfs-Brock wrote: There are no rules that constrain [[Put]] in this manner you are suggesting. Sorry, perhaps my comments were unclear. The observation I was intending to highlight was only that the current behaviour of [[Put]] will be to call