Logtalk reference manual
Built-in predicate: logtalk_load_context/2
Contents > Reference Manual > Built-in Predicates > logtalk_load_context/2

## logtalk_load_context/2

#### Description

    logtalk_load_context(Key, Value)

Provides access to the Logtalk compilation/loading context. The following keys are currently supported: `entity_identifier`, `entity_prefix`, `entity_type` (returns the value `module` when compiling a module as an object), `source`, `file` (same as `source`), `basename`, `directory`, `stream`, `target` (the full path of the intermediate Prolog file), `flags` (the list of the explicit flags used for the compilation of the source file), `term_position` (`Start-End`), and `variable_names` (`[Name1=Variable1, ...]`). The `term_position` key is only supported in back-end Prolog compilers that provide access to the start and end lines of a read term.

The `source`, `file`, `basename`, `directory`, `target`, and `flags` keys can also be used in calls to the `logtalk_load_context/2` predicate wrapped in `initialization/1` directives.

The `term_position` and `variable_names` are only meaningful when the `logtalk_load_context/2` predicate is called from the `term_expansion/2` predicate. Due to the goal-expansion phase occurring at a later compiler stage, the information provided by these two keys is no longer available at that time.

Using the `variable_names` key requires calling the standard built-in predicate `term_variables/2` on the term read and unifying the term variables with the variables in the names list. This, however, rises portability issues with those Prolog compilers that don't return the variables in the same order for the `term_variables/2` predicate and the option `variable_names/1` of the `read_term/3` built-in predicate, which is used by the Logtalk compiler to read source files.

#### Template and modes

    logtalk_load_context(?atom, -nonvar)

#### Errors

`(none)`

#### Examples

    term_expansion(Term, ExpandedTerms) :-
        ...
        logtalk_load_context(entity_identifier, Entity),
        ....

    :- initialization((
        logtalk_load_context(directory, Directory),
        assertz(logtalk_library_path(my_app, Directory))
    )).

#### See also

`goal_expansion/2`, `term_expansion/2`