6.16. kink/MOD

Operates the module system.

6.16.1. MOD.require(Mod_name ...[$config={}])

`require` loads the module specified by `Mod_name`. See “Module system” section of the manual for details of module loading.

Config methods:

• C.on_success($success): default = VAL$identity

• C.on_not_found($not_found): default = a fun which raises an exception

• C.on_compile_error($compile_error): default = a fun which raises an exception

If module loading ends with `success` status, `require` tail-calls $success with the loaded module.

If module loading ends with `not_found` status, `require` tail-calls $not_found with no arg.

If module loading ends with `compile_error` status, `require` tail-calls $compile_error with a `compile_error` value.

If an exception is thrown while module loading, the exception is propagated to the caller.

Preconditions

`Mod_name` must be a `str`.

$success must be a fun which takes a module.

$not_found must be a thunk.

$compile_error must be a fun which takes a `compile_error` value.

Example

:MOD.require_from('kink/')

:FLAT_SET <- MOD.require('kink/container/FLAT_SET')
stdout.print_line(FLAT_SET.of('foo' 'bar' 'baz').repr) # => (flat_set "bar" "baz" "foo")

MOD.require('no/such/MOD'){(:C)
  C.on_not_found{ stdout.print_line('no such mod') }
} # => no such mod

6.16.2. MOD.add_path(Path)

`add_path` inserts `Path` to the mod base paths as the last path.

Precondition:

• `Path` must be a str