Difference between Type{T} and T when passing type variable inside generated function?

You can’t interact with values in generated functions, but you can with the types of arguments.
So it’s often more convenient to use the arguments directly (as types) than have to type every argument to the function. This is especially true with varargs.

julia> @generated function foo(a, b...)
           @show a b
       end
foo (generic function with 1 method)

julia> foo((1,0xcf,1f0,1.0), "hi", "world", 3.14, :π, π)
a = Tuple{Int64,UInt8,Float32,Float64}
b = (String, String, Float64, Symbol, Irrational{:π})
(String, String, Float64, Symbol, Irrational{:π})
2 Likes