| Arguments |

The most basic primitive is the argument placeholder. For the sake of explanation, we used the '?' in our introductory examples to represent unknown arguments or argument place holders. Later on, we introduced the notion of positional argument place holders.

We use an object of a special class argument<N> to represent the Nth function argument. The argument placeholder acts as an imaginary data-bin where a function argument will be placed.

There are a couple of predefined instances of argument<N> named arg1..argN (where N is a predefined maximum). When appropriate, we can of course define our own argument<N> names. For example:

`

        actor<argument<0> > first_param;    // note zero based index

`

Take note that it should be wrapped inside an actor to be useful. first_param can now be used as a parameter to a lazy function:

`

        plus(first_param, 6)

`

which is equivalent to:

`

        plus(arg1, 6)

`

Here are some sample preset definitions of arg1..N

`

        actor<argument<0> > const arg1 = argument<0>();
        actor<argument<1> > const arg2 = argument<1>();
        actor<argument<2> > const arg3 = argument<2>();
        ...
        actor<argument<N> > const argN = argument<N>();

`

An argument is in itself an actor base class. As such, arguments can be evaluated through the actor's operator(). An argument as an actor base class selects the Nth argument from the arguments passed in by the client (see actor).

For example:

`

        char        c = 'A';
        int         i = 123;
        const char* s = "Hello World";

        cout << arg1(c) << ' ';     //  Get the 1st argument of unnamed_f(c)
        cout << arg1(i, s) << ' ';  //  Get the 1st argument of unnamed_f(i, s)
        cout << arg2(i, s) << ' ';  //  Get the 2nd argument of unnamed_f(i, s)

`

will print out "A 123 Hello World"

Copyright © 2001-2002 Joel de Guzman
Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.