Skip to content

Commit a84bce3

Browse files
authored
docs: add a section about modules specifics (vlang#20653)
1 parent a17b545 commit a84bce3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/docs.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3266,6 +3266,19 @@ fn main() {
32663266
* You can create modules anywhere.
32673267
* All modules are compiled statically into a single executable.
32683268

3269+
### Special considerations
3270+
3271+
For the top level project folder (the one that is compiled with v .), and *only*
3272+
that folder, you can have several .v files, that may be mentioning different modules
3273+
with `module main`, `module abc` etc
3274+
3275+
This is to ease the prototyping workflow in that folder:
3276+
- you can start developing some new project with a single .v file
3277+
- split functionality as necessary to different .v files in the same folder
3278+
- when that makes logical sense to be further organised, put them into their own directory module.
3279+
3280+
Note that in ordinary modules, all .v files must start with `module name_of_folder`.
3281+
32693282
### `init` functions
32703283

32713284
If you want a module to automatically call some setup/initialization code when it is imported,

0 commit comments

Comments
 (0)