-
Notifications
You must be signed in to change notification settings - Fork 19
Use this#prop instead this.#prop #35
Comments
I think the main problem with this proposal is that it's an ASI hazard. If we allow Class A {
#bar
b() {
foo()
#bar.baz()
}
} Does that code call |
@littledan > Private properties can only be inside code will be: Class A {
#bar
b() {
foo()
this#bar.baz()
}
} Word is this association in people that we turn to the current context, it is not necessary to remove and replace at Sharp. This will cause the brain confused. The algorithm is:
|
The proposal in this repository is class-local, not instance-local. For example, if you want to make an |
You mean to make sugar for this: class Cat {
constructor(){
this.arr = []
this.arr.#prop = true
}
setArr(arr){
if(arr.#prop) return;
this.arr = arr
this.arr.#prop = true
}
} compile to: let prop = Symbol()
class Cat {
constructor(){
this.arr = []
this.arr[prop] = true
}
setArr(arr){
if(arr[prop]) return;
this.arr = arr
this.arr[prop] = true
}
} That is, the symbols are automatically created, which we can use as we want? Not only in ITS EPIC IDEA, OMG =)!!! I truly understand your ideas? That is, symbols are seen in the scope of the class, and other symbols are visible in the file scope? like #prop and ##prop , no? |
Well, the proposal in this repository is based on WeakMaps, not Symbols, but yes, there is support for accessing things other than |
dot will mean access to public fields and sharp will mean access to private fields. This syntax is nicer and more logical than combination of points and sharp
Thus, the human brain will understand if we look through the point, we then turn to the public fields, if the appeal through the sharp, then to private. Also, there is no excess syntax.
Sharp does not seem much to stand out, but it's only because he did not syntactically highlighted the current engine. Here I have drawn for you an example, as if it might look like in code editors in the future:
P.S. Squares, is my font so look empty arrays []
The text was updated successfully, but these errors were encountered: