[swift-evolution] rethrows as first-class type annotation

Dmitri Gribenko gribozavr at gmail.com
Sun Dec 20 04:37:36 CST 2015


Hi Alexandre,

I think for this use case we don't actually need 'rethrows' to become
a part of the closure type, we just need the compiler to allow and
"instantiate" it in more places.

The case where we would need 'rethrows' to become a first class part
of the type system is if we wanted 'rethrows' to be a part of the
signature of the closure itself, for example:

(swift) let forEach = [ 10, 20, 30 ].forEach
// forEach : (@noescape (Int) throws -> Void) throws -> () = (Function)

Here, a more precise type would be (@noescape (Int) throws -> Void)
rethrows -> Void.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list