Skip to content

Commit

Permalink
F# , add chapter on opening with global specifier (#40809)
Browse files Browse the repository at this point in the history
* Update import-declarations-the-open-keyword.md

Chapter on global keyword

* better names

* specifier not keyword

* Update import-declarations-the-open-keyword.md

Co-authored-by: Petr <psfinaki@users.noreply.github.com>

* Update import-declarations-the-open-keyword.md

Co-authored-by: Petr <psfinaki@users.noreply.github.com>

* try fix md linting errors

---------

Co-authored-by: Petr <psfinaki@users.noreply.github.com>
  • Loading branch information
goswinr and psfinaki committed May 10, 2024
1 parent 04a5481 commit 3bcd650
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@ open type M.DU
printfn "%A" A
```

## Open from root path only with `global` specifier

Nested modules like

```fsharp
module A =
module B =
...
```

can be opened via

```fsharp
open A // opens A
open B // opens A.B
```

To open **only** fully qualified modules or namespaces prefix them with the `global` specifier:

```fsharp
open global.A // works
open global.B // this now fails
open global.A.B // works
```

## Namespaces That Are Open by Default

Some namespaces are so frequently used in F# code that they are opened implicitly without the need of an explicit import declaration. The following table shows the namespaces that are open by default.
Expand Down

0 comments on commit 3bcd650

Please sign in to comment.