Re:JavaScript TC39 implementing hashmark private class fields
by spankalee on Thursday August 03, 2017 @03:24PM
(#14922893)
It gets really tricky when you have any kind of polymorphism, intended or not.
If you accept instances of your own class as arguments to a method, you may be templated to think you can access the private fields of those arguments, even if instanceof checks pass, but they may not be there.
C++ works that way, and several other languages do as well. And the use case mentioned in that comment is exactly the reason: the implementation of a class knows how to access both its own private fields and those of another instance of itself, so that it can do comparisons, combinations, or other operations.