6.16. kink/MOD

モジュールシステムを操作する。

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

requireは、Mod_nameで指定されたモジュールをロードする。モジュールのロードの詳細については、マニュアルの「モジュールシステム」の章を見よう。

コンフィグメソッド:

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

• C.on_not_found($not_found): default = 例外を投げる関数

• C.on_compile_error($compile_error): default = 例外を投げる関数

モジュールのロードがsuccessの状態で終わった場合、requireは、ロードされたモジュールを渡して$successを末尾呼び出しする。

モジュールのロードがnot_foundの状態で終わった場合、requireは、引数なしで$not_foundを末尾呼び出しする。

モジュールのロードがcompile_errorの状態で終わった場合、requireは、compile_error値を渡して$compile_errorを末尾呼び出しする。

モジュールのロードが例外を投げた場合、その例外は呼び出し元に伝播される。

事前条件

Mod_nameはstrでなければならない。

$successはモジュールを取る関数でなければならない。

$not_foundはサンクでなければならない。

$compile_errorは、compile_error値を取る関数でなければならない。

: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