Use

This struct can be used to implement, what looks similar to, new statements. This struct overloads the "in" operator which a delegate can be passed to. The delegate passed to the "in" operator will then be called at an appropriate time decided by the implementation of the function returning the Use struct.

Members

Functions

opBinary
ReturnType opBinary(ARGS[0] dg)

Overloads the "in" operator. The given delegate is supplied by the user and will be called at a time the implementaion has decided.

Variables

args
NEW_ARGS args;

The first argument will be the delegate that performs some arbitrary operation. The rest of the arguments will be pass as arguments to the delegate in "args[0]".

Examples

Use!(void delegate (), bool) unless (bool condition)
{
    Use!(void delegate (), bool) use;
    use.args[1] = condition;

    use.args[0] = (void delegate () dg, bool condition) {
        if (!condition)
            dg();
    };

    return use;
}

int a = 3;
int b = 4;

unless(a == b) in {
    println("a != b");
};

Meta