Closed aimingoo closed 5 years ago
The colon there is a forbidden extension, which is reserved for possible future type annotations, and would conflict with TypeScript and Flow.
Additionally, the asymmetry of using private
for declaration and #
for access wouldn't be acceptable to some on the committee.
Additionally, the shorthand #data
was rejected for now, so all private access would need an explicit receiver for the time being.
@lijarb Thanks.
This is not just a proposal about syntax, its core claim is No Fields
, and delivery an implementation based on the core concept of object is a collection of properties
. This more succinct than the operational lexical context, And provides the possibility for implementations such as protectd property
.
For grammar, I think that if can't deny the existing property declaration syntax, we can't deny the rationality of private property
using :
because the latter is a property. However, I can accept the suggestion to cancel the #
shorthand, which looks good.
whether you use : or =, it’s either per-instance (fields), or its on the prototype (massive footgun).
even more ugly than original, and does not fix '#'.
@yw662
No. cannot implement protected property
base on #149 , and it explicitly uses symbols and lexical contexts. BUT, class declaration itself has no lexical environment, so the solution must also create and maintain such an environment.
The good side is No fields
. ^^.
The project at aimingoo/private-property.
The goal of this proposal is to replace the highly controversial old proposal "proposal-class-fields". The new proposal with a concise implementation and aims to propose and accomplish One objective: SIMPLE!
^^~
Thanks for all.
A showcase, I really hope you can run it in person.