David Herman dherman at mozilla.com
Thu Nov 17 14:29:06 PST 2011

On Nov 17, 2011, at 2:15 PM, Brendan Eich wrote:

> On Nov 17, 2011, at 2:08 PM, David Herman wrote:
>>> Prototype extension or delegation is not the same as FRU at all -- the delegating object can shadow proto-properties,
>> That's precisely what makes it analogous to FRU. You functionally update (i.e., update without mutating) by shadowing.
> Mutating [[Prototype]] is still mutation :-P.

Who's mutating [[Prototype]]? This is Object.create.

> The fact that you get a chain of two or more objects instead of one is the big thing about this that makes it not FRU to me. We don't have records, of course, but squinting hard at objects might make them look as pretty (need beer goggles ;-). But only own properties of a single object, so I'd want FRU of this kind:
> let o = { p:1, r:3 };
> let u = { o where p:1, q:2 };
> and u would have own p, q, and r.

Yes, this is of course a different semantics than prototype extension. I'm not sure there's a "canonical" definition of what FRU means in the presence of mutation. I think Ocaml agrees with you, FWIW. The cost model of prototype extension can be nice, since you aren't repeatedly copying the entire structure. (Of course, lookups can get more expensive.)

Anyway, I've already cried uncle. Not that I'm gonna stop using Object.create for FRU any time soon. ;)


More information about the es-discuss mailing list