JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

Sogaiu <3 https://github.com/sogaiu/janet-glossary

I saw module and package in the docs (not namespace or library really). I was especially curious about what sub...packages are called, e.g. the core's math/ or spork/math/, subpackages ...subbundles?

My head canon is:

There are bundles and modules.
A bundle exists on the file system. It refers to a directory that contains particular files (notably info.jdn and either bundle/init.janet or bundle.janet).
A bundle can provide one or more modules. This is done by the bundle including one or more files in its directory and telling Janet (via an install function in bundle/init.janet or bundle.janet) to copy these files into Janet's lib directory where they can be imported by other code.
A module is a logical grouping of bindings. It is represented in the runtime as an environment table. That table is typically constructed by reading a file with dofile (which you usually don't call directly but instead use via import). When a module is 'imported' into another module (the importer), certain values from the module's environment table are copied into the environment table or the importer (typically the public ones).
Because of how the environment table is constructed in the common case, a module is typically represented by a single file. It is possible to 'fake' the splitting of a module into different files that the 'containing module' imports into itself and then exposes to its importers by calling import with :prefix "" :export true.

the above is how bundles/modules work outside of the core. The core is different. It's really one environment table but with certain symbols including a 'namespace' (really a prefix, e.g. os/) that makes it look like they're separate modules, but they're not really because they're not from separate environment tables that you can access other than via core.

https://janet-lang.org/docs/modules.html

A module is a collection of bindings and its associated environment. By default, modules correspond one-to-one with source files in Janet, although you may override this and structure modules however you like.