Refine docs.

This commit is contained in:
Stephen Chung
2020-09-19 12:14:02 +08:00
parent b795ce9f45
commit 2ff3a1fde5
18 changed files with 133 additions and 107 deletions

View File

@@ -20,14 +20,15 @@ Global Variables
The `export` statement, which can only be at global level, exposes selected variables as members of a module.
Variables not exported are _private_ and hidden to the outside.
Variables not exported are _private_ and hidden. They are merely used to initialize the module,
but cannot be accessed from outside.
Everything exported from a module is **constant** (**read-only**).
```rust
// This is a module script.
let private = 123; // variable not exported - default hidden
let hidden = 123; // variable not exported - default hidden
let x = 42; // this will be exported below
export x; // the variable 'x' is exported under its own name
@@ -43,9 +44,6 @@ export x as answer; // the variable 'x' is exported under the alias 'answer'
}
```
[`private`] variables are used to initialize the module.
They cannot be used apart from this.
Functions
---------