Gentee Programming Language > Documentation > Syntax | Download documentation |
The as operator executes two functions: to assign a value to a variable and to redefine a type. This operator is binary, that has right-to-left associativity. The left-hand operand must be a local variable of uint type. Depending on the value of the right-hand operand, it can be operated in two possible ways:
1. The right-hand operand is a type name that is different from fundamental types. A value of the local variable is not modified, but its type is redefined with the required one; the variable is assumed to store an object's address, moreover this variable can be treated as the object, ignoring the pointer operation ->.
<as operation> ::= <variable name>'as' ((<type name>[<array>]) | <object>)
str mystr uint a a = &mystr a as str a = "New value"
2. The right-hand operand is an expression that returns an object. An address of the object is assigned to the variable, which redefines its type with the object's type. The object type must be different from fundamental types.
str mystr uint a a as mystr a = "New value"
The variable type will be redefined either until the end of the current block or until the next operation as with the variable occurs. If the variable stores an array address, you should specify dimensions and an element type in addition to the type in the same way as in the pointer operation ->.
See alsoFields. Address And Pointer Operation Table Of Operator Precedence
![]() |
![]() Copyright © 2004-2006 Gentee Inc. All rights reserved. ![]() |