For class types, a special operator is defined to return the class object for method calls rather than the return value from the call itself. The use of the operator places the return types in special variables to be accessed easily. The operator is simply a syntax helper and is along the lines of UFCS.

e.g.,

class myClass
{
     Do(int x) { return x + 2; }

}

auto myObj = new myClass();
assert(@@myObj.Do(3).Do(4).Do(5) == 7);

Of course, such a silly example is not very helpful but demonstrates the concept.

To make such a syntax work well, I believe one then needs a further operator to access the last return value.

e.g.,

assert(@@myObj.Do(3).Do(@).Do(@2) == 9);

Where the same symbol is used for there return value placeholders and indices are used to access nested calls return value with @ defaulting to @1.

Essentially such syntax allows for easily doing nested calls.

The only down side is that the operator could only be used on one method call at a type in the nesting. (or multiple or parameritized operators would be required)

Obviously @ would not be the symbol of choice.


Reply via email to