why can i define this function?
julia> f(y,x...)=+(x...).*y
f (generic function with 1 method)
and can’t I define this other one?
julia> f1(x...,y)=+(x...).*y
ERROR: syntax: invalid "..." on non-final
Couldn’t we gnisrap the arguments in reverse order?
I guess there are many possible side effects to avoid but I am not able to imagine.
mbaz
April 8, 2022, 2:14pm
2
DNF
April 8, 2022, 3:05pm
3
This seems to be about slurping, not about optional arguments.
Here’s a PR that addresses this: https://github.com/JuliaLang/julia/pull/42902
Not sure when/if it will land.
But currently, this is not allowed.
3 Likes
Note that the PR doesn’t address method dispatch as the OP asked for. That would require changes to the type system to actually be able to represent signatures like this.
3 Likes