On Tue, Oct 4, 2011 at 8:56 PM, John J Barton <[email protected]>wrote:
> In trying to update my JS approach I looked into 'traits'. I'm still on the > fence about using them at this stage, but MarkM was asking for feedback of > pretty much any kind so here is a little. > > I believe I understand traits for the most part just from the info on the > Web site: > http://traitsjs.org/ > (but read the examples in the Paper, not the one in the Tutorial). > Traits feel like JS to me: a reusable set of methods packaged in an object. > The Trait construct add regularity and organization to a wide-spread pattern > of JS use, but it feels like a tool you pick up when you need it. The key > operations are create and compose, with resolve and override to handle > exotic issues. > > On the other hand I had the opposite reaction to > http://wiki.ecmascript.org/doku.php?id=strawman:syntax_for_efficient_traits > That proposal is a completely different language with many new keywords and > operators. > > I came away deciding to stop using |prototype| + new in favor of > Object.create() and to revisit the traits.org library after a bit. > Ok that was a quick experiment. I completely misunderstood Object.create(). I imagined that Object.create(a,b) returned an object with the properties of b and a __proto__ of a. Unfortunately the second argument is some kind of meta object. So to get {p:42} you have to write { p: { value: 42, writable: true, enumerable: true, configurable: true } }. Oy vey. jjb
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

