Skip to content
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

[Godot] Add access modifiers, private and public, to GDScript #7

Open
Lazy-Rabbit-2001 opened this issue Oct 16, 2024 · 4 comments
Open
Labels
topic:gdscript tracked:godot Issue already tracker on the godot issue tracker

Comments

@Lazy-Rabbit-2001
Copy link

Lazy-Rabbit-2001 commented Oct 16, 2024

Describe the project you are working on

Original proposal: godotengine#641
Original pull request: godotengine/godot#98136
Linked PR: Redot-Engine/redot-engine#734

Describe the problem or limitation you are having in your project

According to the original proposal, "_" as access modifier is ok for properties, but confusing for methods when it comes to "being private/protected" or "being virtual". Check the original proposal for the rest info.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Currently, I posted a pull request about adding @private and @protected annotations to achieve this as annotations are easy to be implemented than keywords. However, based on what dalexeev said, annotations is handled later than keywords. So I then added two reserved word versions of the annotations, which are now reserved for implementation. Check the original pr for more details

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Check the original pr.

If this enhancement will not be used often, can it be worked around with a few lines of script?

No, because this is related to source code

Is there a reason why this should be core and not an add-on in the asset library?

The same answer as the previous question

@Lazy-Rabbit-2001
Copy link
Author

I shouldn't have write the full links here. Gosh, under the orignal pr and proposal can be found this proposal. 😒
How foolish I was...

@heavymetalmixer
Copy link

I'll be following this one

@tokengamedev
Copy link

Access modifier is a heavy topic and will be increasing the complexity of the language.
I don't like to use access modifiers outside object-oriented language like C# and C++, but I don't mind having it in code.

This access modifier has been debated for and against it in the original proposal,
It is unlike structs which was accepted by all and only discussion was about ways of implementation of struct.

Moreover, I would like to see how the annotations will work, as part of the language. It is just cryptic here in the proposal and original proposal did not clarify. I doubt you are planning to implement full-fledged access restrictions in the language. Need to understand more.

I hope it will not impact performance of the game during runtime, given GDScript is running slower than C#.

@Spartan322 Spartan322 changed the title [Transplanted from Godot] Add access modifiers, private and public, to RDScript [Godot] Add access modifiers, private and public, to GDScript Oct 17, 2024
@TrickyFatCat
Copy link

As a technical game designer, who works a lot with other game designers who aren't good at programming, I really want to have some access specifiers. They really helps to create safe environment for people, who can experiment with my tools and mechanics with less risk to break something.

I would say, it would be great to have, at least, public and protected variables and functions. In my experience working with Unreal Engine I use them most of the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:gdscript tracked:godot Issue already tracker on the godot issue tracker
Projects
None yet
6 participants