> On Jan 9, 2017, at 1:11 PM, Anton Zhilin <[email protected]> wrote:
>
> I also thought about sum types as implementation of errors, but selecting
> between Tyler’s and John’s syntaxes, I would pick the latter. Compare:
>
> let x: (_ a: Int) -> (Error | (_ b: Float) -> (Error | Double))
>
> let x: (_ a: Int) throws(Error) -> (_ b: Float) throws(Error) -> Double
>
> let x: (_ a: Int) -> (Error | Double)
>
> let x: (_ a: Int) throws(Error) -> Double
> Granted, the version with sum types contains less characters and leads to
> more minimalistic type system. But | on itself does not mean error handling.
> It’s used for creation of sum types, without error handling semantics. So
> it’s easier to grasp the meaning of type containing throws than anything
> else. If Swift had a special symbol as related to errors, as ? relates to
> optionals, then we could use it there. Unfortunately, there isn’t anything
> like that.
>
> What would it look like if the function returns nothing but can throw an
> error?
>
> let x: (_ a: Int) -> (Error | ())
Or even possibly just
let x: (_ a: Int) -> Error
depending on your tastes.
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution