3 ms·
The solution that TC39 voted is based on requirements that can only be satisfied by having the ugly `#`. Namely they voted for encapsulation / hard-private [#3
by drinchev 8y ago
The solution that TC39 voted is based on requirements that can only be satisfied by having the ugly `#`.
Namely they voted for encapsulation / hard-private [#33] as well as comparing private properties of two classes [2], which as a result makes the only possible syntax the one with the `#`.
Unfortunately this comes at the price that once browsers implement this it will become history ( same as the `with` statements [3] and `labels` with `continue` [4] ). Because of backwards compatibility these will never be removed.
Maybe in 2022 TC39 will decide that "use static-type;" will be a mode, such as strict mode, where you can write statically typed JS ( great idea, btw ), where this
proposal will make no sense. Another "use class-inheritance;" mode would also finally end the abuse of prototype inheritance with syntax sugar. In this future the `#` will be just a huge annoyance.
#33 : https://github.com/tc39/proposal-private-fields/issues/33 https://github.com/tc39/proposal-private-fields/issues/33
2 : https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#why-does-this-proposal-allow-accessing-private-fields-of-other-instances-of-the-same-class-dont-other-languages-normally-forbid-that https://github.com/tc39/proposal-class-fields/blob/master/PR...
3 : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
4 : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/continue https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- JeremyBanks 8y agoI can sort-of understand the desire for the values to be hard-private, but I think even that would be achievable without new syntax[1]. However, they also want the existence and names of the properties to be hard-private, which seems excessive. (And linguistically inconsistent with the choice of non-hard-privacy for symbols.) [1]: https://github.com/tc39/proposal-class-fields/issues/177#issuecomment-448292545 https://github.com/tc39/proposal-class-fields/issues/177#iss...
- ksec 8y agoMay be by actively making Javascript Shorter and uglier, to steer people away from it, and making JS a compiling target only? I mean whenever I see # I thought I am either on tweeter or the code was commented out.