Style rules for type annotation?

Yeah, but then errors are caught later, if at all. I use f(x) = x^2 in generic open source library code, and f(x::Number) = x^2 in my end-user private code when I don’t expect to use a matrix. I can always change it later, and it’s better documentation.

Along those lines, I also started using Any type aliases for documentation. Eg.

const Functor = Any
run_with_context(f::Functor, ctx, ...) = ...

It makes the code clearer, until Julia starts supporting interfaces/contracts/etc.

2 Likes