Call a function: Difference between revisions

Line 20:
 
* There are no differences between between calling built-in vs. user defined functions (or procedures).
 
* Functions without parameters can be called by omitting the parameter list (no empty brackets!):<lang Ada>S: String := Ada.Text_IO.Get_Line;</lang>
 
* Ada provides for functions with optional parameters:<lang Ada>function F(X: Integer; Y: Integer := 0) return Integer;
...
A : Integer := F(12); -- F(12) is the same as F(12, 0)</lang>
 
* One can realize first-class functions by defining an access to a function as a parameter:<lang Ada>function H (Int: Integer;
Line 37 ⟶ 43:
X := H(A, Fun=>F'Access); -- mixture </lang>
 
* As a general rule Ada compiler is free to pass arguments by value or by reference. Parameters have a mode, however: either 'in' or 'out' or 'in out'. It is prohibited to write somthing to an 'in' parameter. The next language Standard, Ada 2012, will support functions with 'out' and 'in out' mode parameters, so far, only procedures could have parameters with non-'in' modes.
 
=={{header|Icon}} and {{header|Unicon}}==
Anonymous user