Record
From Mesham
Jump to navigationJump to search
Syntax
record[name1,type1,name2,type2,.....,named,typed]
Semantics
The record type allows the programmer to combine d attributes into one, new type. There can be any number of names and types inside the record type. A record type is very similar to a typedef structure in C. To access the member of a record use the dot, .
Example
var complex : record["r",Float,"i",Float]; var person: record["name",String, "age",Int, "gender",Char]; var a:array[complex,10]; (a#1).i:=22.3; var b:complex; var me:person; me.name:="nick";
In the above example, complex (a complex number) is a record with two float elements, i and r. The variable b is defined as a complex number and a as an array of these numbers. The variable me is of type person.