Friday, August 10, 2012

Use Space in F# Namespace and Module

It is Friday's afternoon and sun finally decide to visit Seattle. I decide to have some fun with F#. I tried to use  space in the variable name with ``. It works perfectly and then  I decide to add space to other components like namespace and module.

Result: both namespace and module name can contains space.

But there are some limitation. The C# IDE does not support namespace contains space. As a result, the C# cannot reference the F# function inside a namespace which contains space. Because F# support space, so you can reference function inside F# code.

In File1.fs

namespace A.``My Space``
type MyClass() = class end
In File2.fs, the following code compiles.

module File2
open A.``My Space``
let c = MyClass()
let d = A.``My Space``.MyClass()
Not sure if somebody wants to use this feature to hide the code from C#, but it is do-able.. :-)

1 comment:

Stacey Oakson said...

That's very interesting! You've specified various kinds of 'space' perfectly. Thanks for the explanation of giving us a clear concept about it.
modules