3 ms·
I was specifically responding to "calling a 4 parameter function with 3 parameters". In the case you have a 3 parameter function, and pass in the wrong type, st
by lostcolony 6y ago
I was specifically responding to "calling a 4 parameter function with 3 parameters". In the case you have a 3 parameter function, and pass in the wrong type, static typing -may- help you...but most languages that allow that that are statically typed allow for function overloading (since functions are then defined not by name and # of args, but name and types of args). If you overload the 3 param variant, static typing can't help ensure you pick the right one, just one that exists. That was my point; you still have to write proper tests, and that not only has the benefit of ensuring you're calling the right function, but that it also does what you want.
Re: testing - regardless of whether you have static typing or not, you should be exhaustively testing every pattern you match on, to ensure you're doing the right thing. If you don't, you don't care about the behavior in those cases - in most languages that's a problem, in Erlang it's a "if that happens, supervisor restarts", and you focus your effort on ensuring restarts put you back into a good state (which you do anyway, ergo, no additional work unless you choose to invest it).
Erlang is a little unique in this regard; it's not that it doesn't have error handling and that static typing might not be a benefit, it's that proper focus should be on the supervisor strategy and "what happens when things go wrong". Of course things that reduce how often things go wrong are helpful (for log consumability if nothing else), but they don't buy you that much if you're doing things correctly; the whole 'correctness' mechanism is separate and distinct from those concerns (whereas most other languages it is not).