Strict typing and restricting types in a method's signature

I disagree. It’s not just for throwing errors, but like types in general it serve as useful, compiler checked documentation.

I don’t want to reopen the age old static vs dynamic typing debate. I’m a proponent of the former, and while Julia is dynamically typed, it allows me to write code in a mostly statically typed style. Many Julia programmers, like Lispers, seem to think of types only as useful for optimization, but I’d put types in many places even if it made the code a bit slower. IME your unintended uses for loose typing end up being unintended consequences.

I prefer to strictly type function arguments and return types. Not a categorical rule, but a general preference. I may leave local variables untyped if their type appears obvious. YMMV, and it obviously does.

2 Likes