-
Notifications
You must be signed in to change notification settings - Fork 74
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
Story for unowned pointers in collections #99
Comments
Can you provide a situation you're running into where this is causing friction? Truth be told, I've long considered
|
Take There are definitely more APIs of this type that are currently out of reach. |
Ah, I see. So this is where the thought process differs. I always envisioned that cacao would have something akin to: /// pseudocode~
pub struct Workspace(...);
impl Workspace {
pub fn duplicate_urls<U, F>(urls: Vec<U>, completion: F) { }
} Aka the Cocoa-ness would be massaged away with an actual Rust layer. Now with that said, this isn't the first time people have found this annoying, so I don't mind fixing up the types in the I don't have time to do it myself at the moment, but I'm happy to treat this issue as a working issue/collab space for it. |
Actually I agree with you completely. This came up because I started to build out the I will (probably) do the work; I'm just unsure what needs to happen because the specifics of how memory is being managed in this bridge is not apparent to me. EDIT: Oh, and I don't think there's a good pattern for returning |
Hmmm, well let's maybe start with I'm wondering if the current Actually... @madsmtm your work over in objc2 - does it touch on |
There's a lot of work done on this in objc2, see madsmtm/objc2#265 and madsmtm/objc2#419, thanks for pinging me! I'm still working on more "user-level" documentation on this (stashed away somewhere locally), but the gist is to realize that mutability is (almost [1]) always something tied to the class, not to the usage site. So e.g. [1]: Technically you could choose to use a shared mutability approach on e.g. |
Interesting... I do like that approach actually. I think it probably makes sense to go down the rabbit hole of getting the ObjC2 stuff merged and sorted before doing too much else (at this level of things) since it might be rough if we bake in a ton of assumptions now or end up redoing the work you've done elsewhere. |
Agreed. A quick status update on that, I'm slowly getting closer to something where I feel it is stable enough that people can start depending on it. I expect it to be ready at the end of the next month, though that very much depends on the amount of free time I get. |
Both of the collection types (
NSArray
andNSMutableDictionary
) only accept owned pointers to elements. This makes sense, but there are many types that are always shared (NSURL
,NSImage
, etc), which means we cannot store these elements in any collections. This prevents using some APIs and just generally is a bit weird.Why are those types always unowned, and what would need to happen in order to properly add them to a collection without leaking?
The text was updated successfully, but these errors were encountered: