I'm new to Julia and much more experienced in R, so for those who are familiar with both, here is a snippet of R code that I'm trying to replicate in Julia.
f = function(a, b = 1, c = 2) a + 2*b = 3*c
g = function(d, ...) 5 + f(d, ...)
With this it would be valid to call g(1), which would evaluate with the default values for f, or you could specify g(1, b = 3) or g(1, c = 4, b = 2), or whatever. The point is of course that you can pass any permutation of optional arguments to f without order mattering as long as the names are specified.
In Julia I've had a bit of trouble doing this because the varargs stuff works a bit differently. I'm aware that you can pass an unlimited list of arguments to a function in the form of a tuple (e.g., function g(d::Number, f_args::NamedTuple), but it seems like it doesn't work with optional keyword arguments. It's almost as if somewhere along the line the f_args tuple loses its names, and f gets confused because it sees 3 arguments without names and doesn't know which method to select?
If it is indeed possible, I'd really appreciate if someone could show me how to do this in Julia. I would like to preserve the optionality of these arguments, as well as their names. I'd also like to be able to keep their types (i.e., I'd like each argument of f to only be acceptable if they fit under the correct type, which is of course usually done in Julia with the :: operator in the header).
PS - for the purposes of my question, rewriting g so it has c and b as optional arguments will not suffice for me. I display the example of f and g for simplicity but in reality am hoping to apply these principles to much more complex functions with many arguments.