-
Notifications
You must be signed in to change notification settings - Fork 234
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
Add destructors to Kotlin and Swift #8
Comments
Our hand-written Kotlin bindings don't have destructors either, and I'm told that's on purpose because they're generally considered bad form in Java (for good reasons that I don't think apply in our case). I believe there's some elaborate infrastructure around the Which isn't to say that we shouldn't do it, just to brain-dump some thoughts on how. |
Ooooh, I think the Kotlin equivalent would be the |
Yeah, I agree. That's what all our existing code does. I think if the a-c team wants to do the cleaner infra. They should probably own that (or at least let us know), AFAIK the autocloseable version has been working fine for them. |
In Java 8/Kotlin/Android, the The evil way is the But Glean's experience would show that this is a source of crashes (via Sentry), and they went and removed it. This bit from @badboy scared me most:
So much for the magical ways on Android. For the non-magical ways, the explicit cleanup method. So now we come to the second hardest problem: naming; specifically— name collisions. Android-components is using |
Yeah, at first I was thinking we would implement You're totally right, though! Aesthetically, I don't think WebIDL has a concept like this, either— Using a name like |
I'm not aware of any concrete uses of this in practice (but then again, there are many things of which I'm not aware). It may be modestly useful for test code that creates and destroys a bunch of instances.
FWIW, I feel like at this stage we should be pretty strongly opinionated about the shape of the generated code, and just declare a name for the destructor rather than trying to let consumers configurate-all-the-things. Naming it |
The Python bindings already define
__del__
destructors for classes, but Kotlin and Swift don’t yet. We’ll want to make sure we wire these up and call them correctly, to avoid leaks and double-frees.┆Issue is synchronized with this Jira Task
The text was updated successfully, but these errors were encountered: