EnglishРусский  
The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

Redefining operator operations

Gentee enables objects to do new operations using the existing operators (=, ==, +=, +, *, <, == etc.). 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. Operands can have different types. If the result of the operation is a new object ( for example, adding ) then you must use result attribute. Also, you can define alias attribute if you need that.

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 str +<result>( str left right )
{
   ( result = left ) += right
}

operator str +=( str left, int val )
{
   return left.out4( "%i", val )
}

func main<main>
{
   str dest = "Zero", a="One", b="Two"
   
   print( ( dest = a + b )+= 323 )
}

Related links