Introduction
Glich has just one built-in object, the general purpose object with the code name ":" (colon).
There is also one built-in object function. This is available for all objects irrespective of the object definition.
Built-in Objects
General Purpose Object ":"
The {:} object can be used as a variable length array of values. Its definition is equivalent to the following statement.
object : {} |
Example | Output |
---|---|
let x = {: 1,,3}; write x nl; x[4] = 5; write x nl; | {: 1, null, 3} {: 1, null, 3, null, 5} |
Built-in Object Functions
Function | Description |
---|---|
object_type @mask( object_type ) | Overlays one object value on another. |
object_type @size | Return the number of elements. |
object_type @obj:name | Return the code name of the object as a string. |
object_type @obj:list | Return object values as a string. |
Object Function ovalue @mask( value )
The elements of the value object are used to replace any values in the calling ovalue object that are of type null.
The length and object definition do not need to match.
Example | Output |
---|---|
let x = {: 1,,3,,5}; write x nl; x = x @mask( {: 10, 20, 30} ); write x nl; x = x @mask( {: ,,,400,500,600} ); write x nl; | {: 1, null, 3, null, 5} {: 1, 20, 3, null, 5} {: 1, 20, 3, 400, 5, 600} |
Object Function ovalue @size
Return the number of elements.
Example | Output |
---|---|
{: 1, 2, 3}@size | 3 |
Object Function ovalue @obj:name
Return the code name of the object as a string.
Example | Output |
---|---|
{test 1, 2, 3}@obj:name | "test" |
Object Function ovalue @obj:list
Return an annotated list of an objects contents as a string, one line per value.
Example | Output |
---|---|
object test { values first second; } {test "One hundred", 101, 102}@obj:list | first = "One hundred" second = 101 2 = 102 |