|
|
|
|
|
by gf000
216 days ago
|
|
Well, this obviously depends on a given programming language/culture, but in my mind I would say in case of parsing a string to an int it is an expected case that it could fail, so I would model it as a Return type of an Int or a ParsingError, or something like that. Meanwhile, for a function doing numerous file copies and network calls I would throw an exception, as the number of possible failure cases are almost limitless. (Like you surely not want to have an ADT that models FileSystemFullErrors and whatnot). It so happens that in this particular example one is pure and the other is side-effecting, but I'm not convinced that's a hard rule here. |
|