Skip to content

Implement owner argument inference #633

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

Closed
wants to merge 1 commit into from
Closed

Implement owner argument inference #633

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Nov 8, 2020

This allows the use of _ as types of arguments named owner or _owner within #[methods] blocks. Such placeholders will be automatically replaced with TRef<'_, Self::Base, Shared> for convenience.

This should make typing function signatures less tedious, and give new users a sufficiently sane default owner argument type that just works in common use cases: calling methods and passing as arguments. This should also help with the rather frequent confusion new users face when they try to write something that don't extend Node.

The downside is that it makes more things implicit, although it can be argued that owner in godot-rust is close enough to self to make this acceptable. Documentation is added to the #[methods] attribute macro to explain the exact behavior for advanced users.

Draft status: The change itself is simple enough and not really expected to impact #609 a lot, but some opinions on whether this is a good feature would be really helpful.

This allows the use of `_` as types of arguments named `owner` or `_owner`
within `#[methods]` blocks. Such placeholders will be automatically replaced
with `TRef<'_, Self::Base, Shared>` for convenience.

This should make typing function signatures less tedious, and give new users
a sufficiently sane default owner argument type that just works in common use
cases: calling methods and passing as arguments. This should also help with
the rather frequent confusion new users face when they try to write something
that don't extend `Node`.

The downside is that it makes more things implicit, although it can be argued
that `owner` in godot-rust is close enough to `self` to make this acceptable.
Documentation is added to the `#[methods]` attribute macro to explain the
exact behavior for advanced users.
@ghost ghost added feature Adds functionality to the library c: export Component: export (mod export, derive) labels Nov 8, 2020
@ghost
Copy link
Author

ghost commented Nov 13, 2020

Closing after gathering feedback. The consensus is that this is too much "magic", and it breaks IDEs too much, which is undesirable.

@ghost ghost closed this Nov 13, 2020
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: export Component: export (mod export, derive) feature Adds functionality to the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants