Re: Extended Object Literals to review

2011-03-12 Thread Juan Ignacio Dopazo
Right, my bad then. Juan On Sat, Mar 12, 2011 at 8:37 PM, Brendan Eich wrote: > On Mar 12, 2011, at 2:58 PM, Juan Ignacio Dopazo wrote: > > > Correct me if I'm wrong, but I think it should be like this: > > > > function S() {} > > > > function C() { > > Object.defineProperty(this, 'constr

Re: iteration order for Object

2011-03-12 Thread Jeff Walden
On 03/12/2011 12:02 AM, Brendan Eich wrote: Take it from me, JS objects are not hashmaps and any would-be implementor who tries that and tests on real code is quickly disabused of the notion. It's not going to change, for named properties or any kind of property name. This is true. It is als

Re: iteration order for Object

2011-03-12 Thread Brendan Eich
On Mar 12, 2011, at 11:27 AM, Charles Kendrick wrote: > On Mar 12, 2011, at 10:41 AM, Brendan Eich wrote: > >> On Mar 12, 2011, at 9:54 AM, David Bruant wrote: >> >>> The little "issue" I see in returning 1) index properties in ascending >>> order 2) all other properties in addition order is th

Re: Extended Object Literals to review

2011-03-12 Thread Brendan Eich
On Mar 12, 2011, at 2:58 PM, Juan Ignacio Dopazo wrote: > Correct me if I'm wrong, but I think it should be like this: > > function S() {} > > function C() { > Object.defineProperty(this, 'constructor', { > value: C, > enumerable: false, > writable

Re: Extended Object Literals to review

2011-03-12 Thread Juan Ignacio Dopazo
Correct me if I'm wrong, but I think it should be like this: function S() {} function C() { Object.defineProperty(this, 'constructor', { value: C, enumerable: false, writable: false, configurable: false }); } C.prototype = Object.create(S.prototype); var o = new C(); console.log(o.constructor

Object property for-in enumeration as an internal method

2011-03-12 Thread David Bruant
Hi, I think it would be worth for spec readability to give a name to the for-in property enumeration internal method and list it as such in ES5 8.6.2 Table 8 regardless the fact that it is implementation-dependent. >From the spec edition point of view, it would require a bit of re-writing for the

[Harmony Proxies] Adding a defineProperties derived trap

2011-03-12 Thread David Bruant
Hi, The thread entitled "iteration order for Object" made me realize that there is no defineProperties trap. Let's imagine I'd like to implement an object which would keep track of order in which own properties have been added/deleted to it. With the defineProperty and delete traps I can already

Re: iteration order for Object

2011-03-12 Thread David Bruant
Le 12/03/2011 21:24, Allen Wirfs-Brock a écrit : > On Mar 12, 2011, at 11:58 AM, David Bruant wrote: > >> Le 12/03/2011 19:41, Brendan Eich a écrit : >>> On Mar 12, 2011, at 9:54 AM, David Bruant wrote: The little "issue" I see in returning 1) index properties in ascending order 2) all ot

Re: iteration order for Object

2011-03-12 Thread David Bruant
Le 12/03/2011 20:58, David Bruant a écrit : > Le 12/03/2011 19:41, Brendan Eich a écrit : >> On Mar 12, 2011, at 9:54 AM, David Bruant wrote: >>> The little "issue" I see in returning 1) index properties in ascending >>> order 2) all other properties in addition order is that there is a bit >>> of

Re: iteration order for Object

2011-03-12 Thread Allen Wirfs-Brock
On Mar 12, 2011, at 11:58 AM, David Bruant wrote: > Le 12/03/2011 19:41, Brendan Eich a écrit : >> On Mar 12, 2011, at 9:54 AM, David Bruant wrote: >>> The little "issue" I see in returning 1) index properties in ascending >>> order 2) all other properties in addition order is that there is a bit

Re: iteration order for Object

2011-03-12 Thread David Bruant
Le 12/03/2011 19:41, Brendan Eich a écrit : > On Mar 12, 2011, at 9:54 AM, David Bruant wrote: >> The little "issue" I see in returning 1) index properties in ascending >> order 2) all other properties in addition order is that there is a bit >> of information lost in the process: overall property

Re: iteration order for Object

2011-03-12 Thread Charles Kendrick
Bradley, the proposal is to define the iteration order for Object only, not all objects (eg Array). Also, if you were choosing between: 1. The strawman: preserve insertion order for non-index properties only, on both Object and Array 2. My proposal: preserve insertion order for all properties

Re: Extended Object Literals to review

2011-03-12 Thread Allen Wirfs-Brock
good point, the desugaring should be: function c() {}; c.prototype=Object.create(s,protoype,{'constructor': { value:c, enumerable: false, writable: false, configurable:false}}); We can debate about the attributes of the constructor (and the constructor's prototype) property but my stake in the

Re: iteration order for Object

2011-03-12 Thread Charles Kendrick
On Mar 12, 2011, at 10:41 AM, Brendan Eich wrote: > On Mar 12, 2011, at 9:54 AM, David Bruant wrote: > >> The little "issue" I see in returning 1) index properties in ascending >> order 2) all other properties in addition order is that there is a bit >> of information lost in the process: overal

Re: Extended Object Literals to review

2011-03-12 Thread Michael Haufe
On Sat, Mar 12, 2011 at 11:02 AM, Allen Wirfs-Brock wrote: [...] > class c { > > } > class c { > > } > both are equivalent to: > function c() {}; > c.prototype=Object.create(s.prototype); [...] So if "var b = new c", then "b.constructor" will be "s" instead of "c"? _

Re: Extended Object Literals to review

2011-03-12 Thread Allen Wirfs-Brock
I've added basic desugaring patterns to the class initialisers wiki page to clarify things. On Mar 12, 2011, at 9:44 AM, Juan Ignacio Dopazo wrote: > (note correction in function c() {} example below. the Object.create is an > essential part of the semantics) > > That makes complete sense! So

Re: iteration order for Object

2011-03-12 Thread Allen Wirfs-Brock
On Mar 12, 2011, at 10:41 AM, Brendan Eich wrote: >> >> What is the rational or use case behind having index properties at first >> for objects and then the rest of properties? > > The "rationale" (such as it is) is that JS conflates lists and dicts in > objects, but users mostly think about o

Re: iteration order for Object

2011-03-12 Thread Brendan Eich
On Mar 12, 2011, at 9:54 AM, David Bruant wrote: > The little "issue" I see in returning 1) index properties in ascending > order 2) all other properties in addition order is that there is a bit > of information lost in the process: overall property addition order > (index properties included). T

Re: iteration order for Object

2011-03-12 Thread David Bruant
Le 12/03/2011 09:06, Brendan Eich a écrit : > On Mar 11, 2011, at 12:49 PM, Charles Kendrick wrote: > >> Yes Allen, hence the urgency. If IE9 final ships that way, the >> "goose is cooked": > > I hear tell of something happening next Monday. Goose, well-done, > stuffed, I think. > > >> 1. we will

Re: Extended Object Literals to review

2011-03-12 Thread Juan Ignacio Dopazo
> > (note correction in function c() {} example below. the Object.create is an > essential part of the semantics) > That makes complete sense! So the resulting prototype will be a new object. Perfect! Why were class bodies chosen as object initializers instead of function > bodies? > > In ord

Re: Extended Object Literals to review

2011-03-12 Thread Allen Wirfs-Brock
(note correction in function c() {} example below. the Object.create is an essential part of the semantics) On Mar 12, 2011, at 6:04 AM, Juan Ignacio Dopazo wrote: > Hi! I hope you don't mind a couple of questions about this proposal. > > The meta property definition says: > > This causes th

Re: Extended Object Literals to review

2011-03-12 Thread Allen Wirfs-Brock
On Mar 12, 2011, at 6:04 AM, Juan Ignacio Dopazo wrote: > Hi! I hope you don't mind a couple of questions about this proposal. > > The meta property definition says: > > This causes the [[Prototype]] value of the new class’ prototype to be set to > the prototype property value of the designat

Re: [Harmony Proxies] Non-constructable, but callable function proxies

2011-03-12 Thread David Bruant
Le 12/03/2011 11:29, Tom Schuster a écrit : > Hi, > > the current definition of [[Construct]] doesn't allow to create > non-constructable objects, but instead just invokes the call handler. > On easy hackaround would be to check if the constructhandler has a > [[Construct]] internal method. Then yo

Re: Extended Object Literals to review

2011-03-12 Thread Juan Ignacio Dopazo
Hi! I hope you don't mind a couple of questions about this proposal. The meta property definition says: This causes the [[Prototype]] value of the new class’ prototype to be set to > the prototype property value of the designated constructor function Shouldn't the superclass' prototype be chai

Re: A proposal to add String.prototype.format

2011-03-12 Thread Christian Mayer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Am 09.03.2011 19:48, schrieb P T Withington: > > Disagree. Since ECMAScript knows the type of the arguments, it does _not_ > need the format specifier to tell it the type (as C does). Perhaps not for the data type - but for the representation of

[Harmony Proxies] Non-constructable, but callable function proxies

2011-03-12 Thread Tom Schuster
Hi, the current definition of [[Construct]] doesn't allow to create non-constructable objects, but instead just invokes the call handler. On easy hackaround would be to check if the constructhandler has a [[Construct]] internal method. Then you could create non constructable Functions like this:

Re: iteration order for Object

2011-03-12 Thread Claus Reinke
Below are two partial implementations of LinkedHashMap in JavaScript, with test code to populate with lots of keys and remove half the keys at random, then alert() the results. Both implementations add and maintain an index to provide O(1) lookups. Each is compared to the speed of the equival

Re: iteration order for Object

2011-03-12 Thread Claus Reinke
I believe it is very very important that the ECMAScript standard specify that when a new Object is created, for..in iteration traverses properties in the order they are added, regardless of whether the properties are numeric or not. Some users might prefer 'in the order of keys'. That is predict

Re: iteration order for Object

2011-03-12 Thread Brendan Eich
On Mar 11, 2011, at 12:49 PM, Charles Kendrick wrote: > Yes Allen, hence the urgency. If IE9 final ships that way, the "goose is > cooked": I hear tell of something happening next Monday. Goose, well-done, stuffed, I think. > 1. we will have a new de facto standard iteration order for Object

Re: iteration order for Object

2011-03-12 Thread Brendan Eich
On Mar 11, 2011, at 12:11 PM, Charles Kendrick wrote: > And again, I find your notion that an Object is "obviously" a HashMap very > suspect. John's simply mistaken :-). Take it from me, JS objects are not hashmaps and any would-be implementor who tries that and tests on real code is quickly d