Here'a a clarification on what Ralf wrote. This also augments what is at [link:research.microsoft.com] (we're in the process of revamping the entire F# language specification and will improve this material)

  • The granularity of initialization is the implementation file (.ml or .fs). If anything triggers the execution of a single binding in the file then all the top-level bindings in the file are established in top-to-bottom order. This means accessing a binding in a nested module may trigger the execution of all the bindings in a file.
  • Bindings in other implementation files are guaranteed to be triggered prior to uses of any values initialized by side-effecting, computed top-level bindings. For example if an implementation file creates a top-level hashtable value then the hash table is created before it is used. The bindings may also be triggered by the use of constant values such as large constant data terms.
  • For an EXE the bindings in the last implementation file are executed first. This may trigger bindings in other implementation files.
  • For a DLL no particular bindings are executed "first" - it depends on which modules are actually used by clients of the DLL.

The rest of the details come straight from the .NET treatment of intialization, e.g.

  • The bindings are executed on the same thread of execution of the code that triggers the execution of the bindngs. That means you can't rely on the bindings being run on the main thread (e.g. the GUI thread). A mutex is active during the execution of the bindings to ensure two threads don't both execut the bindings.
By on 2/24/2007 2:26 AM ()

The execution flow is that every global let binding is executed. In general, that is right at the end of the last file in the project.

There is a simpler way than adding files back in: You add the new .fs/.fsi file. Choose "Unload Project". Then select "Edit Project file" and rearrange the file entries at the bottom of the file the way you want them to be. Save the fhsarpp project file and then select "Relead Project".

Hope this helps,

Ralf Herbrich

By on 2/24/2007 12:12 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper