Are operator parentheses, i.e. trailing ( ), needed if there are no arguments?
Some operators have no arguments and others have only optional arguments. When there are no arguments in use, it is permitted to omit the parentheses. Both these are acceptable:
$MyList = $MyList.sort;
$MyList = $MyList.sort();
Exceptions
Most strict transactional operators (see listing) such as '+
' or '==
' never use trailing parentheses, as in—hypothetically—coding '+()
' would be wrong.
Statement-type operators never take parentheses, but are used as a keyword that precedes some code defining the operator's task:
Conversely, a user-defined function defined via function must always have trailing parentheses or the parser will not detect it. Thus a user defined function 'fSomeTask' that has no defined arguments is nonetheless always coded as fSomeTask()
with tailing parentheses.
Summary
Though optional in some cases, it is considered 'good practice' with Tinderbox action code and other programming languages to use the parentheses when using operators even then they are not strictly required. Not least, it helps remind the user that the code object is a an operator.
So, if in doubt, use empty trailing parentheses.