Entry Point in F# June, 2009
I'm now to the point where I have more than one source file in an F# project (Woo hoo!) and the issue of entry point came up. Here is what the language spec says about it (As of 1.9.6):
"12.1.4 Explicit "Main" Entry Point
The last file specified in the compilation order for a .EXE may additionally contain an explicit entry point, indicated by annotating a function in a module with EntryPointAttribute.
- The attribute can be applied only to a let-bound function in a module. It may not be a member.
- Only one function may be given this attribute, and this must be the last declaration in the last file processed on the command line. The function may be in a nested module.
- The function is asserted to have type "string -> int" prior to being checked. If this assertion fails an error is reported.
- At runtime the arguments passed on startup are an array containing the same as entries as System.Environment.GetCommandLineArgs(), minus the first entry in that array.
The function becomes the entry point to the program. It immediately forces the static initializer for the file in which the function exists. It will then run the body of the function."