mirror of
https://github.com/vlang/v.git
synced 2025-09-12 17:07:11 -04:00
docs: add a section about modules specifics (#20653)
This commit is contained in:
parent
a17b54527a
commit
a84bce37f1
13
doc/docs.md
13
doc/docs.md
@ -3266,6 +3266,19 @@ fn main() {
|
|||||||
* You can create modules anywhere.
|
* You can create modules anywhere.
|
||||||
* All modules are compiled statically into a single executable.
|
* 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
|
### `init` functions
|
||||||
|
|
||||||
If you want a module to automatically call some setup/initialization code when it is imported,
|
If you want a module to automatically call some setup/initialization code when it is imported,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user