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

Macro method modification policy #467

Merged
merged 5 commits into from
Jan 21, 2025
Merged

Macro method modification policy #467

merged 5 commits into from
Jan 21, 2025

Conversation

dhardy
Copy link
Collaborator

@dhardy dhardy commented Jan 20, 2025

Add a policy on code modification by the #[widget] macro on Widget methods. This code modification was already used (call order verification) but was unobservable outside of reported error cases.

Make use of this policy to call draw.set_id in fn Layout::draw, thus making DrawCx::recurse redundant.


While allowing macros to modify methods may seem an evil, it is deemed the lesser evil compared to alternatives:

  • Requiring repetition of boiler-plate code by users in all implementations. (Note that while the DrawCx::recurse pattern avoided the need to call draw.set_id(self.id()), that pattern is incompatible with a planned future change.)
  • Usage of separate "impl-target" and "call-target" methods. This was functional with probe / try_probe but not a great solution, especially when it needs to apply to more than one "method".
  • Usage of separate traits for impl- and call-target methods (inevitably this causes name conflicts if the methods share names).
  • Usage of a wrapper "pod" as in Druid. This does not pair well with Kas's user-defined widgets.

@dhardy dhardy merged commit d004933 into master Jan 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant