OK, I need to make clear the difference between "definition" of a function and "calling" a function:
pawn Код:
MyFunc(a, b = 27, c[] = "Hi")
{
printf("%d %d %s", a, b, c);
}
That is a function "definition", with one required parameter and two optional parameters. The first defaults to 27, the second to "hi". These, on the other hand, are function calls:
pawn Код:
MyFunc(); // Warning (required parameter is missing).
MyFunc(42); // Prints "42 27 hi".
MyFunc(42, 42); // Prints "42 42 hi".
MyFunc(42, 42, "hello"); // Prints "42 42 hello".
Now it may be that you want to change the third parameter, but leave the second as default. There are three ways of doing this AT THE CALL SITE:
pawn Код:
MyFunc(42, 27, "hello"); // Prints "42 27 hello".
MyFunc(42, _, "hello"); // Prints "42 27 hello".
MyFunc(42, .c = "hello"); // Prints "42 27 hello".
The first version is not brilliant, if the default value on the function definition changes, this will continue to print "27" instead of the new default value.
The second version uses "_" to mean "default", with the parameters still specified in order.
The third version doesn't mention the second parameter at all, instead it sets the third parameter by name using ".".
Named parameters do not have to be in order:
pawn Код:
MyFunc(42, .c = "hello", .b = 42); // Prints "42 42 hello".
Hopefully that clears up my last post.