3 ms·
> The function will generally only work on a subset of types for given variable. This is true for many functions defined in statically typed languages too. Jus
by b3n 4y ago
> The function will generally only work on a subset of types for given variable.
This is true for many functions defined in statically typed languages too. Just because your function says it works with an integer, doesn't mean it's necessarily going to work with _any_ integer (think `1/n`). Very often the type used isn't narrow enough.
Modern dynamic languages understand this, see for example Clojure's spec[1].
[1] https://clojure.org/about/spec https://clojure.org/about/spec
- Gigachad 4y agoI like libraries and languages that create a bunch of types which are essentially just renaming existing types. So you'll have a type PostID which is just an int but the language won't let you give a PostID to a function that takes UserID even though its both just integers.