Call a function: Difference between revisions

(Call a function en BASIC256)
Line 1,666:
var value = returnsValue();
}</lang>
 
=={{header|Delphi}}==
Delphi allows everything what [[#Pascal|Pascal]] allows.
In addition, the following is ''also'' possible:
 
Calling a function without arguments and obtaining its return value:
<lang delphi>foo()</lang>
Calling a function with optional arguments:
<lang delphi>foo(1)</lang>
Calling a function with a variable number of arguments:
<lang delphi>foo(1, 2, 3, 4, 5)</lang>
Using a function in a statement context:
<lang delphi>writeLn('Hello world.');
foo;
writeLn('Goodbye world')</lang>
Like above, an empty parameter list, i. e. <tt>()</tt>, could be supplied too.
 
=={{header|Dragon}}==
Line 2,245 ⟶ 2,261:
1, 2, 3, 4, cadena, 6, 7, 8, \'incluye texto\'</pre>
 
=={{header|Free Pascal}}==
See [[#Delphi|Delphi]].
Note, calling a <tt>function</tt> as if it was a <tt>procedure</tt> [i. e. ''discarding'' the return value] is only permitted if you set the compiler setting <tt>{$extendedSyntax on}</tt>/<tt>{$X+}</tt>.
This is the default.
 
=={{header|Gambas}}==
Line 4,063 ⟶ 4,083:
 
Most arguments are passed by reference. Some built-in functions accept arguments (e.g., flags) that are not <code>GEN</code>s; these are passed by value or reference depending on their [[C]] type. See the User's Guide to the PARI Library section 5.7.3, "Parser Codes".
 
=={{header|Pascal}}==
''see also: [[#Delphi|Delphi]] and [[#Free Pascal|Free Pascal]]''
 
Calling a nullary function and obtaining its return value:
<lang pascal>foo</lang>
Calling an n-ary function (n ≥ 1) and obtaining its return value:
<lang pascal>foo(1, 'abc', true)</lang>
 
Following are not possible in Pascal as defined by the ISO standards (ISO 7185 and ISO 10206).
* optional arguments<!-- except for certain _built-in_ _procedures_ [no functions!] -->
* variable number of arguments<!-- except for certain built-in _procedures_ [no functions!] -->
* named arguments
* using a function call as a statement
* distinguishing built-in functions and user-defined functions
* distinguishing subroutines and functions
* stating ''at the call site'' whether arguments are passed by value or by reference
* partial application
 
=={{header|Perl}}==
149

edits