Reputation: 7407
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.
Upvotes: 8
Views: 957
Reputation: 118895
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.)
Upvotes: 8
Reputation: 755317
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
Upvotes: 4