Re: Thoughts on ARC
Re: Thoughts on ARC
- Subject: Re: Thoughts on ARC
- From: Allan Odgaard via Cocoa-dev <email@hidden>
- Date: Fri, 27 Sep 2019 14:50:18 +0200
On 27 Sep 2019, at 14:19, Turtle Creek Software via Cocoa-dev wrote:
It makes sense that Cocoa programmers much prefer ARC to MRC. Doing it
manually is easy to break and hard to debug. However, the fact that
ARC is
not exception-safe concerns me.
Cocoa in general is not exception safe as the policy is to only use
exceptions for programmer errors such as accessing an array with an
invalid index, therefore any exception thrown in production is likely to
cause problems, leaking an object, which is the effect of ARC’s lack
of exception safety, is not going to make much of a difference.
You can however make ARC exception safe by passing
`-fobjc-arc-exceptions` to clang (default for Objective-C++ code).
It suggests that Cocoa still manages ref counts manually, somewhere
under the hood.
The compiler will insert retain/release calls where necessary, so yes,
retain counts are still used, as with your smart pointers in C++, it’s
effectively just compiler generated constructor/destructor code to
perform the retain/release (with a few optimizations).
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
References: | |
| >Thoughts on ARC (From: Turtle Creek Software via Cocoa-dev <email@hidden>) |