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.

Type inheritance

Gentee allows you to inherit structure types. For this purpose you have to specify an attribute inherit with the name of the parent type.

type mytype <inherit = str>
{
   uint i
   uint k
}

Specify an empty curly brackets or a collon if a new type does not have additional fields.

type mynewtype <inherit = mytype> :

You cannot inherit base numeric types and the type reserved. The type inheritance allows you to get fields of any parent type.

type my <inherit = mytype>
{
   str name
}
...
my m
m.i++

Also, you can call methods or functions of all parent types. The compiler finds a suitable method or function when you call some function or method. For example, there are the following functions

func print( mytype mt, uint i )
{
   print("MYTYPE PARAMETER = \( mt.i + i )\n")
}

func print( mytype mt )
{
   print("MYTYPE = \( mt.i )\n")
}

func print( my m )
{
   print("MY = \( m.i )\n")
}

You have

my mm

print( mm, 20 )
print( mm )

The first print outputs MYTYPE PARAMETER = 20 and the second print outputs MY = 0, but nor MYTYPE = 0. The situation with methods or operators is like. If you need to call just a parent method or a function then use the typecasting operator '->' with the parent typename. print( mm->mytype ) displays MYTYPE = 0.

So, Gentee gives you the such main object-oriented programming features as the inheritance and the polymorphism.

Related links