(no title)
Dessesaf | 2 years ago
Would you also consider the following Haskell function to not be strongly typed?
add a b = a + b
This is a polymorphic function that works for any type that has a Num instance (has functions `+`, `-`, `*`, etc.). Just like the python version works for any type that implements __add__().It's just that in Haskell's case, this checking is done at compile-time and in python's case at runtime.
tgv|2 years ago
Or, if you want to look at it in another way: every function, class member and variable is super-hyper-extra-polymorphic, with the types limited by one or two sanity checks at runtime for a handful of operations that happen to apply to them. If my f() would avoid the addition operator sometimes, e.g. like this:
then y can be anything when somepredicate(x) is true, and the type of f might not even be computable. The type of f certainly would never be verified by Python beyond "is it a function of two arguments".It may not be weak, but I'm not sure calling it "strong typing" makes sense.
dunefox|2 years ago