Be nice, I'm a total newbie to F#. I have created my first console app, and I can't figure out how F# decides which of my .fs files its going to run on startup. Normally apps have an entry point, and the F# forms projects I've seen have an entry point. My console project does not.
It always seems to start with the last file I've added, which is a giant pain. I can't believe its supposed to work this way. I must be doing something wrong.
F# does support entry points, with EntryPointAttribute. See the last screenshot of this blog for details. The 'main' function takes a string array and returns an int, and the EntryPoint must be in the last code file in the project. See also 12.1.4 of the language spec.
Note that if you do not provide an explicit entry point, then the 'top level code' in the last file of the project effectively behaves like 'main'.
(Incidentally, see also this blog for info on managing ordering files in a project inside VS.)
EDIT Read Brian's answer for latest information
My answer is linking to out-dated information.
At this point F# does not support an explicit entry point for an application. It has an implicit entry point which is, as you observed, the last file in the project.
This thread has more details: http://cs.hubfs.net/forums/thread/4151.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With