SML# Document Version 4.1.0
19 Expressions

19.3 Long identifier expression ⟨longVid⟩

A long identifier ⟨longVid⟩, appears as an expression, evaluates to the type and dynamic value that the ⟨longVid⟩ bound to in the current environment.

⟨longVid⟩ is of the form ⟨strId1⟩. ⋯.⟨strIdn⟩. ⟨vid⟩. Structure identifier ⟨strIdi⟩ corresponds to a (nested) structure, according to the static scope rule defined in Chapter 21. As defined in Chapter 16, each structure declaration has the effect of extending the current environment with the set of bindings of long identifiers. The set of binding generated by the structure declaration corresponding to ⟨strIdi-1⟩ contains the binding obtained from the binding corresponding to ⟨strIdi⟩ by prefixing the structure name ⟨strId⟩ to each of the long identifier.

The type and value of ⟨longVid⟩ are therefore the same as those that ⟨vid⟩ is bound to in the structure corresponding to ⟨strIdn⟩. If n=0 then the type and value are those that ⟨vid⟩ is bound to at the top-level. A simple example is shown below.

# structure A = struct val x = 99 end;
structure A =
  struct
    val x = 99 : int
  end
# structure B = struct structure C = A end;
structure B =
  struct
    structure C =
      struct
        val x = 99 : int
      end
  end
# B.C.x;
val it = 99 : int