[MLton] Main.main idiom
Stephen Weeks
MLton@mlton.org
Wed, 8 Sep 2004 11:21:17 -0700
> but I think it is better programming practice to not scatter
> top-level effects around. It can actually be useful to compile and
> run the program without the call to Main.main -- it verifies that
> there weren't any unexpected evaluations in the program.
Fair enough. This gives me another idea. We could have a switch
(like -safe) that controls some boolean variable that is used to
govern whether or not the main function is called. So, one would
write:
val () = if MLton.runMain then Main.main () else ()
and then compile with -run-main true to generate the executable
(although maybe -run-main true would be the default). One advantage I
see of this over -mainfn is that the programmer gets to specify within
the language how to call main.