Methods and Functions
Function and class method declaration is the biggest difference between Origo and existing well known programming languages.
There's no definitive "method name" in Origo, but the parameters are mixed within the name text.
(About the terminology. In the present document, name method means the function members of the classes, and functions are the global functions outside any class like the program entry point main.)
Parameters
A function consists of any number of words (text parts) and parameters, which are separated from each other with spaces.
Parameters are written inside angle brackets < >. Here's an example of a method definition:
(int) base <int base> to power <int exponent>
The definition above taks two parameters: base and exponent. Parameter data type specifier precedes the actual variable name,
like int before base.
Return value
If a function has a return value it is written in parentheses ( ) in the beginning of the definition.
A Function Call
The function is called simply by entering suitable values (or arguments) in place of parameter definitions, and storing the possible return value if needed.
For instance, the function above is called:
int power = base 5 to power 7
(int) base <int base> to power <int exponent>
if base < 1 or exponent < 0
return 0
int result = 1
int i = 0
while i < exponent
result *= base
i++
return result
The Program Entry Point
Global function main is a mandatory function in every program. It is the program entry point where the execution of the program always starts.
main
int result = base 5 to power 7
print result
print 5 ** 7
return