A record expression is a collection of pairs of labels lab and expressions exp.
A record expression is evaluated as follows. First, it is checked whether all of its labels are distinct. If not, a type error occurs. Second, each expression exp is evaluated to a type ty and value in the order of their occurrences in the record expression. Finally, they are sorted in the order of label strings and constitutes a record type
{lab : ty, , lab : ty}
and record value
{lab = , , lab = }
as the type and value of the record expression.
Therefore, for example, when
val x = {SML = (print "SML#";"SML#"), IS = (print " is ";" is "), SHARP = (print " sharp!
\
n";" sharp!\
n")}
is evaluated, it prints "SML# is sharp!" and then x is bound to the type and value like the following
val x = {IS = " is ", SHARP = " sharp!
\
n", SML = "SML#"} : {IS: string, SHARP: string, SML: string}