On Oct 25, 2013, at 7:49 PM, Allen Wirfs-Brock <al...@wirfs-brock.com> wrote:
> It turns out that even in pseudo code, this is a fairly complicated set of > runtime validation rules to apply. I'm having a hard time convincing myself > that the runtime computational and meta data costs of this dynamic validation > is justified. It costs too much and the actual benefit is pretty small. > > ***For that reason, I propose that we drop this runtime validation of object > literals (and class definition). We would still have the static validation > and early errors for property definitions that don't have computed keys. But > anything that makes it past those checks (including all property definitions > with computed names) are just processed sequentially with no duplicate name > checking.*** Yep, I fully agree. And I especially appreciate what you say below: > What about predetermining the "shape" of literal objects that include > computed property keys? > > One of the reason for the dynamic checks was the desire to preserve the > characteristics that allowed an implementation to look at an object literal > and statically determine exactly how many own properties the resulting > objects would have. The hope was that an implementation could still > determine an intended shape and that the dynamic checks would guarantee that > the actual constructed objects conform to that predicted shape. If we drop > the dynamic checks we loose that shape guarantee. > > I think this ability to predict an intended shape was probably a committee > pipe-dream. Amen. > Consider this function: > > function makeObj(a,b,c,d,e) { > return { > get [a] () {}, > get [b] () {}, > set [c] (v) {}, > set [d] (v) {}, > set [e] (v) {} > } > } > > The object returned by this function might validly have 3, 4, or 5 > properties. The is no clearly intended shape to try to guarantee. The "shape predictability" concept has never really been defined clearly, and this is a good demonstration of why it's fishy. Anyway, agreed 100%. It's worth revisiting at the November f2f. Dave _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss