julia> f(_, a) = 10
f (generic function with 1 method)
julia> f(_, a=1) = 10
ERROR: syntax: all-underscore identifier used as rvalue around REPL[0]:1
The second form seems legitimate, no? The same issue arises with keyword arguments (f(_; x=1) = ...
)
It does seem like a good way to indicate that you don't care about an argument, similar to ::Any
but shorter.
Ah, naturally this is due to lowering converting the definition to
f(_) = f(_, 1)
f(_, a) = 10
Could be nice to lower _
as a function argument to @nospecialize(_)
how does the lowering for keyword arguments look like? is it the same reason there?
Most helpful comment
Could be nice to lower
_
as a function argument to@nospecialize(_)