[swift-evolution] [Review] SE-0102: Remove @noreturn attribute and introduce an empty NoReturn type

David Waite david at alkaline-solutions.com
Wed Jun 22 12:23:18 CDT 2016


> 	https://github.com/apple/swift-evolution/blob/master/proposals/0102-noreturn-bottom-type.md
> 
> 	* What is your evaluation of the proposal?

In terms of raw syntax, I like the idea of using an uninhabited types to indicate non-returning behavior.

I haven’t used a language with a ‘bottom’ type functionality, so I can’t evaluate that as an alternative.

I actually like the name ‘Never’ more than ‘NoReturn’, but thats mostly bike shedding. The one non-bikeshedding bit backing up the use of Never over NoReturn is that there is nothing in the language which prevents use of NoReturn in other contexts,e.g.:

func foo(_ n:NoReturn) {}  // Compiles but is not callable
var a:Optional<NoReturn> = nil // works, but can never be .Some(x)

The one catch I see here is that even documentation tools will need to understand uninhabited types in order to represent behavior to a developer, but I believe there is already a strong push away from tools built on technologies which wouldn’t have access to that information (such as using regular expressions)

> 	* Is the problem being addressed significant enough to warrant a change to Swift?

I think so - it eliminates what would need to be special rules around function declaration with @noescape, plus may allow for future subtype behaviors.

> 	* Does this proposal fit well with the feel and direction of Swift?

I think so

> 	* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

I haven’t used languages with bottom types before or with non-returning behavior indicated by use of certain types - I’ve only languages that annotate non-returning functions at the compiler level. However, it seems like a good way of eliminating redundant or possibly conflicting behavior as well as special rules, such as declaration of a @noreturn fatal(_ message:String)->Int, and covariance of using such a non-returning function as an argument

> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

Quick reading of proposal, intermittent tracking of the discussion beforehand.

-DW
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160622/3edbefc7/attachment.sig>


More information about the swift-evolution mailing list