Avatar
+1 to an unconstrained, two-argument Result type. Referring back to @John_McCall's original error handling rationale, I think throws and Result can be seen as addressing different corners of the design space. As the rationale describes, throws was designed for systemic errors, which tend to have a large distance between error source and error handler, so source and handler end up needing to be rather loosely coupled, which was a motivator for the exception-like propagation and lack of specific typing in the current throws feature. Result on the other hand is great for conditions that are intended to be immediately handled by the caller, for which being an regular return value with a more specific failure type is in fact the more convenient representation. While we should definitely have helper operations to map back and forth between throws and Result when the failure type of Result conforms to Error, I think Result would be maximally useful if it doesn't need to be used as an integrated facet of the throws-based error handling mechanism. https://forums.swift.org/t/adding-result-ii-unconstrained-boogaloo/17128/18
+1 to an unconstrained, two-argument Result type. Referring back to @John_McCall's original error handling rationale, I think throws and Result can be seen as addressing different corners of the design space. As the rationale describes, throws was designed for systemic errors...
4:48 PM
↓のような理解でいいのかな? throwsResult は異なる問題を取り扱ってて、 throw されたエラーは伝播して問題の発生源から遠く離れたところでハンドリングされるから typed じゃなくてゆるく Error として扱えば良くて、 Result は( Optional のように)即時ハンドリングされることが意図されてるから明確な型を指定できるのが適する。 throwsResult を相互変換できる機能は提供すべきだけど、 throws とは別の局面で使われてこそ Result は真価を発揮すると思う。 (edited)
😀 1