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

Add a "callback" keyword #24320

Closed
QbieShay opened this issue Dec 13, 2018 · 9 comments
Closed

Add a "callback" keyword #24320

QbieShay opened this issue Dec 13, 2018 · 9 comments

Comments

@QbieShay
Copy link
Contributor

Godot version:
11d7738

Issue description:
Add a editor-specific keyword (similar to export or even export) for marking functions as callbacks, so that only callbacks show up when connecting a signal and making a function track in the animation player.
Related to #24316

@akien-mga
Copy link
Member

no-keyword

@bojidar-bg
Copy link
Contributor

Might be easy to do once #20318 is in place.

@akien-mga
Copy link
Member

More seriously, that's yet another use case that would be better with annotations instead of a keyword.

@vnen
Copy link
Member

vnen commented Dec 13, 2018

I don't see how useful this would be. It only makes sense if you have a lot of functions and signals in the same script, at which point you might consider splitting the script into more dedicated libraries. It's also often the case that you have a function to connect to a specific signal so even if it shows up in such list you would only use it once.

I'm also not fond of adding keywords to GDScript just to provide a help in the editor. If this becomes a thing then it should have a practical meaning in the language. For instance, we could make that only callback functions can be connected to signals (and called from the AnimationPlayer as well, maybe). But I don't think this would be helpful.

@QbieShay
Copy link
Contributor Author

@vnen I agree with @akien-mga , they should be annotations, that can possibly be kicked out on export.

I disagree with what you said about splitting in different libraries: if you take a look into a call function track interface, even the simplest Node (a bare node) has already 20-30 methods in the list.

But, on the other hand, I am not sure how i would feel if i had to declare a function in my script only to forward a function to the editor. Maybe the functions not marked as export or callback could be folded, so still accessible but not crowding your screen.

@girng
Copy link

girng commented Dec 14, 2018

functions can already be used like callbacks, i'm confused

@bojidar-bg
Copy link
Contributor

Note the wording in the OP:

[...] so that only callbacks show up when connecting a signal and making a function track in the animation player.

The idea is to make an editor-only aid, so as to not get flooded by functions such as set_name or is_visible when viewing the methods of a node.

@vnen
Copy link
Member

vnen commented Dec 14, 2018

if you take a look into a call function track interface, even the simplest Node (a bare node) has already 20-30 methods in the list.

Well, they are categorized so the script methods show first. You also might want to call those base functions of the Node, how to choose which ones can be called or not?

I also think that usually you already know the function you want to call so you can just use the search (which is focused by default already).

Besides that, I also fear that is a feature that will confuse users (does the function need to be a callback to be called or it's just an editor hint?) and also just not get known, since most people don't really read the docs.

@QbieShay
Copy link
Contributor Author

@vnen I see your point. I'd say then that the problems outweight the gain, so we can close this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants