Re: Object.prototype.get bye bye Object.defineProperty

2012-12-01 Thread Herby Vojčík
Maybe some little kind of protection would be helpful. One of minimal solution I see is to have a well-known object that holds all of the descriptor defaults (Reflect.defaultPropertyDescriptor), and: - when returning descriptor from API, make it `__proto__:R.dPP` - when creating descriptor,

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread David Bruant
Le 29/11/2012 06:20, Brandon Benvie a écrit : The answer though in that case is easy enough though, make sure the prototype descriptor is created with Object.create(null). This wouldn't solve compatibility issues with in-the-wild code but it solves the issue for most people who care enough to

RE: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Nathan Wall
Object.defineProperty(obj,key, Object.create(defaultDataProperty, {value: 123}); Er, shouldn't that be: Object.defineProperty(obj,key,Object.create(null, {value: {value: 123}})); Seems pretty excessive. It's probably too late to make defineProperty only look at own properties, but how about

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread David Bruant
Le 29/11/2012 16:47, Nathan Wall a écrit : In addition, it'd be nice if there was an easier way to create an object with no [[Prototype]]... some sort of addition to object literal notation? I think ES6 will have such a notation with the __proto__ de facto standardization: var o = {

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Allen Wirfs-Brock
On Nov 29, 2012, at 7:47 AM, Nathan Wall wrote: Object.defineProperty(obj,key, Object.create(defaultDataProperty, {value: 123}); Er, shouldn't that be: Object.defineProperty(obj,key,Object.create(null, {value: {value: 123}})); oops, yes create requires an addition object layer

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread David Bruant
Le 29/11/2012 17:02, Allen Wirfs-Brock a écrit : On Nov 29, 2012, at 7:47 AM, Nathan Wall wrote: Seems pretty excessive. It's probably too late to make defineProperty only look at own properties, but how about making it ignore properties inherited from Object.prototype? Fairly complex to

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
I really don't understand what is exactly the advantage of considering inherited properties for descriptors. If you create a new instance with those properties using a class to avoid writing them ... what are you gaining against a literal object? If you are doing this in order to have less code

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Brendan Eich
Andrea Giammarchi wrote: I really don't understand what is exactly the advantage of considering inherited properties for descriptors. It's easy to overreact here. Don't mess with Object.prototype still applies, or you will have other WTF moments. ES5 shipped this and browsers shipped

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
I will ... but I still would like to know why other developers are using inheritance for this. No memory, performance, size, benefits and more verbose code, i.e. Object.defineProperty(o, p, Object.create(null, {value:{value:v}})) OR Object.defineProperty(o, p, new DefaultDescriptor(v)); VS

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Brandon Benvie
Here's a place I've made use of it, note Descriptor and Descriptors. https://github.com/Benvie/benvie.github.com/blob/master/client/modules/site/introspect.js#L221 ___ es-discuss mailing list es-discuss@mozilla.org

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
that's actually cool, but you suffer same problem? :-) desc.enumerable = 'get' in desc; On Thu, Nov 29, 2012 at 1:07 PM, Brandon Benvie bran...@brandonbenvie.comwrote: Here's a place I've made use of it, note Descriptor and Descriptors.

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
Updated MDN: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty#Description Hope it's fine, feel fere to edit/add/change that, thanks On Thu, Nov 29, 2012 at 12:23 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: I will ... but I still

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-28 Thread Allen Wirfs-Brock
On Nov 28, 2012, at 6:40 PM, Andrea Giammarchi wrote: This was not true at some point, but now it seems to be the case in every browser. Just Object.prototype.get = function(){}; and any further attempt to use Object.defineProperty(obj, key, {value:123}) will fail because

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-28 Thread Brandon Benvie
To answer that question, I do. I reuse descriptors often for performance but also use prototypal inheritance as well.Since most descriptors share the same common properties for all but one (or two) fields, they are an ideal candidate for use with prototypal inheritance. The answer though in that