on Sat Apr 23 2016, Антон Жилин <[email protected]> wrote:
> SE-0066 disallows Void to be used on left side of function types.
>
> Some people, including me, argue that Void should be removed altogether,
> because:
> 1) () is more consistent with curried functions: (Int) -> () -> Double
> 2) () follows functional programming traditions
>
> Now, why don't we repurpose Void to follow functional programming traditions
> as
> well?
> Its definition will look like:
> enum Void { }
>
> Basically, Void is a type which cannot have values.
> With it, we can eliminate at least two Swift special cases:
>
> 1. Noreturn functions
>
> func exit(code: Int = 0) -> Void
>
> From this signature, it's obvious that `exit` cannot return normally
>
> 2. Rethrows
>
> func call<T, U>(block: () throws T -> U) throws T -> U
>
> Non-throwing functions are functions throwing Void.
> So if T=Void, we get the non-throwing version of `call`.
Repurposing the name "Void" in this way would move Swift definitively
away from being a C-family language. If we were to do that, we should
do it very consciously and with full awareness of the larger
implications. I.e. this isn't just about one name.
--
Dave
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution