[swift-evolution] Idea: change "@noreturn func f()" to "func f() noreturn"
Radosław Pietruszewski
radexpl at gmail.com
Thu Feb 25 17:09:53 CST 2016
I stand corrected! In this case, I change my position.
`func x() noreturn { … }` isn’t that bad on a second look.
— Radek
> On 26 Feb 2016, at 00:04, Jordan Rose <jordan_rose at apple.com> wrote:
>
> "noreturn" is a part of a type signature; a @noreturn method cannot be overridden by a method that isn't @noreturn*, and you could have a closure that's guaranteed to not return.
>
> * This isn't true in Objective-C, but it is in Swift.
>
> Jordan
>
>> On Feb 25, 2016, at 14:38, Radosław Pietruszewski via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>> The difference though is that throws/rethrows is a part of type signature, @noreturn isn’t and has no reason to be AFAICT. It’s just an attribute of the method…
>>
>> — Radek
>>
>>> On 25 Feb 2016, at 22:44, Jacob Bandes-Storch via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>
>>> Premise: there are multiple ways of describing control-/data-flow when a function is called:
>>>
>>> func x() -> T // x returns a value, of type T, to the caller
>>> func x() throws // x may throw an error to the caller
>>> func x() throws -> T // x may throw an error, and also return a value
>>> func x(...) rethrows ... // if a closure argument can throw an error, x may also throw
>>> @noreturn func x() // x never returns to the caller
>>>
>>> "noreturn" is currently spelled as an attribute, but like "throws" / "rethrows" / "-> T", it's really describing how control flow works.
>>>
>>> IMO this calls for consistency: whatever happens "after" the function is called should appear "after" the parameter list.
>>>
>>> func x() noreturn {
>>> ...
>>> }
>>>
>>>
>>> Thoughts?
>>>
>>> Jacob
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160226/8615e540/attachment.html>
More information about the swift-evolution
mailing list