Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
42
Task/Call-a-function/Liberty-BASIC/call-a-function.basic
Normal file
42
Task/Call-a-function/Liberty-BASIC/call-a-function.basic
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
'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
|
||||
res = g(x)
|
||||
res = h(x,y)
|
||||
'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
|
||||
'impossible
|
||||
'Calling a function with named arguments
|
||||
'impossible
|
||||
'Using a function in statement context
|
||||
'impossible (see starting notice)
|
||||
'Using a function in first-class context within an expression
|
||||
'impossible
|
||||
'Obtaining the return value of a function
|
||||
res = g(x)
|
||||
'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),
|
||||
res = g(x)
|
||||
'while subroutines called with special keyword CALL and without brackets
|
||||
call test x, y
|
||||
'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
|
||||
'impossible
|
||||
Loading…
Add table
Add a link
Reference in a new issue