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

Dave Abrahams dabrahams at apple.com
Fri Mar 25 11:10:46 CDT 2016


on Wed Mar 23 2016, Chris Lattner <swift-evolution at swift.org> wrote:

>> On Mar 21, 2016, at 9:37 AM, Jordan Rose via swift-evolution
>> <swift-evolution at swift.org> 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()
>> }
>> 
>> If we had a rule to default generic return values to Void if they
>> aren't used then I'd be okay with it, but that'd be a separate
>> proposal. (Providing two overloads may also work; haven't tested
>> it.)
>
> I understand that Jordan withdrew his objection later (because no
> overload is required) but it still isn't clear to me that
> autoreleasepool should return a value.
>
> Here’s my thought process: autoreleasepool is *intentionally* looking
> like a statement, not an expression.  

I guess there's no arguing with the intention here, because
autoreleasepool in the library predates me on the project, but it's
worth asking: why is it a good thing for autoreleasepool to be like a
statement and not like an expression?  As far as I can tell that just
makes it less useful and more cumbersome.  It is also an illusion that
breaks down at the edges, so why try to maintain it?

-- 
Dave



More information about the swift-evolution mailing list