You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is purely an ergonomic issue and therefore subjective, and it's also a breaking change. But since you're still at 0.1 this seems like a good time for this kind of feedback :)
Basically, I think shared should be the default because all Objective-C objects can be shared by default because they all have reference counting. When I see an id in Objective-C code, I assume it can be shared until proven otherwise. I would like to be able to use the same mindset with Rust, except that once I as the programmer prove that it is not shared, I can explicitly use an OwnedId and have that invariant enforced by the compiler (at least on the Rust side of things).
Additionally, since the owned vs shared aspect is not enforced in any way on the Objective-C side of things, that means it's far more safe to assume that everything is shared by default (even init methods might retain and share self with some other object, so there is no guarantee that even an object you just created is owned in the Rust sense). So it makes more sense to me to have the shared version be the default, only switching to the owned variant when safe and necessary.
The text was updated successfully, but these errors were encountered:
This is a good thing to mull over! I haven't been working on this crate very actively; it's really only used by the objc-foundation crate (and its users). Not having wider adoption has slowed it down; I never found a design that worked for the cocoa crate, as detailed in SSheldon/rust-objc#24. Instead, each project using cocoa has ended up making its own id, like IdRef in glutin.
This is a usability degradation, but before we know more about actual usage patterns this is the safer option; users will have to explicitly specify the ownership they're expecting.
See SSheldon/rust-objc-id#4
This is purely an ergonomic issue and therefore subjective, and it's also a breaking change. But since you're still at 0.1 this seems like a good time for this kind of feedback :)
Basically, I think shared should be the default because all Objective-C objects can be shared by default because they all have reference counting. When I see an
id
in Objective-C code, I assume it can be shared until proven otherwise. I would like to be able to use the same mindset with Rust, except that once I as the programmer prove that it is not shared, I can explicitly use anOwnedId
and have that invariant enforced by the compiler (at least on the Rust side of things).Additionally, since the owned vs shared aspect is not enforced in any way on the Objective-C side of things, that means it's far more safe to assume that everything is shared by default (even
init
methods might retain and shareself
with some other object, so there is no guarantee that even an object you just created is owned in the Rust sense). So it makes more sense to me to have the shared version be the default, only switching to the owned variant when safe and necessary.The text was updated successfully, but these errors were encountered: