docs: add a section about modules specifics (#20653)

This commit is contained in:
Pierre Curto 2024-01-25 21:50:42 +01:00 committed by GitHub
parent a17b54527a
commit a84bce37f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,