Structures are used to define the memory organization and treatment of values.
A structure can be added to and modified after its declaration, as long as the internal types do not conflict.
A structure is defined as follows:
[variable]{[...definitions]}
Where the definitions are enclosed in braces following the variable that is being structured. The definitions include a list of the values and functions which the structure is composed of, which can be both named or unnamed, separated by commas or semicolons. The variable can not be defined as any type other than a structure.
A single field of a structure can be accessed as follows:
[variable] [field]
Where the name of the field follows the variable, separated by any number of spaces.
Multiple fields of a structure can be accessed and used as follows:
[variable]>>[...fields]
Where the fields which follow the double right arrow contains any usage of the fields of the variable, which is unlike the single field access shown above. This is very similar to the definition of a structure, except variables defined in fields are not stored in the structure;
//definition of farm
farm{
products=[];
size =50*acre;
age =5*year;
}
//...
//...
//extended definition
farm{
animals =["cow","pig","chicken","lamb"];
plants =["lettuce","corn","wheat"];
products=animals+plants;
enough?(req_size): req_size <= size;
}
Farm is declared with some initial fields, then it has new fields added and the products fields modified
//making a copy of the structure farm
Joes =farm;
Lucas =farm;
//modify individual fields
Joes size, Lucas size = 90*acre, 20*acre;
//modify several fields of Joes
Joes >> products = sum(animals, plants = ["chicken"], []);
Accessing and modifying fields of several farm structures