-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose statics on instances #14
Comments
The # prefix doesn't mean "static". If is something completely different, a non-property "field" that can only be referenced from within the body of the class that defines it. What you are asking for seems to be what some language call "protected" fields (or properties). |
I must have been conflating different topics. I'm not very interested in private fields. My real interest is in getting a this.myStatic, in having static imply singleton accessible both from on the constructor and from the instance. It feels like more of a stretch ask, but semantically I've always found it be-deviling that no language makes it easy to ask for a static by name for the current instance. |
Do you mean you want a syntactic way to do |
or something like what is shown in #16 (comment) |
I'm curious why this.#helper() would be disallowed? This seems to be a very very common language pattern, but I've never understood a good reason for it.
I understand that it's not the instance per-se that has the field, but it's class does, and the # implicitly says to me- look at this instance's class for this field.
There are a number of very straightforward and useful places where having static methods virtualized seems like it'd be potentially very handy. A really simple example of what this could enable:
It seems intuitively obvious and simple to a laymen like me that I'd want to be able to ask for whatever the current class's static is. Time and time again I run into languages where this is impossible or requires extensive and painful reflection steps to accomplish. I can understand the conceptual argumentation that
this
doesn't have a static field, but especially if we have a symbol designating that the field is static-#
it seems like there's no chance for ambiguity and we can should and ought allow this straightforward ask- give me the static field for whatever my class is.In EcmaScript, not having this would imply having to write userland code to walk the prototype chain, looking at constructors. This seems suboptimal and painful from a usability and performance standpoint both.
I'd like to see statics exposed on instances, especially given that there is a
#
indicator in front of the field indicating very clearly the user's intent to look at statics. Please allowthis.#helper()
.The text was updated successfully, but these errors were encountered: