Hacker News new | ask | show | jobs
by b3n 1460 days 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

1 comments

I 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.