[Bug 12845] Disallow shadowing attributes

http://www.w3.org/Bugs/Public/show_bug.cgi?id=12845

--- Comment #7 from Allen Wirfs-Brock <allen@wirfs-brock.com> 2011-06-02 01:43:18 UTC ---
(In reply to comment #5)
> I'm not actually sure what the problem with the shadowing attribute is.  As
> others say, the property on Bar.prototype will need to have both a getter and a
> setter.  The spec defining these interfaces should just define what Bar::quux
> returns on getting.  That definition could be "Returns the same thing as
> Foo::quux".

My reading of the original question is that Bar wants to define the setter
while continuing to inherit the getter from Foo.  (of course, these are just
interfaces, but the binding needs to say what concretely happens.)

If that is the intended meaning, then it doesn't match a naive JS
implementation because JS always defines getter/setter pairs.  JS doesn't have
the concept of over-riding just a getter or just a setter.

There are at least 2 ways you might interpret this in a JS binding,
1) say that the implementation of Bar's quux (either in Bar.prototype or copied
to avoid MI issues) uses the same getter function as Foo's quux.
2) say that the implementation of Bar's quux getter dynamically delegates Foo's
guux getter as if by evaluating Foo.prototype.quux.call(this)

In solution 1, if somebody dynamically changes the getter of Foo quux is won't
be seen by objects that implement the Bar interface.  In solution 2, such a
dynamic change would be visible to Bars

> 
> One question is whether we need to make
> `Object.getOwnPropertyDescriptor(Foo.prototype, "quux").get ==
> Object.getOwnPropertyDescriptor(Bar.prototype, "quux").get`.  I don't think we
> do.

For solution 1, it could be defined so it came out either way. For solution 2
it is going to have to be false.

Solution 2 seems to be the directly we are heading in ES.next.  I'd recommend
you go that route.

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Thursday, 2 June 2011 01:43:20 UTC