Geas MUD, enter the Aventure!
Geas Home | Play the Game

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1.2 Partial argument lists

As seen in the previous chapter, it's possible to assign the reference of a function to a function variable with another name. Another handy feature is that it's possible to set this new function up so that it defines a number of the arguments to the original function as constants, leaving only the remaining as variables. Look at this example:

 
e.g.
    void
    tell_player(object player, string mess)
    {
        player->catch_msg(mess + "\n");
    }

    void
    my_func()
    {
        function mod_tell;

        mod_tell = &tell_player(this_player(), );

        mod_tell("Hello!"); // Equivalent to

        tell_player(this_player(), "Hello!");
    }

This works fine for any number of arguments. The remaining arguments will be filled in left to right, just as you would like to expect. i.e. a function with the header void func(int a, int b, int c, int d, int e) defined as function my_func = func(1, , 3, 4,) and called as my_func(100, 101) is eqvivalent to the call func(1, 100, 3, 4, 101).

As you now understand, the &function_name(argument_list)-way of obtaining function references always count as a partial function definition, even if the argument list is empty. This really isn't that important from a practical point of view, not from your end anyway, but it's good to know what you're talking about even so.



This document was generated by Ronny Wikh on July, 8 2003 using texi2html