Modules
A module always has the following file structure:
Directorysrc/
- …
Directoryres/
- …
Directorytest/
- …
- module.tls
A module is the highest-level grouping of Tacholang code. Every module always has a module.tls file, which specifies
the module information (name, version, description, authors, and other). The src folder contains all the code for that module,
whilst the res folder contains resources that will be embedded into the compiled binary. The test folder is a special
directory, which may contain unit-testing code. Files inside that folder are not included in compiled binaries and completely
ignore all visibility modifiers of the module source code, allowing for extensive unit testing.
Modules are self-contained. The internal visibility modifier makes code visible only inside the current module, with no way to provide
exceptions. Resources are also self-contained inside a module. If you wish to expose resources from your module to library consumers,
you must provide functions which return the resources.
*.tls files are special Tacholang script files which expose only certain subset of functionality of a full Tacholang source file. A
module.tls file may look like this:
// The module name is the public identifier of this module.// A module may be attributed. These attributes// are retrievable during runtime.module module_name some-attribute
// Dependencies can be configured via the dependencies block.dependencies { // From a central source central vectors // From a GitHub repository github "Strokkur424/discord_tl" as discord // Local library local "/home/strokk/libs/web-library/"}
// Tacholang language extensions need to always be configured module-wide.extensions { from core async from discord_tl command as dc-command}
// Each library may have its own configuration, too!web { // Set path for incoming connections. path "/dev"
// Multiple option values may be present. // Configure initial and max pool size. pool-size 5 20
// Some options may be repeated. This makes the option appear as // an array for the library defining these options. // Add path handlers. handler mod.handler.Warning "/warning" handler mod.handles.Note "/note" // Options can also reference classes from another module. handler web.ErrorHandler "/error"}Libraries may use the module.tls file as a sort of configuration file for their library. This is especially useful for libraries to
set default values. Depending on the definition of the options in the library, these options may be present only during compile-time
or be retrievable in runtime too.