|
|
|
|
|
by zozbot234
2323 days ago
|
|
There's actually a fairly natural way of representing Result-like types (including exceptions) in a flow chart. Draw multiple "exit" terminals for the function, one for "success" and one for each error case. Then a function invocation can have multiple flowlines leading from it, one for each case. And one can "rethrow" the exception quite naturally, by having a flowline for a "rethrown" exception lead to an exit terminal of its own. This also applies by analogy to the case of multiple entry terminals, which come up most naturally when desugaring async functions. (It's actually even simpler than that when accounting for the functor and monad properties of Result<T, Err>, but the graphical representation for a "functor" or "monad" is a bit more complex; these would be drawn as labeled regions, and functor and monad properties would describe how such regions can be "merged" or "combined".) |
|