Gentee Programming Language > Documentation > Syntax Download documentation

Subfunction subfunc declaration

Subfunctions are defined in the body of the function with the help of the subfunc construction. A subfunction is defined in the lowest level of the embedded block of the body. You can call a subfunction only from the function body as well as from other subfunctions of the given function. It is impossible to define another subfunction and to call itself recursively, because local variables are considered to be static. A subfunction is able to redefine other functions' names. A subfunction is actually called like a function; moreover, a subfunction as well as its parameters are declared in much the same way as the function, except for the lack of attributes. You can use local variables of the function within the subfunction.

<subfunction> ::= subfunc [<type name>] <function name> ['(' [<parameters declaration>] ')'] <block>

func uint myfunc( int par )
{
int locvar
subfunc int mysubfunc( int subpar )
{
return locvar + par + subpar
}
par = mysubfunc( 10 )
}

See also

    func Function Declaration


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