With NamedTuple keyword arguments and constant propagation pull requests both open, it sounds like keyword arguments will soon be type stable and fast. Does this spell the end for optional arguments? Keyword arguments have several advantages:
They can be used in any order (duh)
You can add new keywords easily with no breakage
Keywords help with readability
Disadvantages:
Slightly less verbose (tradeoff with readability)
Don’t participate in dispatch (but can be wrappers for functions which do)
I am not sure why you think this. Many languages have both just fine.
One, or at most two, optional arguments are kind of a sweet spot in most contexts when there is nothing else to parametrize. For 2+, it is usually better style to use keywords. There is place for both.
No. max(2,4,6,8) (max(x...)) is objectively simpler, more readable, and more extendable than max(x1=2,x2=4,x3=6,x4=8) (@generated function max(;kwargs...)), and it’s easier to implement.
In the packages I develop I also use optional arguments as fundamental parameters for an algorithm that are crucial for it. I use keyword more like things that fine-tune the algorithm.
For example, an initial condition would be optional argument since it can be automatically generated randomly but the outcome depends crucially on it. On the other hand, some kind of tolerance level is a keyword argument.
I like it very much this way, and it allows me to keep this behaviour choice consistent across functions. So I am happy that I can use both arguments and keyword arguments.
Why would you want your user to have to constantly use rstrip(s, chars=mplah_mplah) instead of just rstrip(s, mplah mplah)…? I would definitely not want this for functions that have less than 5 arguments
I guess I’m in general a fan of readable code. I think that rstrip(s, chars=mplah_mplah) is much more readable in case you forget what second argument is supposed to be (number of characters to split? A regex expression?). It is also much more flexible in terms of being able to go back and add other keyword arguments in any order without breaking code (I think?)