Gentee Programming Language > Documentation > Syntax | Download documentation |
Gentee enables objects to do new operations using the statements which already exist. Moreover, the statement priority keeps permanent. The operation processing is executed with the help of special function-operators which include the keyword operator. Then you should specify the result type, the operator represented by characters and one or two parameters which are subject to the operation (either unary or binary). The parameters type coincides with the operands type, thus the parameters will contain the operand values. If the operation is considered to be binary, the first parameter represents the left operand and the second parameter represents the right one. To get the structured result, you will need to add the extra parameter.
If you want to describe comparison operators for your type then you can take only ==, < and > operators . Operators !=, >=, <= may not be described and are compiled to ==, < and > automatically.
<operator declaration> ::= operator <type name> <operator> '(' <parameters declaration> ')'
<operator> ::= <operator declaration><function body>
The operator-body is like the function-body
operator str +( str left right result ) //The + operator concatenates two strings.
{
result = left
return result += right //the assignment operator as defined above is used
}
...
str a="One", b="Two
a = a + " " + b //In this expression the + operator concatenates two strings
See also
![]() |
![]() Copyright © 2004-2006 Gentee Inc. All rights reserved. ![]() |