-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invoke
does not accept keyword arguments
#7045
Comments
Closing as a dup of #2758. |
I don't see how this is a dup; this issue is specifically about |
Having # Pack keyword arguments, logic copied from jl_g_kwcall
function pack_kwargs(;kws...)
kwlen = length(kws)
ary = Array(Any, 2 * kwlen)
for i in 1:kwlen
ary[2 * i - 1] = kws[i][1]
ary[2 * i] = kws[i][2]
end
return ary
end
function get_kwsorter(f::Function)
if !isdefined(f.env, :kwsorter)
error("function $(f.env.name) does not accept keyword arguments")
end
return f.env.kwsorter
end
## Custom implementation of `invoke`
# Supports keyword arguments
function my_invoke(f::Function, types::Tuple, args...; kws...)
# FIXME, replace with the builtin invoke after it supports keyword arguments
if isempty(kws)
return invoke(f, types, args...)
else
return invoke(get_kwsorter(f), tuple(Array, types...),
pack_kwargs(;kws...), args...)
end
end I'm not sure if this is the fastest way to do it or if it is compiler friendly though.................... |
Could potentially be backported to 0.5 even. |
backporting features is iffy |
Sure, but there's no way this feature can break anyone's code. |
Actually it could, but in an indirect way. If say it were backported into 0.5.3 or similar, then code written in 0.5.3 or later that started making use of it wouldn't work for anyone who's happily using 0.5.1 and doesn't upgrade. It's fine if people test against a range of point releases and are careful about their minimum Julia version requirements, but not many people are. |
That's a fair point. |
FWIW, if we add kw support using |
The end goal here seems to be adding keyword support directly to |
The way functions work now it's possible to add a keyword sorter method to |
Should we just have it be |
This makes it impossible to pass keyword arguments to other calls:
gives
The text was updated successfully, but these errors were encountered: