zenparsing / proposal-virtual-properties

0 stars 0 forks source link

Analogy between public and private #6

Open littledan opened 6 years ago

littledan commented 6 years ago

The class fields and private methods proposals create an analogy between public and private, where class elements can be given names starting with # and see generally corresponding semantics, with the main exception being that # private elements are not visible outside the class, and various operations on them will lead to either a TypeError, a SyntaxError, or just appearing to be missing (as an implication of privacy, basically).

This proposal doesn't seem to attempt such an analogy. Instead, it provides better ergonomics for using WeakMaps. I'm worried that this design will make it harder to refactor between public and private (in both directions) and provide additional cognitive overhead in the simpler cases.

What do you make of the lack of an analogy here?

zenparsing commented 6 years ago

The supposition here is that the public/private analogy creates more problems than it solves, and that hard privacy should not be used unless you really want hard privacy. The hypothesis is that for the majority of use cases, users just want a type system.