Sage
Tusk Language
Welcome to Sage
Volume (47%) Hide Volume
Topics
Function Calls
In Tusk, you call a routine (a procedure or function) using parentheses…

var x := Sqrt(y); // Call the Sqrt function Writeln(x, ', ', y); // Call the Writeln procedure

Like Delphi, Tusk does not require parentheses when calling a zero-argument routine…

var Name := GetUserName; // Call the GetUserName function Write(Name); // Call the Write procedure Writeln; // Call the Writeln procedure

Trailing Commas

Unlike Delphi, Tusk permits trailing commas in function calls…

Writeln( 'x=', x, '; ', 'y=', y, '; ', 'z=', z, '; ', );

Additional details on this feature may be found here.

Precedence

The precedence of an anonymous method is such that it may be called directly…

var z := function: Integer begin Result := 4; end();

Above, z becomes 4. Note that a one-liner anonymous method may need to be enclosed in parentheses when called directly…

// parens required here... var z := (function = 4)(); // but not here... procedure(f: Boolean) = if f then begin Writeln('f') end(True);

Above, the first anonymous method needed to be enclosed in parentheses, because it ends with an expression (the number 4), but the second one did not need parentheses because it ends with a non-expression (the end keyword).

Regardless, feel free to always enclose anonymous methods in parentheses when calling them directly (Tusk will preserve the superfluous parentheses when pretty printing the code).

Diagram

Syntax Diagram

Call Expression


Last Modified: 2/15 10:06:11 am
In this article (top)  View article's Sage markup
2/15 10:06:11 am