|
|
Line 610: |
Line 610: |
|
var foo = [1, 2, 3]; |
|
var foo = [1, 2, 3]; |
|
mutate(foo) // foo is now [null, 2, 3], not 42</lang> |
|
mutate(foo) // foo is now [null, 2, 3], not 42</lang> |
|
|
|
⚫ |
=={{header|Liberty BASIC}}== |
|
⚫ |
|
|
⚫ |
'Call a function - Liberty BASIC |
|
|
|
|
⚫ |
'First, function result could not be discarded |
|
⚫ |
' that is, you cannot do "f(x)" as a separate statement |
|
|
|
|
⚫ |
'Calling a function that requires no arguments |
|
⚫ |
res = f() 'brackets required |
|
|
|
|
⚫ |
'Calling a function with a fixed number of arguments |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
'Calling a function with optional arguments |
|
⚫ |
'impossible for user-defined functions |
|
⚫ |
'Some build-in functions ex. INSTR and MID$ could be called with last argument omitted |
|
⚫ |
'Calling a function with a variable number of arguments |
|
⚫ |
|
|
⚫ |
'Calling a function with named arguments |
|
⚫ |
|
|
⚫ |
'Using a function in statement context |
|
⚫ |
'impossible (see starting notice) |
|
⚫ |
'Using a function in first-class context within an expression |
|
⚫ |
|
|
⚫ |
'Obtaining the return value of a function |
|
⚫ |
|
|
⚫ |
'Distinguishing built-in functions and user-defined functions |
|
⚫ |
'I would say impossible. Though built-in functions could be EVAL'ed, |
|
⚫ |
'while user-defined would not be called (tries address array instead). |
|
⚫ |
'Still cannot distinguish user-defined function from array. |
|
⚫ |
'Distinguishing subroutines and functions |
|
⚫ |
'then defined, subroutines and functions defined with words |
|
⚫ |
'SUB and FUNCTION (case incensitive) |
|
⚫ |
'Then used, function used as expression (with return value), |
|
⚫ |
|
|
⚫ |
'while subroutines called with special keyword CALL and without brackets |
|
⚫ |
|
|
⚫ |
'Stating whether arguments are passed by value or by reference |
|
⚫ |
'Variables passed as arguments into functions and subs are passed "by value" by default |
|
⚫ |
'parameters could be passed "by reference" if formal parameter in sub/function definition uses the "byref" specifier |
|
⚫ |
'Then calling a function, you can prevent pass by reference by changing variable to expression |
|
⚫ |
' like x+0, x$+"" or just (x), (x$) |
|
⚫ |
'Is partial application possible and how |
|
⚫ |
|
|
⚫ |
|
|
|
|
|
|
|
=={{header|LFE}}== |
|
=={{header|LFE}}== |
Line 786: |
Line 740: |
|
* However, one can use <code>lambda</code>s to achieve the same effect. |
|
* However, one can use <code>lambda</code>s to achieve the same effect. |
|
|
|
|
|
⚫ |
=={{header|Liberty BASIC}}== |
|
⚫ |
|
|
⚫ |
'Call a function - Liberty BASIC |
|
|
|
|
⚫ |
'First, function result could not be discarded |
|
⚫ |
' that is, you cannot do "f(x)" as a separate statement |
|
|
|
|
⚫ |
'Calling a function that requires no arguments |
|
⚫ |
res = f() 'brackets required |
|
|
|
|
⚫ |
'Calling a function with a fixed number of arguments |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
'Calling a function with optional arguments |
|
⚫ |
'impossible for user-defined functions |
|
⚫ |
'Some build-in functions ex. INSTR and MID$ could be called with last argument omitted |
|
⚫ |
'Calling a function with a variable number of arguments |
|
⚫ |
|
|
⚫ |
'Calling a function with named arguments |
|
⚫ |
|
|
⚫ |
'Using a function in statement context |
|
⚫ |
'impossible (see starting notice) |
|
⚫ |
'Using a function in first-class context within an expression |
|
⚫ |
|
|
⚫ |
'Obtaining the return value of a function |
|
⚫ |
|
|
⚫ |
'Distinguishing built-in functions and user-defined functions |
|
⚫ |
'I would say impossible. Though built-in functions could be EVAL'ed, |
|
⚫ |
'while user-defined would not be called (tries address array instead). |
|
⚫ |
'Still cannot distinguish user-defined function from array. |
|
⚫ |
'Distinguishing subroutines and functions |
|
⚫ |
'then defined, subroutines and functions defined with words |
|
⚫ |
'SUB and FUNCTION (case incensitive) |
|
⚫ |
'Then used, function used as expression (with return value), |
|
⚫ |
|
|
⚫ |
'while subroutines called with special keyword CALL and without brackets |
|
⚫ |
|
|
⚫ |
'Stating whether arguments are passed by value or by reference |
|
⚫ |
'Variables passed as arguments into functions and subs are passed "by value" by default |
|
⚫ |
'parameters could be passed "by reference" if formal parameter in sub/function definition uses the "byref" specifier |
|
⚫ |
'Then calling a function, you can prevent pass by reference by changing variable to expression |
|
⚫ |
' like x+0, x$+"" or just (x), (x$) |
|
⚫ |
'Is partial application possible and how |
|
⚫ |
|
|
⚫ |
|
|
|
|
|
|
=={{header|Lua}}== |
|
=={{header|Lua}}== |