object
logtalk
Built-in object providing message printing, debugging, library, source file, and hacking methods.
built_instatic, built_in, context_switching_calls, threaded
Default message kinds:
silent,silent(Key),banner,help,comment,comment(Key),information,information(Key),warning,warning(Key),error,error(Key),debug,debug(Key),question, andquestion(Key).Printing of silent messages: By default, silent messages are not printed. These messages are only useful when intercepted.
Printing of banner and comment messages: By default, banner and comment messages are only printed when the
reportflag is turned on.Printing of help, information, and question messages: These messages are always printed by default as they provide requested output.
Printing of warning messages: By default, warning messages are not printed when the
reportflag is turned off.Printing of error messages: These messages are always printed by default.
Printing of debug messages: By default, debug messages are only printed when the
debugflag is turned on. The compiler suppresses debug message printing goals when compiling in optimized mode.Meta messages: A meta message is a message that have another message as argument and is typically used for debugging messages. Meta messages avoid the need of defining tokenizer rules for every message but can be intercepted as any other message.
Meta message
@Message: By default, the message is printed as passed to thewrite/1predicate followed by a newline.Meta message
Key-Value: By default, the message is printed as “Key: Value” followed by a newline. The key is printed as passed to thewrite/1predicate while the value is printed as passed to thewriteq/1predicate.Meta message
Format+Arguments: By default, the message is printed as passed to theformat/2predicate.Meta message
List: By default, the list items are printed indented one per line. The items are preceded by a dash and can be@Message,Key-Value, orFormat+Argumentsmessages. If that is not the case, the item is printed as passed to thewriteq/1predicate.Meta message
Title::List: By default, the title is printed followed by a newline and the indented list items, one per line. The items are printed as in theListmeta message.Meta message
[Stream,Prefix]>>Goal: By default, call user-definedGoalin the context ofuser. The use of a lambda expression allows passing the message stream and prefix. Printing the prefix is delegated to the goal.Meta message
[Stream]>>Goal: By default, call user-definedGoalin the context ofuser. The use of a lambda expression allows passing the message stream.Message tokens:
at_same_line,tab(Expression),nl,flush,Format-Arguments,term(Term,Options),ansi(Attributes,Format,Arguments),begin(Kind,Variable), andend(Variable).
Public predicates
print_message/3
Prints a message of the given kind for the specified component.
staticprint_message(Kind,Component,Message)print_message(+nonvar,+nonvar,+nonvar) - oneprint_message_tokens/3
Print the messages tokens to the given stream, prefixing each line with the specified atom.
staticprint_message_tokens(Stream,Prefix,Tokens)print_message_tokens(@stream_or_alias,+atom,@list(nonvar)) - oneprint_message_token/4
User-defined hook predicate for printing a message token (see this object remarks).
dynamic, multifileprint_message_token(Stream,Prefix,Token,Tokens)print_message_token(@stream_or_alias,@atom,@nonvar,@list(nonvar)) - zero_or_onemessage_tokens//2
User-defined hook grammar rule for converting a message into a list of tokens (see this object remarks).
dynamic, multifilemessage_tokens(Message,Component)message_tokens(+nonvar,+nonvar) - zero_or_onemessage_prefix_stream/4
Message line prefix and output stream to be used when printing a message given its kind and component.
dynamic, multifilemessage_prefix_stream(Kind,Component,Prefix,Stream)message_prefix_stream(?nonvar,?nonvar,?atom,?stream_or_alias) - zero_or_moremessage_prefix_file/6
Message line prefix and output file to be used when printing a message given its kind and component.
dynamic, multifilemessage_prefix_file(Kind,Component,Prefix,File,Mode,Options)message_prefix_file(?nonvar,?nonvar,?atom,?atom,?atom,?list(compound)) - zero_or_moremessage_hook/4
User-defined hook predicate for intercepting message printing calls.
dynamic, multifilemessage_hook(Message,Kind,Component,Tokens)message_hook(+nonvar,+nonvar,+nonvar,+list(nonvar)) - zero_or_oneask_question/5
Asks a question and reads the answer until the check predicate is true.
staticask_question(Kind,Component,Question,Check,Answer)ask_question(*,*,*,1,*)ask_question(+nonvar,+nonvar,+nonvar,+callable,-term) - onequestion_hook/6
User-defined hook predicate for intercepting question asking calls.
dynamic, multifilequestion_hook(Question,Kind,Component,Tokens,Check,Answer)question_hook(*,*,*,*,1,*)question_hook(+nonvar,+nonvar,+nonvar,+list(nonvar),+callable,-term) - zero_or_onequestion_prompt_stream/4
Prompt and input stream to be used when asking a question given its kind and component.
dynamic, multifilequestion_prompt_stream(Kind,Component,Prompt,Stream)question_prompt_stream(?nonvar,?nonvar,?atom,?stream_or_alias) - zero_or_moretrace_event/2
Trace event handler. The runtime calls all trace event handlers using a failure-driven loop before calling the debug event handler.
dynamic, multifiletrace_event(Event,ExecutionContext)trace_event(@callable,@execution_context) - zero
Unification events: Generated after a successful unification with a fact -
fact(Entity,Fact,Clause,File,Line)- or a rule head -rule(Entity,Head,Clause,File,Line).Goal events: Generated when calling a goal:
top_goal(Goal,CompiledGoal)orgoal(Goal,CompiledGoal).
debug_handler/1
Enumerates, by backtracking, all declared debug handler providers. Define a clause for this predicate to declare a new debug handler provider.
static, multifiledebug_handler(Provider)debug_handler(?object_identifier) - zero_or_moredebug_handler(?category_identifier) - zero_or_moreactive_debug_handler/1
Current active debug handler provider if any. There is at most one active debug handler provider at any given moment.
staticactive_debug_handler(Provider)active_debug_handler(?category_identifier) - zero_or_oneactive_debug_handler(?category_identifier) - zero_or_oneactivate_debug_handler/1
Activates the given debug handler provider. There is at most one active debug handler provider at any given moment. Fails if the object or category is not declared as a debug handler provider.
staticactivate_debug_handler(Provider)activate_debug_handler(@object_identifier) - zero_or_oneactivate_debug_handler(@category_identifier) - zero_or_onedeactivate_debug_handler/0
Deactivates the current debug handler provider if any.
staticdeactivate_debug_handler - onedebug_handler/3
Debug event handler. Called by the runtime when the given provider is active.
static, multifiledebug_handler(Provider,Event,ExecutionContext)debug_handler(+object_identifier,+callable,+execution_context) - zero_or_moredebug_handler(+category_identifier,+callable,+execution_context) - zero_or_more
Unification events: Generated after a successful unification with a fact -
fact(Entity,Fact,Clause,File,Line)- or a rule head -rule(Entity,Head,Clause,File,Line).Goal events: Generated when calling a goal:
top_goal(Goal,CompiledGoal)orgoal(Goal,CompiledGoal).
expand_library_path/2
Expands a library alias (an atom) or a compound term (using library notation) into its absolute path. Uses a depth bound to prevent loops.
staticexpand_library_path(LibraryAlias,AbsolutePath)expand_library_path(+atom,?atom) - zero_or_oneexpand_library_path(+callable,?atom) - zero_or_oneloaded_file/1
Enumerates, by backtracking, all loaded files, returning their full paths.
staticloaded_file(Path)loaded_file(?atom) - zero_or_moreloaded_file_property/2
Enumerates, by backtracking, loaded file properties.
staticloaded_file_property(Path,Property)loaded_file_property(?atom,?compound) - zero_or_more
Property
basename/1: Basename of the file (includes the file extension, if any).Property
directory/1: Directory of the file (ending with a slash).Property
mode/1: Compilation mode of the file (possible values areoptimal,normal, anddebug).Property
flags/1: Explicit flags used for compiling the file.Property
text_properties/1: List of the file text properties (encoding/1andbom/1). Empty if noencoding/1directive is present and the stream used for reading the file does not have abom/1(or equivalent) property.Property
target/1: Full path of the generated intermediate Prolog file.Property
modified/1: File modification time stamp (should be regarded as an opaque but otherwise comparable term).Property
parent/1: Full path of the parent file that loaded the file.Property
includes/2: Full path of a file included by the file and the line of theinclude/1directive.Property
includes/1: Full path of a file included by the file.Property
library/1: Library alias for the library that includes the file.Property
object/3: Identifier for an object defined in the file and the start and end lines of its definition.Property
object/1: Identifier for an object defined in the file.Property
protocol/3: Identifier for a protocol defined in the file and the start and end lines of its definition.Property
protocol/1: Identifier for a protocol defined in the file.Property
category/3: Identifier for a category defined in the file and the start and end lines of its definition.Property
category/1: Identifier for a category defined in the file.
file_type_extension/2
Enumerates, by backtracking, all defined file type extensions. The defined types are: source, object, logtalk, prolog, and tmp. The source type returns both logtalk and prolog type extensions.
staticfile_type_extension(Type,Extension)file_type_extension(?atom,?atom) - zero_or_morecompile_aux_clauses/1
Compiles a list of auxiliary clauses. Can only be called during source file compilation, usually from term_expansion/2 or goal_expansion/2 hook predicate definitions.
staticcompile_aux_clauses(Clauses)compile_aux_clauses(@list(clause)) - oneentity_prefix/2
Converts between an entity identifier and the entity prefix that is used for its compiled code. When none of the arguments is instantiated, it returns the identifier and the prefix of the entity under compilation, if any.
staticentity_prefix(Entity,Prefix)entity_prefix(?entity_identifier,?atom) - zero_or_onecompile_predicate_heads/4
Compiles clause heads. The heads are compiled in the context of the entity under compilation when the entity argument is not instantiated.
staticcompile_predicate_heads(Heads,Entity,CompiledHeads,ExecutionContext)compile_predicate_heads(@list(callable),?entity_identifier,-list(callable),@execution_context) - zero_or_onecompile_predicate_heads(@conjunction(callable),?entity_identifier,-conjunction(callable),@execution_context) - zero_or_onecompile_predicate_heads(@callable,?entity_identifier,-callable,@execution_context) - zero_or_onecompile_predicate_indicators/3
Compiles predicate indicators. The predicate are compiled in the context of the entity under compilation when the entity argument is not instantiated.
staticcompile_predicate_indicators(PredicateIndicators,Entity,CompiledPredicateIndicators)compile_predicate_indicators(@list(predicate_indicator),?entity_identifier,-list(predicate_indicator)) - zero_or_onecompile_predicate_indicators(@conjunction(predicate_indicator),?entity_identifier,-conjunction(predicate_indicator)) - zero_or_onecompile_predicate_indicators(@predicate_indicator,?entity_identifier,-predicate_indicator) - zero_or_onedecompile_predicate_heads/4
Decompiles clause heads. All compiled clause heads must belong to the same entity, which must be loaded.
staticdecompile_predicate_heads(CompiledHeads,Entity,Type,Heads)decompile_predicate_heads(@list(callable),-entity_identifier,-atom,-list(callable)) - zero_or_onedecompile_predicate_heads(@conjunction(callable),-entity_identifier,-atom,-conjunction(callable)) - zero_or_onedecompile_predicate_heads(@callable,-entity_identifier,-atom,-callable) - zero_or_onedecompile_predicate_indicators/4
Decompiles predicate indicators. All compiled predicate indicators must belong to the same entity, which must be loaded.
staticdecompile_predicate_indicators(CompiledPredicateIndicators,Entity,Type,PredicateIndicators)decompile_predicate_indicators(@list(predicate_indicator),-entity_identifier,-atom,-list(predicate_indicator)) - zero_or_onedecompile_predicate_indicators(@conjunction(predicate_indicator),-entity_identifier,-atom,-conjunction(predicate_indicator)) - zero_or_onedecompile_predicate_indicators(@predicate_indicator,-entity_identifier,-atom,-predicate_indicator) - zero_or_oneexecution_context/7
Execution context term data. Execution context terms should be considered opaque terms subject to change without notice.
staticexecution_context(ExecutionContext,Entity,Sender,This,Self,MetaCallContext,CoinductionStack)execution_context(?nonvar,?entity_identifier,?object_identifier,?object_identifier,?object_identifier,@list(callable),@list(callable)) - zero_or_oneProtected predicates
(none)
Private predicates
active_debug_handler_/1
Current active debug handler provider. There is at most one active debug handler provider at any given moment.
dynamicactive_debug_handler_(Provider)active_debug_handler_(?entity_identifier) - zero_or_oneOperators
(none)