On Jul 19, 2011, at 11:56 AM, Luke Hoban wrote: >>> Object.extend(src, dest) > >> This is certainly closest to paving the cowpath. Either via a built-in >> module exporting 'extend', or as you suggest, directly on Object. The >> Object.extend route is a bit harder to analyze, but not fatally so for any >> capable static analysis framework. >> Either way (built-in module or Object.extend), old script (Hi Luke! ;-) >> could use it too. > > Agreed - this was my initial reaction to <| as well, and I still see a number > of reasons to prefer a library solution over a syntax solution for both > 'Obect.extend' and 'Object.make'. > > The arguments for <| as an operator seemed to boil down to: > 1) It's more 'declarative' > 2) It can be optimized by engines
One issue is that <| conceptually modifies the [[Prototype]] of its RHS. As an operator (whether special character or keyword based) we can restrict the RHS to be a literal and define the behavior such that no actual mutation of [[Prototype]] is necessary. However, at the value level we have no way to distinguish an object that was created via a literal and which has no references other than the current argument value. So, when we specify Object.make we have to accept an arbitrary object as the second argument and specify either [[Prototype]] mutation or some sort of shallow copy, either of which can be problematic. Allen _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

