Difference between revisions of "Record"
From Mesham
Jump to navigationJump to search (Created page with '== Syntax == record[name<sub>1</sub>,type<sub>1</sub>,name<sub>2</sub>,type<sub>2</sub>,.....,name<sub>d</sub>,type<sub>d</sub>] == Semantics == The ''record'' type allows the…') |
(No difference)
|
Revision as of 21:29, 10 January 2010
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.