> On Feb 6, 2015, at 2:00 PM, Greg Parker <[email protected]> wrote: > > Swift adds "unowned" references. These references are non-retaining. They > differ from weak references and unsafe unretained references: unowned > references fail with a runtime error if you try to access the pointed-to > object after it has been deallocated. … > They are cheaper than weak references and safer than unsafe-unretained.
What makes them cheaper than weak references? It sounds like they both have to do the same bookkeeping to track whether the pointed-to object is alive; the only difference is the behavior when accessing the reference after the pointed-to object is dealloced (i.e. treating the pointer as nil vs. failing with an error.) Both of those seem equivalent in complexity. But maybe I'm off-base on how weak references are implemented… I'd love to see an explanation, actually. —Jens _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
