-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Improve description of annotations #9188
Improve description of annotations #9188
Conversation
33a4907
to
25e6104
Compare
I still think the specifics of what annotations are isn't relevant to this article, I don't think it should even mention keywords because it's irrelevant |
I’m intentionally leaving this as a draft PR until after the Tuesday GDScript meeting, in case that meeting highlights any other ways annotations could be described in documentation. |
I don't agree that the difference between annotations and keywords is how the script is compiled. In fact, annotations affect the script behavior and the bytecode generated (for example, I think annotations in GDScript are not much different from keywords. Annotations are not just metadata like attributes in PHP and not a clear language feature like decorators in Python. Differences between annotations and keywords:
|
Is If not for those counterexamples, it would be tempting to think of keywords as nouns and annotations as adjectives. |
25e6104
to
180271f
Compare
Thanks for starting on this allenwp! I'm kind of wondering whether a change like this would be better suited for the "contributing" section of the docs. The user doesn't really care whether static is a keyword or an annotation and why, they just want to know what to type to make their function static. On the other hand, when contributing to GDScript, you'd want some guidelines as to whether to make your new feature of keyword or annotation. |
In principle, any keyword could be an annotation (and then you could do something like |
💯 Yep, a new Contributing page should be added with guidelines that go into detail on keywords vs annotations. Maybe I could include that new page in this PR, but I feel I am not the person to write it, as the nuance goes beyond my experience and understanding... |
Actually, maybe I can take stab at this… Here is a thought on how a Contributing section could be written on this subject. It would pair nicely with this current PR draft for the user-facing documentation: Keywords vs AnnotationsIf the primary purpose is to affect the way that the engine, editor, or external tools treat or interact with the script, it should be implemented as an annotation. Otherwise, it should be implemented as a keyword. Edit: I've pushed a new page to the Contributing section of the docs that adds some details on annotations vs. keywords. Please let me know if I've done this correctly, as this is my first time making this sort of change. |
d455033
to
3c476b7
Compare
contributing/development/core_and_modules/scripting_development.rst
Outdated
Show resolved
Hide resolved
One important note that was brought up during the meeting was that Contributing guidelines should be written based on what we want future tokens to be implemented as, not based on describing all existing annotations and keywords perfectly. |
An alternative to godot-specific vs general programming is whether the token is more important at run time or compile time. Or maybe another way to say it would be, whether the token operates within the code or on the code itself. For example, one can think of Similarly, you can think of In contrast, keywords like This is also maybe a more helpful guideline for new keywords/annotations going forward. Whereas the distinction between game/Godot-specific and general programming can be fuzzy, I think the distinction between run time/compile time is more clear and might have technical implications about how the feature is implemented. For example, one could imagine designing the GDScript compiler/VM in such a way that all annotations are resolved before non-annotations. This would essentially make annotations an avenue for metaprogramming (e.g. |
I think there is some promise with the concept of "annotations operate on the script's code" (as in, the annotations are not considered the "code of the script". I think this is a little different than the historical/previous definitions of GDScript annotations, but again this could be a good thing. The wording of "the token is more important at runtime" might be confusing to some people, as I interpreted that to mean that annotations like I will try to make some time in the next week or two to write out a new draft with this sort of wording instead, so we can compare it. |
4599b24
to
a6f3e63
Compare
I just pushed a commit that reworks some of the PR. I think this basically the best I can do with annotation documentation for users and contributors based on the comments and discussion that I've seen in RocketChat, the GDScript meeting, and here in this PR. The line I added was:
Unfortunately, I don't entirely believe that this new documentation actually helps all that much in guiding whether abstract should be implemented as an annotation or as a keyword. The way I would interpret it is that These new changes remove the suggestion from @akien-mga:
With this new approach, some language features that act on the code, such as metaprogramming, would be implemented as annotations instead of keywords. |
compilation details because these are often inconsistent between annotations | ||
|
||
Create annotations for modifiers that act on the script or its code. | ||
Addionally, create annotations for behaviour that is specific to the Godot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addionally, create annotations for behaviour that is specific to the Godot | |
Addionally, create annotations for behavior that is specific to the Godot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I unmarked this as resolved since the PR still have the previous word.
63bf2c2
to
71e4e2c
Compare
In yesterday's GDScript meeting, the decision was made to implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the description of annotations is a good fit for what has been discussed with the GDScript team and it's an improvement of what was there before.
Removes an unnecessary and potentially confusing comparison of annotations to keywords and generally improves wording in the GDScript Basics tutorial. A new page to the Contributing section has been added for scripting development guidelines. This new page hosts suggestions on when annotations should be implemented in GDScript.
71e4e2c
to
8dd09aa
Compare
Merged. Thanks! Good idea to document the results of this discussion. :) |
This change uses wording from discussions in the RocketChat GDscript channel.