How (is it possible) to annotate the type of arguments when using the splat operator?
f(x, y) = x^2 + y^2
vec = [1.0, 2.0, 'a']
f(vec[1:2]...)
How can I annotate that use of ...
in the function call. Also notice that none of the macros to view code (@code_llvm
, @code_lowered
, @code_native
, @code_typed
, @code_warntype
) work, so it would be very hard to optimize when using the splat?
Because it seems that in the above use-case, macro versions of reflection functions couldn't reach the right argument types, using original function instead of macro, could be helpful:
f(x, y) = x^2 + y^2
vec = [1.0, 2.0, 'a']
@code_warntype(f(vec[1:2]...)) # => Nothing
code_warntype(f,map(typeof,vec[1:2]))
# Variables:
# x::Float64
# y::Float64
# .....
This logic is true for all reflection macros, using their variant function with a (function, collection of types)
.
references: