Typed throw functions

I strongly second what @anandabits said about throws Never. In general in Swift every function or any accessor does return something. In many cases this is done implicitly for you, as many things return Void even the compiler reserved = operator, but they still return. In that sense every function and every accessor should throw an error, but we can again reduce this so a simple model that provides the implicit functionality we need.

Right now we would like to extend the functionality to functions and closures, but later on we also want accessors to throw.

The basic idea is very simple and easy to teach:

(X, Y, Z) -> W          === (X, Y, Z) throws Never -> W

(X, Y, Z) throws -> W   === (X, Y, Z) throws Error -> W

// T: Swift.Error omitted 
(X, Y, Z) throws T -> W === (X, Y, Z) throws T -> W
3 Likes