Nothing == absence of keyword argument?

If you know the set of possible keyword argument names accepted by libraryfunc, you can filter them out of the keyword arguments passed to func:

function func(; kwargs...)
    ... do something ...
    libraryfunc_kwargs = (`atA`, `atB`, `atC`)
    validkwargs = filter(kwargs) do (key, _)
        key in libraryfunc_kwargs
    end
    libraryfunc(; validkwargs...)
end

There you don’t need to know the default values, but still have to define the list of keys accepted by libraryfunc, in the variable libraryfunc_kwargs. Instead of writing them manually as in the example above, you can get them with Base.kwarg_decl, although if libraryfunc has several methods, you need to choose the one that you mean to call (easier if your function is type-stable).

This would become a bit more complicated if libraryfunc accepts variable keyword arguments (kwargs...). But in that case, probably you don’t even have to filter the ones passed to func.

1 Like