Go to the first, previous, next, last section, table of contents.


The interactive top-level shell

Author(s): Daniel Cabeza and the CLIP Group.

Version: 1.10#6 (2004/8/7, 21:46:39 CEST)

Version of last change: 1.7#129 (2001/10/28, 15:38:52 CET)

ciaosh is the Ciao interactive top-level shell. It provides the user with an interactive programming environment with tools for incrementally building programs, debugging programs by following their executions, and modifying parts of programs without having to start again from scratch. If available, it is strongly recommended to use it with the emacs interface provided, as it greatly simplifies the operation. This chapter documents general operation in the shell itself. Other chapters document the

Shell invocation and startup

When invoked, the shell responds with a message of identification and the prompt ?- as soon as it is ready to accept input, thus:

Ciao-Prolog X.Y #PP: Thu Mar 25 17:20:55 MET 1999
?- 

When the shell is initialized it looks for a file .ciaorc in the HOME directory and makes an include of it, if it exists. This file is useful for including use_module/1 declarations for the modules one wants to be loaded by default, changing prolog flags, etc. (Note that the .ciaorc file can only contain directives, not actual code; to load some code at startup put it in a separate file and load it using e.g. a use_module/1 declaration.) If the initialization file does not exist, the default package default is included, to provide more or less what other prologs define by default. Thus, if you want to have available all builtins you had before adding the initialization file, you have to include :- use_package(default) in it. Two command-line options control the loading of the initialization file:

-f
Fast start, do not load any initialization file.
-l File
Look for initialization file File instead of ~/.ciaorc. If it does not exist, include the default package.

Shell interaction

After the shell outputs the prompt, it is expecting either an internal command (see the following sections) or a query (a goal or sequence of goals). When typing in the input, which must be a valid prolog term, if the term does not end in the first line, subsequent lines are indented. For example:

?- X =
   f(a,
   b).

X = f(a,b) ? 

yes
?- 

The queries are executed by the shell as if they appeared in the user module. Thus, in addition to builtin predicates, predicates available to be executed directly are all predicates defined by loaded user files (files with no module declaration), and imported predicates from modules by the use of use_module.

The possible answers of the shell, after executing an internal command or query, are:

To allow using connection variables in queries without having to report their results, variables whose name starts with _ are not considered in answers, the rest being the answer variables. This example illustrates the previous points:

?- member(a, [b, c]).

no
?- member(a, [a, b]).

yes
?- member(X, [a|L]).

X = a ? ;

L = [X|_] ? 

yes
?- atom_codes(ciao, _C), member(L, _C).

L = 99 ? ;

L = 105 ? ;

L = 97 ? ;

L = 111 ? ;

no
?- 

Entering recursive (conjunctive) shell levels

As stated before, when the user answers with `,' after a solution is presented, the shell enters a recursive level, changing its prompt to N ?- (where N is the recursion level) and keeping the bindings or constraints of the solution (this is inspired by the LogIn language developed by H. Ait-Kaci, P. Lincoln and Roger Nasr [AKNL86]). Thus, the following queries will be executed within that context, and all variables in the lower level solutions will be reported in subsequent solutions at this level. To exit a recursive level, input an EOF character or the command up. The last solution after entering the level is repeated, to allow asking for more solutions. Use command top to exit all recursive levels and return to the top level. Example interaction:

?- directory_files('.',_Fs), member(F,_Fs).

F = 'file_utils.po' ? ,

1 ?- file_property(F, mod_time(T)).

F = 'file_utils.po',
T = 923497679 ? 

yes
1 ?- up.

F = 'file_utils.po' ? ;

F = 'file_utils.pl' ? ;

F = 'file_utils.itf' ? ,

1 ?- file_property(F, mod_time(T)).

F = 'file_utils.itf',
T = 923497679 ? 

yes
1 ?- ^D
F = 'file_utils.itf' ? 

yes
?- 

Usage and interface (ciaosh)

Documentation on exports (ciaosh)

PREDICATE: use_module/1:

Usage: use_module(Module)

PREDICATE: use_module/2:

Usage: use_module(Module, Imports)

PREDICATE: ensure_loaded/1:

Usage: ensure_loaded(File)

PREDICATE: make_exec/2:

Usage: make_exec(File, ExecName)

PREDICATE: include/1:

Usage: include(File)

PREDICATE: use_package/1:

Usage: use_package(Package)

PREDICATE: consult/1:

Usage: consult(File)

PREDICATE: compile/1:

Usage: compile(File)

PREDICATE: ./2:

Usage: .(File, Files)

PREDICATE: make_po/1:

Usage: make_po(Files)

PREDICATE: unload/1:

Usage: unload(File)

PREDICATE: set_debug_mode/1:

Usage: set_debug_mode(File)

PREDICATE: set_nodebug_mode/1:

Usage: set_nodebug_mode(File)

PREDICATE: make_actmod/2:

Usage: make_actmod(ModuleFile, PublishMod)

PREDICATE: force_lazy/1:

Usage: force_lazy(Module)

PREDICATE: undo_force_lazy/1:

Usage: undo_force_lazy(Module)

PREDICATE: dynamic_search_path/1:

Usage: dynamic_search_path(Name)

PREDICATE: multifile/1:

Usage: multifile Pred

Documentation on internals (ciaosh)

PROPERTY: sourcenames/1:

Is defined as follows:

sourcenames(File) :-
        sourcename(File).
sourcenames(Files) :-
        list(Files,sourcename).

See sourcename/1 in section Basic file/stream handling

Usage: sourcenames(Files)


Go to the first, previous, next, last section, table of contents.