Features
-
Declaration: A function begins with def and ends with colon (:).
-
The beginning and ending of a function is specified by an indentation of the code.
-
The interface and implementation are not separated. However, they must have been defined before they are used.
-
An error occurs if the function name is the same as a reserved word or interpreter internal function name. To avoid this, use the function name as using the prefix "fn_", if possible.
Caution
Never use the following reserved words as variable names or function names.
|
and |
assert |
break |
class |
continue |
|
def |
del |
elif |
else |
except |
|
exec |
finally |
for |
from |
global |
|
if |
import |
in |
is |
lambda |
|
list |
not |
open |
or |
os |
|
pass |
|
raise |
return |
select |
|
try |
while |
with |
yield |
|
Sentence
def <function name> (parameter 1, parameter 2, … parameter N):
<syntax> …
return <return value>
# Example
def fn_Times(a, b):
return a * b
fn_Times (10, 10)
def fn_Times(a, b):
return a * b
tp_log(str(fn_Times(10, 5)))
#expected result: 50
def movej():
return 0 # movej should not be used as a function name as interpreter
# internal function name