Skip to content

Commit 3b1739a

Browse files
dsymeadegeo
andauthored
F# docs - add info about capitalization of modules implied by script names (#25297)
* Update index.md * Update index.md * Update docs/fsharp/tools/fsharp-interactive/index.md Co-authored-by: Andy (Steve) De George <[email protected]> Co-authored-by: Andy (Steve) De George <[email protected]>
1 parent fa3a874 commit 3b1739a

File tree

1 file changed

+7
-2
lines changed
  • docs/fsharp/tools/fsharp-interactive

1 file changed

+7
-2
lines changed

docs/fsharp/tools/fsharp-interactive/index.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ open Script1
179179
printfn $"%d{square 12}"
180180
```
181181

182-
Note that the `open Script1` declaration is required. This is because constructs in an F# script are compiled into a top-level module that is the name of the script file it is in.
183-
184182
You can evaluate `Script2.fsx` like so:
185183

186184
```console
@@ -190,6 +188,13 @@ dotnet fsi Script2.fsx
190188

191189
You can specify as many `#load` directives as you like in a script.
192190

191+
> [!NOTE]
192+
> The `open Script1` declaration is required. This is because constructs in an F# script are compiled into a top-level module that is the name of the script file it is in. If the script file has a lowercase name such as `script3.fsx` then the implied module name is automatically capitalized, and you will need to use `open Script3`. If you would like a loadable-script to define constructs in a specific namespace of module you can include a namespace of module declaration, for example:
193+
>
194+
> ```fsharp
195+
> module MyScriptLibrary
196+
> ```
197+
193198
## Using the `fsi` object in F# code
194199
195200
F# scripts have access to a custom `fsi` object that represents the F# Interactive session. It allows you to customize things like output formatting. It is also how you can access command-line arguments.

0 commit comments

Comments
 (0)