-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestskeyword argumentsf(x; keyword=arguments)f(x; keyword=arguments)
Description
I suggest to enhance the new Base.Fix
to handle fixing keyword arguments.
I think it would be fairly easy, something like this, which implements Fix{:kw}(fun, x)
to work like (y...) -> fun(y...; kw=x)
:
struct Fix{N,F,T} <: Function
f::F
x::T
function Fix{N}(f::F, x) where {N,F}
if N isa Symbol
return new{Val{N}, _stable_typeof(f), _stable_typeof(x)}(f, x)
end
... as before ...
end
end
# and the additional:
function (f::Fix{Val{S},F,T})(args...; kws...) where {S,F,T}
narg = NamedTuple{(S,), Tuple{T}}(f.x)
return f.f(args...; narg..., kws...)
end
Metadata
Metadata
Assignees
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestskeyword argumentsf(x; keyword=arguments)f(x; keyword=arguments)