Is there a difference between top-level modules and local modules?

I am new to F #, but I am very familiar with C #. And I was wondering if there is a difference between the declaration of top-level modules and local modules (e.g., performance, etc.). Also, the namespace declaration is not required for top-level modules (it is part of the module declaration). I cannot find anything in the documentation ( MSDN F # Modules ), indicating other differences.

Basically, based on the C # world, I prefer

//Version 1 namespace My.Namespace module MyModule = let a = 1 

above

 //Version 2 module My.Namespace.MyModule let a = 1 

Given that in both versions there will be only one module in the file, does version 2 have any drawbacks (compared to version 1)?

+7
module f #
source share
1 answer

It is equivalent. According to the F # 3.0 specification :

An implementation file that begins with a module declaration defines a single group of namespace declarations with one module. For example:

 module MyCompany.MyLibrary.MyModule let x = 1 

equivalent to:

 namespace MyCompany.MyLibrary module MyModule = let x = 1 
+6
source share

All Articles