From all the programming language I've used or syntax I've learnt. I keep thinking that why is the parameter order is so hard to be remembered.
some code like these
|
string url = getRealLocation( dpart, 0, cache_dir, true );
|
Reading these kind of code require me to read the documentation on the code I or someone else wrote before.
Sure I can turn it to something more like
1 2 3 4 5
|
vector<string>& directoryPartition = dpart;
const int startIndex = 0;
const bool keep_cache = true;
string url = getRealLocation( directoryPartition, startIndex, cache_dir, keep_cache );
|
to make it clearer but it seems to be a hassle to do this for every function call there is and there might be a lot of conflicting variable name for the same parameter name but different function call. regarding performance I think the code above won't effect any because I trust that compiler is smart enough.
I've take a look at Javascript and this is the only language I've known that has code that can do this even though it isn't vanila code rather it use some library to do this easily
1 2 3 4 5
|
var spaceship = new Spacecraft({
x : 0,
y : 0,
health : 1000
});
|
suddenly the order of the parameter doesn't matter and the it's quite clear what the magic number means...
Is there any big reason why this hasn't been implemented in other language ?
or is it just me who is out of date ?