|
|
|
|
|
by shawnz
1886 days ago
|
|
Trying to minimize edge cases can also increase complexity. As a specific example look at the behaviour highlighted in this talk where he shows the result of adding two nonsensical types. In most cases there is probably no sensible result except TypeError, but... - Throwing a TypeError in those situations would itself require that particular edge cases are specifically defined in the spec to return TypeError, therefore actually making the spec more complex and creating more error situations for code to deal with. - Some might get a benefit from the "implicit" behaviour even if it usually makes no sense at first glance (only in context with the other rules). Whereas TypeError is never useful in the happy path. An important idea in dynamic languages is to let the caller decide if a particular usage of a type makes sense, rather than the callee. |
|