My program:
val a = chr 65 : char
val b = Char.chr 65: char
val _ = print (Char.toString a)
val _ = print (Char.toString b)
Output:
AA
Lines 1 and 2 show that both chr
and Char.chr
work.
Is there a difference between the two? And which one is conformant to Standard ML 97 and why?
They are the same function. Char.chr
is simply available at the top-level of any SML program unqualified by its module name.
Should you bind the name chr
to another value at the top-level of your program, the original would still be available via the fully-qualified name Char.chr
.