Is there any difference between top-level modules and local modules?
f#, module
Solution
Those are equivalent. According to F# 3.0 specs:
An implementation file that begins with a module declaration defines a single namespace declaration group with one module. For example:
module MyCompany.MyLibrary.MyModule
let x = 1
is equivalent to:
namespace MyCompany.MyLibrary
module MyModule =
let x = 1
Problem
I am a newbe to F#, but am quite familiar with C#. And I was wondering if there is a difference between declaring top level modules and local modules (e.g. performance, etc.), other than that the namespace declaration is not needed for top-level modules (it is part of the module declaration). I cannot find anything in the documentation (MSDN F# Modules) specifying other differences. Basically, coming from the C# world I prefer ``` //Version 1 namespace My.Namespace module MyModule = let a = 1 ``` over ``` //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 bring any disadvantages (compared to Version 1)?