On Nov 14, 2011, at 1:22 PM, Greg Parker wrote:

> On Nov 12, 2011, at 2:29 AM, Jean-Daniel Dupas wrote:
>> Le 12 nov. 2011 à 03:34, Charles Srstka a écrit :
>>> 
>>> In this day and age, you should probably just use @autoreleasepool instead 
>>> of NSAutoreleasePool:
>>> 
>>> int get_float_data(float *result1, float *result2)
>>> {
>>>     @autoreleasepool {
>>>             [objcCode call];
>>>             *result1 = [more stuff];
>>>             etc.;
>>>     }
>>>     
>>>     return blahblah;
>>> }
>> 
>> 
>> Note that this code is not equivalent with the previous one. 
>> @autoreleasepool does not drain on exception.
> 
> Incorrect. @autoreleasepool does everything that NSAutoreleasePool does on 
> exceptions.

But NSAutoreleasePool doesn't drain on an exception, since it doesn't have an 
explicit scope.  Code posted earlier in this thread used @try-@finally to 
explicitly drain the pool.  So, while @autoreleasepool would be equivalent to a 
naive use of NSAutoreleasePool, it's not equivalent to the earlier code.

Quoting from the Transitioning to ARC Release Notes 
<http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html>:

> On entry, an autorelease pool is pushed. On normal exit (break, return, goto, 
> fall-through, and so on) the autorelease pool is popped. For compatibility 
> with existing code, if exit is due to an exception, the autorelease pool is 
> not popped.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to