On Tuesday, December 31, 2013 11:12:44 AM UTC-5, Daniel Carrera wrote: > > (18)+(19): I disagree. Although I could favour rules like this in a > particular project, in many cases I think that adding type annotations just > creates syntactic noise and can create a needless limitation >
I also strongly disagree with the "Always explicitly type all arguments to a function" rule. Adding an explicit type imposes a severe cost in generality in many cases, since it prevents duck typing. (And duck typing is extremely important in Julia because of the lack of multiple inheritance.) For example, the whole "iterator" pattern in Julia relies on *not* declaring types. This also came up in the IterativeSolvers.jl package, where explicitly declaring arguments as AbstractArrays prevented one from using other linear-operator objects (supporting "op * vector") that lack array-like random access semantics. As I've argued elsewhere (https://groups.google.com/d/msg/julia-users/WOsN9zTOQbg/RgJMnWdx0IoJ), the main reasons to declare an explicit type in Julia are either to disambiguate method dispatch or to prevent unexpected results (*not*MethodError exceptions). In any given case, you should have a clear reason for why you are declaring a type rather than leaving an argument untyped (and you should especially have a reason for using a concrete rather than an abstract type).
