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

darwinkit: generate New variants based on init methods #186

Closed
Tracked by #177
progrium opened this issue Aug 19, 2023 · 0 comments
Closed
Tracked by #177

darwinkit: generate New variants based on init methods #186

progrium opened this issue Aug 19, 2023 · 0 comments
Assignees
Labels
generation Related to generation toolchain
Milestone

Comments

@progrium
Copy link
Owner

Currently we do something like this, for every init prefixed instance method, we make a class helper function that does the alloc and then calls the init method, as if it were a type method. Example: String_InitWithString.

There are two problems with this. First, there are occasionally conflicts with actual type methods with the same name. Second, based the memory management policy, the allocator should be responsible for releasing. So these methods should autorelease just like our New functions (NewString).

We can solve this by adding autorelease, but also naming them as New variants. This will make everything more consistent and somewhat less verbose. Instead of String_InitWithString we'd have NewStringWithString. That particular example is redundant, but usually it won't be. The rule would be take the method name after init and add it to the New method.

@progrium progrium added the generation Related to generation toolchain label Aug 19, 2023
@progrium progrium added this to the 0.5.0 milestone Aug 19, 2023
@progrium progrium self-assigned this Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generation Related to generation toolchain
Projects
None yet
Development

No branches or pull requests

1 participant