[swift-evolution] Update the signature of ObjectiveC.autoreleasepool [SR-842]

Jordan Rose jordan_rose at apple.com
Mon Mar 21 13:46:43 CDT 2016


> On Mar 21, 2016, at 11:43, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> 
> On Mon, Mar 21, 2016 at 9:37 AM, Jordan Rose <jordan_rose at apple.com> wrote:
>> -1 for the signature change. The most common case of autoreleasepool does
>> not return a value and has a multi-statement body that prevents the result
>> type from being inferred. This needs to continue to work:
>> 
>> autoreleasepool {
>>  foo()
>>  bar()
>> }
> 
> It seems to work for me:
> 
> func poolPush() {}
> func poolPop() {}
> 
> public func autoreleasepool<Result>(@noescape code: () throws ->
> Result) rethrows -> Result {
>  poolPush()
>  defer { poolPop() }
>  return try code()
> }
> 
> func foo() {}
> func bar() {}
> 
> autoreleasepool {
>  foo()
>  bar()
> }

Um. Thank you for actually testing it! Objection withdrawn; changed to a +1. :-) Thanks, Dmitri, Tim. No overload needed.

Jordan


More information about the swift-evolution mailing list