Gentee Programming Language > Documentation > Syntax | Download documentation |
Structure types are defined by using the type command. This command is followed by the specified type name and fields description. The structure types can contain fields and methods. However, the type command defines fields only, and methods are defined by the method command. There can be one or more fields of the same type defined in each string of the block. First, a type name is specified, which is followed by field names separated by commas. The field can have a fundamental type as well as the previously defined structure type. Fields of the structure type are organized in memory as they have been described in the source code; if the field has a structure type, the structure of this type is completely embedded in the final structure. When arrays are defined, dimensions separated by commas and enclosed in square brackets and the item type followed the keyword of can be determined.
<array declaration> ::= ['['<natural number> { [','] <natural number>} ']'] [of <type name>]
<field declaration> ::= <field declaration> [<field attributes>] [<array declaration>]
<field declaration> ::= <type name><field declaration> {[','] <field declaration>}<end-of-line>
<type> ::= type [<type attributes>] '{'<field declaration>{<field declaration>} '}'
You can set the index=<type name> attribute for the type command. The item type of the specified structure is declared by default.
type mytype<index = arr of str>
{
...
}
You can inherit types. You have to use the attribute inherit=<type name> for this purpose. See more details in Type inheritance.
Gentee makes it possible to restrict access to fields of the type from other modules. The specified protected attribute is used for this purpose. In this case, all fields of the type will be accessible before the current file has compiled. Otherwise, fields of this type will be unaccessible.
type mytype<protected>
{
...
}
You can set the free attribute for a field. In this case, the field type should be uint; moreover, the memory space address allocated by the alloc function will be stored in the specified field. When an object of the type is destroyed, the memory space will be freed automatically. The other attribute xdim must be set for the singular field type uint, if the object supports a multidimensional array. In this field the service information of the multidimensional array will be stored.
type customer
{
str name, last_name
uint age
arr phones[ 5 ] of str
}
![]() |
![]() Copyright © 2004-2006 Gentee Inc. All rights reserved. ![]() |