Reputation: 12584
I've encountered in some code the following call :
SQLParser.Parse(qry.SQL.Text)().GetWhereClause
and I don't understand the meaning of those 2 parenthesis after the Parse call. Following the implementation I got the declarations for each one of them:
TSQLParser = class
public
class function Parse(const ASQL: string): ISmartPointer<TSQLStatement>;
TSQLStatement = class
function GetWhereClause: string;
and
ISmartPointer<T> = reference to function: T;
Upvotes: 4
Views: 430
Reputation: 28509
The Parse function returns a reference to a function. You can call this function. A longer equivalent form would be:
var
FunctionReference: ISmartPointer<TSQLStatement>;
SQLStatement: TSQLStatement;
begin
{ Parse returns a reference to a function. Store that function reference in FunctionReference }
FunctionReference := TSQLParser.Parse(qry.SQL.Text);
{ The referenced function returns an object. Store that object in SQLStatement }
SQLStatement := FunctionReference();
{ Call the GetWhereClause method on the stored object }
SQLStatement.GetWhereClause();
The line in the question is just a shorter version that does not use explicit variables to store the intermediate results.
Upvotes: 12