Untyped arguments
When function arguments are not annotated with type information, the function is actually more flexible. Why? That's because it can work with any type that you pass into the function. Let's say that, in the future, the coordinate system is changed from Int to Float64. When this happens, the function will not need to be changed: it just works!
In contrast, keeping everything untyped may not be the best idea either because the function cannot really work with every possible data type that is defined in the world. In addition, it could often lead to obscure exception messages and make the program more difficult to debug. For instance, if we were to pass an Int value as the Widget argument to the move_up! function by mistake, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access