-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Omit the &self parameter for functions on engine singletons #127
Comments
The problem with this is that you can no longer access the actual singleton object. A few drawbacks:
I don't think either of those points is a roadblock, but it's important to be aware that the proposal, while syntactically nicer, has quite some implications. We can probably still try it. We might even want to start without providing an object at all. |
Or perhaps we can even have both? |
Thanks for the detailed reply. It's good to be aware... but yeah, I don't think any of these are blockers:
|
Thanks as well!
I think what we could do is impl Input {
pub fn singleton_object() -> Gd<Object>;
} to still give access to the underlying instance as Object (it could be Another topic we need to clarify, is thread safety. The latest threading guidelines specify:
Which sounds quite promising! So is every possible method synchronized, and we don't need to worry about anything, ever? 🤩 Because if not, it's going to be painful to model in safe Rust... |
Yeah, I'd rather not duplicate APIs for syntactical reasons. But the const-ness is anyway not that helpful, as people can always just get a new |
Another thing, there are cases where Godot might return singleton objects (even if it's legacy/compat code), and we must be able to represent them somehow. godotengine/godot#75694 (comment) TLDR: GDExtension changes the There are two problems with this proposal in particular:
|
We could still allow |
Instead of
Input::singleton().is_key_pressed()
you should just be able to writeInput::is_key_pressed()
. It's shorter, closer to GDScript, more Rusty, and avoids the overloaded word "singleton" which can also refer to an autoload.The text was updated successfully, but these errors were encountered: