> I only wonder whether you really want to repeat Error() all over, > possibly with `aString` etc. as argument.
What I really want is the postfix version of `???` as I wrote in my first post in this thread. > Besides the proposed infix `???`, I also want the postfix one which > throws a `NilError` (something like `struct NilError: ErrorType {}`). > It is useful to handle multiple `nil`s at once when we are not > interested in the kind of the error. And also > I think `???` is too long. Instead, I propose `|?`. > For `foo: Foo?`, `try foo|?` can be read like `Foo` or `nil`. It > separates (`|`) nil (`?`) from the value and return `Foo`. > I think it makes sense. Then it becomes something like the following. ``` do { let foo: Foo = try foo( a: Int(aString)|?, b: Int(bString)|?, c: Int(cString)|? ) } catch _ { // Error handling } ``` I think the infix version is also useful when we actually want to specify the types of errors. Swift provides two ways of error handling: optionals and do/try/catch. I think it lacks a way to handle multiple optionals easily in some cases. Someone uses applicative styles for it. ``` let foo: Foo? = curry(Foo.init) <^> Int(aString) <*> Int(bString) <*> Int(cString) ``` But I think it is unreasonable to expect all programmers to understand and master it. So I want the postfix `???` or `|?`. -- Yuta 2016-04-08 23:47 GMT+09:00 Thorsten Seitz <tseit...@icloud.com>: > > Am 08.04.2016 um 11:59 schrieb Brent Royal-Gordon <br...@architechies.com>: > >>> I only wonder whether you really want to repeat Error() all over, possibly >>> with `aString` etc. as argument. >> >> `Error()`, no. `SpimsterKitError.invalidWicketField("a"`), yes, because even >> if `Int.init(_:)` threw *an* error, it wouldn't throw *your* error. > > That's why I thought that in a real use case that logic would likely be > extracted. > > -Thorsten _______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution