Equational definitions
SML functions definitions can look a little more like math:
fun length [] = 0
| length (_ :: tl) = 1 + length tl
More flexible custom operators
Example from http://mlton.org/PrintfGentle:
functor Test(P: PRINTF) =
struct
open P
infix D F
val () = printf (` "here's an int " D " and a real " F ".\n") 13 17.0
val () = printf (` "here's three values (" D ", " F ", " F ").\n") 13 17.0 19.0
end
OCaml can only approach this with infix operators like ^^, **, which loses too much readability to be worth it.
Special features of SML/NJ
Particularly first-class continuations.
Contra: An argument against call/cc
OCaml has multicont in opam, which permits logical programming with the angelic operator.
MLton features
Particularly the section under 'Extensions'.
MLton also has call/cc, and world saving which permits a MLton program to dump program state to a file, and continue from dumped state. Demonstrated in bench/last of 100 million.
MLKit
Has region-based memory management and is supposed to be good for realtime applications.
Has an Online SML IDE that compiles SML to JS in the browser.
Moscow ML
The interactive help is pretty neat! Abbreviated:
- help "before";
+ val o : ('b -> 'c) * ('a -> 'b) -> ('a -> 'c)
+ val ignore : 'a -> unit
@>val before : 'a * unit -> 'a
+
+ val exnName : exn -> string
---- General[23%]: down, up, bottom, top, /(find), next, quit:
and for an ambiguous lookup:
- help "+";
------------------------
| 1 | val General.+ |
| 2 | val Int.+ |
| 3 | val IntInf.+ |
| 4 | val Real.+ |
| 5 | val Time.+ |
| 6 | val Word.+ |
| 7 | val Word8.+ |
------------------------
Choose number to browse, or quit: 7
+ val ~>> : word * Word.word -> word
+
@>val + : word * word -> word
+ val - : word * word -> word
+ val * : word * word -> word
---- Word8[16%]: down, up, bottom, top, /(find), next, quit: