
On 19/04/2020 17:06, Alex Hall wrote:
function(*, dunder, invert, private, meta, ignorecase)
No reader will ever have to think about the difference. They will simply see the second version and know which arguments are being passed.
I seem to be immune to this magical knowledge.
Sorry, what? How is there any doubt that the arguments being passed are dunder, invert, private, meta, and ignorecase? They're right there.
Oh, so that's what you meant. But how is this different from function(dunder, invert, private, meta, ignorecase) if you trust yourself to get the argument order right, or function(dunder=dunder, invert=invert, private=private, meta=meta, ignorecase=ignorecase) if you don't? I still don't get why you think that last form is a problem.
Now, which parameters those arguments are bound to is less obvious, but:
1. When you read the function call, you're thinking about the arguments, not the parameters. You can see which information goes into the function, and the first question you should ask yourself is 'is that the right information?'.
Bitter experience has taught me to think about both the arguments and the parameters. You can't answer the question "is that the right information?" until you know what the right information is.
2. Even if you have no idea what the parameters of the function are, you can already reasonably guess that they match the argument names, and that guess is correct! If you have some idea what the parameter names are, you can be more confident in that guess. Or, if you didn't know the parameter names, but you know what the `**` separator means, now you know the names.
All I can say is that I doubt I would make that association. I certainly don't when similar things come up in function definitions.
3. You probably only start to think about parameter binding when you open up the function definition, and when you do that, binding is still probably not the first thing you look at. You're probably thinking about what the function does in the body.
Well, no, that's not how I work at all.
4. If there are just a few arguments, you're less likely to miss or ignore the `**`.
True. But on the other hand, you have less excuse not to be explicit about which names are bound to which.
5. If there are many arguments, you're less likely to notice any mismatch between argument and parameter positions that might falsely make you think something is wrong. That is, you're less likely to either remember the parameter order or to go through the trouble of inspecting and comparing the orders.
In my experience, the more arguments there are, the more likely it is that something has been got wrong, so I'm actually more likely to go to the trouble of inspecting and comparing the orders. Maybe I'm paranoid, but I've caught enough bugs that way to feel justified in my paranoia.
6. If you're thinking about parameter binding and argument order, you're inspecting the arguments at least somewhat closely, and will almost certainly notice that the `**` is present. If you know what it means, problem solved. If you don't, you're at least likely to think about it and try looking it up or ask someone. It takes a very specific kind of skepticism/suspicion to think "the previous programmer messed up the argument order so these parameters are definitely bound wrong, and also that weird `**` that I don't know the meaning of has no bearing on that, and I'm not going to check with a print() or a debugger".
If I have to go away and look some syntax up, that syntax has slowed me down. This doesn't seem like a win to me. -- Rhodri James *-* Kynesim Ltd