default_foo.ts
in the compiled-aqua
directory:default_foo
and foo
is the compiled function.module
and declare
module
declaration, Aqua allows developers to create named modules and define membership visibility where the default visibility of module
is private. That is, with the module
declaration all module members are private and do not get compiled.export.aqua
file like so:export.aqua
compiled-aqua
, in our case, for the lack of output files. Consequently, foo
cannot be imported from other files. For example:foo
is not visible to import.aqua
:declares
to create visibility for a module
namespace for consuming modules. For example,import.ts
:import.aqua
to include the private bar
:declares *
makes all members of the namespace public, although we can be quite fine-grained and use a comma separated list of members we want to be visible, such as declares foo, bar
.use
and import
import
statement earlier. Using import
with the file name, e.g., import "export.aqua"
, imports all visible, i.e., public, members from the dependency. We can manage import granularity with the from
modifier, e.g., import foo from "file.aqua"
, to limit our imports and subsequent compilation outputs. Moreover, we can alias imported declarations with the as
modifier, e.g.,import foo as HighFoo, bar as LowBar from "export_file.aqua"
.import
, we also have the use
keyword available to link and scope. The difference betweenuse
and import
is that use
brings in module namespaces declared in the referenced source file. For example:ExportModule
namespace and makes foo
visible. We can now bring foo
into scope by means of its module namespace ExportModule
in our import file without having to (re-) declare anything:use
as we now can declare a local foo
function rather than the foo_wrapper
we used earlier. use
provides very clear namespace separation that is fully enforced at the compiler level allowing developers to build, update and extend complex code bases with clear namespace separation by default.use
is to use the dependent filename if no module declaration was provided. Moreover, we can use the as
modifier to change the module namespace. Continuing with the above example: