The julia docstring convention for a function f(x,y)
where the second argument is optional, is:
f(x, y=1)
Here 1
is the default value of the argument. This coincides nicely with the method definition. What does one do, however, if x
is the optional argument? The choice
f(x=1, y)
seems odd, as we don’t place non-optional arguments after optional ones. The alternative to this is to use square brackets, and express this as
f([x=1], y)
This is what zeros
does, for example:
zeros([T=Float64,] dims::Tuple)
However, the docstring convention also states that brackets are to be used in cases where the optional argument does not have a default value, but it does have one in this case. I wonder if the convention is to use brackets in this case anyway?