Skip to content

Commit

Permalink
docs: add a section about modules specifics (vlang#20653)
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrec authored Jan 25, 2024
1 parent a17b545 commit a84bce3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3266,6 +3266,19 @@ fn main() {
* You can create modules anywhere.
* All modules are compiled statically into a single executable.

### Special considerations

For the top level project folder (the one that is compiled with v .), and *only*
that folder, you can have several .v files, that may be mentioning different modules
with `module main`, `module abc` etc

This is to ease the prototyping workflow in that folder:
- you can start developing some new project with a single .v file
- split functionality as necessary to different .v files in the same folder
- when that makes logical sense to be further organised, put them into their own directory module.

Note that in ordinary modules, all .v files must start with `module name_of_folder`.

### `init` functions

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

0 comments on commit a84bce3

Please sign in to comment.