4 ms·
> I don't have to think about abstractions as types I only need to think how to solve the problem in front of me. There's a function in a popular Python scient
by adwn 6y ago
> I don't have to think about abstractions as types I only need to think how to solve the problem in front of me.
There's a function in a popular Python scientific library (I can't recall the name of the library or the function, unfortunately), which takes a parameter n and returns a float if n=1, and a list of floats if n!=1. This behavior wasn't documented explicitly – I found out during testing – and is just annoying to deal with when the parameter n isn't a constant.
This wouldn't happen in a statically typed language, because 1) the function's signature would hint at this unexpected behavior, and 2) the designer of that function has to think about the assumptions they make and the guarantees they give, and not just "how to solve the problem in front" of them.