Gentee Programming Language > Documentation > Syntax Download documentation

Function Call And Method Call, Function Call Via A Pointer

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.

<parameters> ::= <expression> {','<expression>}
<function call> ::= (<function name> | <expression>'->'func ) '(' [<parameters>] ')'
<method call> ::= <object>'.'<method name>'(' [<parameters>] ')'

myfunc( a, b + c )

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( d )
a = b->mystruct.mymethod( d ) // if b stores the address of the structure

A variable of uint type can store the address of a function. In order to get the address of a function, the address-of operator is used, which is followed by the name of the function without parentheses. A function call includes the -> operator followed by the keyword 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.

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 -> operator followed by the keyword 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" )
a->stdcall( 1, b )

See also

    Fields. Address And Pointer Operation    Table Of Operator Precedence


 Copyright © 2004-2006 Gentee Inc. All rights reserved.