Presumably if I ask for p$a or p$b later, it's because I'm interesting
in the value of "p$a" or "p$b" that I specifically put inside that
environment. ?Otherwise I would just ask for "a" or "b". ?If I'm
asking for "p$b" it the above case, that means I forgot to declare b
inside p. ?In this case there should be an error telling me that, not
a silent substitution of the wrong quantity.
If someone wanted to do the y$ls() thing, they could always
y <- proto(a=1)
with(y, ls())
[1] "a"
Another reason is that there are plenty of other programming languages
that have similar structures and this behavior is very odd. ?In
standard languages asking for "b" inside the "p" object gives you an
error, and no one complains.