6

I've been assuming that F# includes the module keyword in addition to the namespace keyword due to backwards compatibility with OCaml. Is this the only reason for the inclusion of the module keyword or are there other reasons module was included?

3

1 Answer 1

5

Namespaces are well defined in the .Net universe, and they don't include the things that make up a module, except inside something very much like a module.

Given that they were designing a language to run on the CLR, making it incompatible with other languages would not have made sense.

On a slightly different tangent, namespaces and modules do NOT overlap -- in particular, you can't define another namespace inside a module, and defining another namespace is the sole purpose of namespaces. They may bear a superficial simularity, but they are distinct concepts.

2
  • @WyattBarnett that would be my guess for namespaces but I'm wondering if there were any other reason to include modules in F# besides OCaml compatibility. Guess I need to ask this on the F# lists. Oct 31, 2012 at 16:54
  • 1
    Well, a module translates to a static class. Jul 3, 2014 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.