[ Predicate Database and Compiler | Reference Manual | Alphabetic Index ]

compiled_stream(-Stream)

Succeeds if the I/O stream currently being compiled is Stream.
Stream
Atom, stream handle or variable.

Description

Used to find the stream that is currently being compiled. The stream handle can be used to get other information about the source being compiled, e.g. file name and position. If nothing is currently being compiled, or if a non-textual source is being compiled (compile_term/1,2), this predicate fails.

compiled_stream/1 is meaningful mainly in queries inside a compiled file, or in event handlers for compilation events.

Modes and Determinism

Fail Conditions

Fails if no compilation from a stream is currently active

Exceptions

(5) type error
Stream is instantiated, but not to an atom or stream handle.

Examples

    [eclipse]: [user].
     a.
     :- compiled_stream(S), get_stream_info(S, name, File),
        printf("Compiling stream %d, file %s\n", [S, File]).
    Compiling stream 0, file user
    ^D
     user       compiled traceable 28 bytes in 0.00 seconds

    yes.
    [eclipse]: exec('cat a.pl', []).
    a.
    :- compiled_stream(S), get_stream_info(S, name, File),
       printf("Compiling stream %d, file %s\n", [S, File]).

    yes.
    [eclipse]: [a].
    Compiling stream 5, file /home/joe/a.pl
    a.pl       compiled traceable 28 bytes in 0.00 seconds

    yes.



See Also

compile / 1, compile / 2, compile_stream / 1