In order for the Julia compiler to compile a specialized version of a function for each different type of argument, it needs to infer, as best as possible, the parameter and return types of all functions. If it doesn't do this, the speed of Julia will be hugely compromised. In order to do this effectively, the code must be written in a way that it is type-stable.
Type-stability
Definitions
Type-stability is the idea that the type of the return value of a function is dependent only on the types of its arguments and not the values. When this is true, the compiler can infer the return type of a function by knowing the types of its inputs. This ensures that type inference can continue across chains of function invocations without...