I ended up using this
function splitkwargs(kwargs, args...)
for f in args
isa(f, Array{Symbol}) ? nothing : throw(ArgumentError("args are not arrays of symbols"))
end
wrongKeywordArguments = setdiff(keys(kwargs), union(args...))
if length(wrongKeywordArguments) != 0
throw(UndefKeywordError(wrongKeywordArguments[1]))
end
out = []
for kwarg in args
push!(out, (;[(key, kwargs[key]) for key in intersect(keys(kwargs), kwarg)]...))
end
return length(out) == 1 ? out[1] : out
end
which could be used here like so:
function useAB(: kwargs...)
#notmyfun has kwargs {calc, norm}
funAkwargs, funBkwargs, notmyfunkwargs = splitkwargs(kwargs, [:a], [:b], [:calc, :norm])
return funA(;funAkwargs...) + funB(;funBkwargs...) + notmyfun(;notmyfunkwargs...)
I’m not sure if there will be some problems with this approach, but oh well…