Mr. King, first off I should say that it's generally bad practice to write functions that have several arguments, for several reasons. If you want a full explanation of why, read Clean Code by Robert C. Martin.
One suggestion would be to create a struct or class that contain the data you want to pass, so you can handle default parameters in that.
// Create a class for the data, or a struct by extending System.ValueType.
class BarArgs {
var a : int = 15;
var b : int = 20;
var c : int = 25;
var d : int = 30;
}
function Bar( data : BarArgs ) {
// Do something with data.a, data.b, data.c, data.d
}
var data = BarArgs();
data.a = 12;
data.b = 9;
data.d = 7;
Bar(data);
In C# you could have used initializers:
Bar(new BarArgs() {a = 12, b = 9, d = 7});
If you don't want to do that, I wouldn't make overloads in any other order than the present:
function Bar() {
Bar(15);
}
function Bar( a : int ) {
Bar(a, 20);
}
function Bar( a : int, b : int ) {
Bar(a, b, 25);
}
function Bar( a : int, b : int, c : int ) {
Bar(a, b, c, 30);
}
function Bar( a : int, b : int, c : int, d : int ) {
// Do something
}
Because as you already mentioned, it's not a good idea to swap order for the parameters. It's error prone and will leave you with a lot to desire.
However, if you want to change the order, you might want to create an overload with a different name.
function BarABD( a : int, b : int, d : int) {
Bar(a, b, 25, d);
}
Then you'd call it by:
BarABD( 12, 9, 7 );
Or you could consider just forcing to deal with 4 arguments (or any subset overloads). Why do you need all this flexibility?