Availability:built-in
initialization(:Goal,
+When)Similar to initialization/1,
but allows for specifying when Goal is executed while loading
the program text:
- now
- Execute Goal immediately.
- after_load
- Execute Goal after loading the program text in which the
directive appears. This is the same as
initialization/1.
- prepare_state
- Execute Goal as part of qsave_program/2.
This hook can be used for example to eagerly execute initialization that
is normally done lazily on first usage.
- restore_state
- Do not execute Goal while loading the program, but only
when restoring a saved state.60Used
to be called
restore
. restore
is still
accepted for backward compatibility.
- program
- Execute Goal once after executing the -g
goals at program startup. Registered goals are executed in the order
encountered and a failure or exception causes the Prolog to exit with
non-zero exit status. These goals are not executed if the
-l is given to merely load files. In that case
they may be executed explicitly using initialize/0.
See also
section 2.11.1.1.
- main
- When Prolog starts, the last goal registered using
initialization(Goal, main)
is executed as main goal. If
Goal fails or raises an exception, the process terminates
with non-zero exit code. If not explicitly specified using the
-t the toplevel goal is set to halt/0,
causing the process to exit with status 0. An explicitly specified
toplevel is executed normally. This implies that -t prolog
causes the application to start the normal interactive toplevel after
completing
Goal. See also the Prolog flag toplevel_goal
and
section 2.11.1.1.