Calling functions and methods
Calling function and method
A function call includes the name of the function being called and the arguments enclosed in parentheses and separated by commas. If the function does not have any arguments, the empty parentheses follow the function name. If either a function or a method returns a value, the function or method call may be used in the expression. The . operator is used to call a method, then the arguments are listed in the same way as the arguments of a function: the variable, which stores a structure, is followed by the point, then you specify the name of the method and the arguments enclosed in parentheses.
a = my.mymethod( myfunc( a, b + c )) a = b->mystruct.mymethod( d )
Function call via a pointer
A variable of uint type can store the address (identifier) of a function. In order to get the address of a function, the & operator is used, which is followed by the name of the function without parentheses. A function call includes the ->func and the arguments listed inside parentheses. In this case, you ought to keep an eye on the number and types of the arguments, because the compiler is not able to verify the arguments. The same way you can call methods and operators.
a = &myfunc a->func( c, d )
Gentee allows you to call functions by their address. For example, you can get the function address when you use Windows API function GetProcAddress. Use the ->stdcall and the arguments listed inside parentheses. If the function has cdecl type then use the keyword cdecl instead of stdcall.
a = GetProcAddress( mylib, "myfunc".ptr()) a->stdcall( 1, b )
The @ operator is applied to call a text-function. This operation can be either unary or binary.
If a text-function is called from the simple function or method, the text function will output data to a console. In case of calling the function from another text-function, data will be outputted to the same place as the current text-function. A text function may be called without the unary @ operator. In other words, the text function is called in the same way as the simple function.
dest @ name(...)
If the @ operator is applied as a binary operator, the left-hand operand must be a string, to which data will be outputted from the text function. In the example illustrated above, dest is a variable or an expression of the str type. Actually, data are appended to a destination string.
The @ operator is used not only for the text-function call, but also for the string output. If the right-hand operand is either a variable or an expression of the str type, this string will be outputted to the console or will be appended to a destination string as described above.
str a @mytext( 10 ) // Console output a @ mytext( 20 ) // string output @"My text" // print( "My text" )