Modules

Modules in a programmatic sense declare a hierarchy of namespaces through which the visibility of names can be controlled.

Underlying that is a module type which is a collection of useful properties.

function module? o

Is o a module?

Param o:

value to test

Type o:

any

Return:

#t if o is a module, #f otherwise

template module name

switch to the namespace name

Param name:

name of module

Type name:

symbol

Note

As this is a template, you cannot pass a variable.

function %find-or-create-module name

Find the module called name or create one

Param name:

module name to look for

Type name:

symbol

Return:

module called name

Rtype:

module

function module-name module

Return the name of module

Param module:

module to query

Type module:

module

Return:

module name

Rtype:

symbol

function module-symbols [module]

return the symbols in module

Param module:

module to use, defaults to the current module

Type module:

module or symbol, optional

Return:

list of symbols

Rtype:

list

function module-exports mod

Return the exported names of mod

Param mod:

module to query

Type mod:

module or name

Return:

exported names

Rtype:

list

function module-imports mod

Return the modules imported by mod

Param mod:

module to query

Type mod:

module or name

Return:

imported modules

Rtype:

list

function module-alias name [identity]

Create name as an alias for identity or the current module if identity is not supplied.

Param name:

module alias’ name

Type name:

symbol

Param identity:

target module

Type identity:

module or symbol

Return:

#<unspec>

Warning

If the identity module’s symbols, exports or imports are unset when module-alias is called then changes will not be seen.

If you are aliasing yourself, use module-alias after the provide expression.

See also

module-identity

function module-identity mod

Return the identity of module mod

Param mod:

module

Type mod:

module or symbol

Return:

module’s identity

Rtype:

module or #n

If mod is an alias of another module then the identity of mod is the module it is aliasing – which could be another alias.

See also

module-alias

template export [names]

Add names to the list of names export by the current module

Param names:

names to be exported

Type name:

symbol or a list of symbols

Note

As this is a template, you cannot pass a variable.

template in-module name [body]

Run body in module name.

Param name:

module name

Type name:

symbol

Param body:

expressions

Type body:

list

function all-modules

Return a list of all modules

Return:

all modules

Rtype:

list

function find-module name [default]

Find the module called name

Param name:

module name to look for

Type name:

symbol

Param default:

return value if name is not found

Type default:

any, optional

Return:

module called name or default (or #<unspec>)

Rtype:

module

Raises ^rt-module-error:

Last built at 2024-05-17T06:10:55Z+0000 from 62cca4c (dev) for Idio 0.3.b.6