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

context.addInitializer for class fields #473

Closed
trusktr opened this issue Jun 21, 2022 · 2 comments
Closed

context.addInitializer for class fields #473

trusktr opened this issue Jun 21, 2022 · 2 comments

Comments

@trusktr
Copy link
Contributor

trusktr commented Jun 21, 2022

#469 was closed, but there was no explainable resolution.

No one there was able to explain exactly why a returned function is better than a function passed to context.addInitializer, and why only field decorators should return a function while other decorators use context.addInitializer.

A claim was made in that thread that adding an initializer with context.addInitializer leads to less performance than if we return an initializer, however no explanation as to why has been given.

On the other hand, the other issue does describe how context.addInitializer for fields would not lead to classes with slower initializers (because why would the mere act of returning a function vs passing a function affect how that function's performance later on?), and that the development experience would be more consistent with other decorators.

@trusktr
Copy link
Contributor Author

trusktr commented Jun 21, 2022

If there's anything I learned from previous decorator implementations, it is that API inconsistency makes development difficult, requires a bunch of conditional checking, returning or not, etc. Consistency makes code easier to organize and understand.

@pzuraq
Copy link
Collaborator

pzuraq commented Jun 21, 2022

This was answered in the other thread multiple times. As it stands, the proposal has moved to stage 3 and has been advancing steadily. There are no blockers on the committee over this issue, so API design consistency is not an issue.

I don’t want to restate the reasoning, you can see it here: #469 (comment)

@pzuraq pzuraq closed this as completed Jun 21, 2022
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

No branches or pull requests

2 participants