# § 7.1. Record expressions

The syntax of record expressions is given below.

{ |

# val point = {X =0.0, Y=0.0};

val point = {X =0.0, Y=0.0} : {X:real, Y:real}

A record whose labels are consecutive numbers starting with 1 is interpreted as a tuple and printed specially.

# {1 = 1.1, 2 = fn => x + 1, 3 = "SML#"};

val it = (1.1, fn, "SML#") : real * (int -> int) * string

# (1,2);

val it = (1,2) : int * int

In Section 6.8, we defined a multiple-argument function, namely powerUncurry (n,C). This is a function that takes a tuple.

Just like lists, record elements can contain values of any types. A record forming function is therefore polymorphic, as seen in the following example.

# fun f x y = {X=x, Y=y};

val f = _ : ['a,'b. 'a -> 'b -> {X:'a, Y:'b}]

# fun g x y = (x,y);

val g = _ : ['a,'b. 'a -> 'b -> 'a * 'b]