Jonathan M Davis:

> All of a sudden you could have
> 
> foo(4, 5);
> foo(x : 4, y : 5);
> foo(y : 5, X : 4);
> 
> all making _exactly_ the same function call. That seem _very_ bug-prone and 
> confusing to me.

(You have used an upper case X, this bug will be caught by the compiler).
For me the #1 purpose of named arguments is to make code more explicit/readable 
and often less buggy.

If you swap all arguments in your program, using named arguments, you are 
probably making your program a little more bug-prone. So as most other features 
there's a way to misuse it. But in most cases you don't swap arguments, and you 
use names more semantically meaningful than just x and y, so swapped arguments 
sticks out more. And you also need to train yourself a bit, to see the 
arguments of function calls not in their of their order, but in term of their 
names, their semantics. If you use MatPlotLib (from Python) you learn to see 
the names of function arguments and mostly ignore the order you give them to 
functions (because the order is much less significant), so this feature needs a 
bit of training for the mind/attitude of the programmer too.

Bye,
bearophile

Reply via email to