Enhancement
A typical pattern for object creation is:
obj = new(`MyType`); $obj.set(`MyType#myProp`, $myValue); $otherObj.set(`OtherType#myRef`, $obj);
Here, a "temporary" variable is used to create an object, initialize it and finally assign it to a reference.
Since set() and other methods do not return the input argument, the temporary variable is necessary to perform the initialization before the new object can be used.
With "explicit method chaining", the temporary variable becomes superfluous:
$otherObj.set(`OtherType#myRef`, new(`MyType`) ..set(`MyType#myProp`, $myValue) );
The ".." operator calls a function on an input object (in this case the new instance of "MyType") and returns this input value, regardless of what the called function returns.
With the ".." operator, object creation and initialization can always be expressed as an expression instead of an imperative chain.
Test
- test.com.top_logic.model.search.expr.TestSearchExpression (reformulated in the now idiomatic syntax for object creation).