Refine docs.

This commit is contained in:
Stephen Chung 2020-09-18 11:52:23 +08:00
parent 206f21c26f
commit b795ce9f45

View File

@ -29,7 +29,7 @@ engine.load_package(package.get()); // load the package manually. 'get' returns
Difference Between a Package and a Module Difference Between a Package and a Module
---------------------------------------- ----------------------------------------
Packages are actually implemented as [modules], so they share a lot of behavior and characteristics. Packages are internally implemented as [modules], so they share a lot of behavior and characteristics.
The main difference is that a package loads under the _global_ namespace, while a module loads under its own The main difference is that a package loads under the _global_ namespace, while a module loads under its own
namespace alias specified in an [`import`] statement (see also [modules]). namespace alias specified in an [`import`] statement (see also [modules]).
@ -37,6 +37,11 @@ namespace alias specified in an [`import`] statement (see also [modules]).
A package is _static_ (i.e. pre-loaded into an [`Engine`]), while a module is _dynamic_ (i.e. loaded with A package is _static_ (i.e. pre-loaded into an [`Engine`]), while a module is _dynamic_ (i.e. loaded with
the `import` statement). the `import` statement).
Functions in a package are _flattened_, meaning that functions from sub-modules must be pulled up to the root level.
In other words, there can be no sub-modules in a package, and everything should reside in one, flat namespace.
Only functions matter for a package. Constant variables registered in a package are ignored.
Load a Module as a Package Load a Module as a Package
-------------------------- --------------------------