-
Notifications
You must be signed in to change notification settings - Fork 113
Private Properties Syntax #6
Comments
See the FAQ for private fields. In short: of course we started out trying to make it work with the same syntax used in other languages. That turns out not to work. |
At the next TC39 meeting, I'll raise this concern again. However, I'm not sure how much more ground there is to cover here--this has already been thoroughly discussed in the private fields issues. |
@littledan I understand why access to private fields needs a specific syntax, but that's not true for the declaration. Was the possibility of having a keyword like |
@dinoboff See the FAQ for private fields. |
So |
We discussed the possibility of an additional keyword for declarations at TC39. Ultimately, we were pretty firm that the declaration should include the |
In my opinion the sigil # looks like a syntactic noise and I'd to see something more compatible with TypeScript and other languages. class Foo {
private x = 1;
public y () {
return this->x;
}
}
let foo = new Foo();
foo.y(); // 1 Why not to use the arrow -> instead of the dot .? |
@monolithed for your first question, please read the FAQ (this is also answered about 3 comments up) |
I have opinion against syntax for private properties and methods in this proposal.
Many languages have keywords
private
,protected
,public
. I suggest to add that keywords against#
syntax. It's looks like you guys reinventing the wheel, but we have that syntax many years in languages like Java or C++ or PHP etc.And making JavaScript with "something" new is harm to JavaScript. I think Javascript need to be more closer to other languages like Java or C# or TypeScript (where we have private/protected/public modificators). And don't create your "own" things.
The text was updated successfully, but these errors were encountered: