Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 2fc07611b08d4a735fd34d5eb60d8e16 > files > 2204

ciao-1.10p8-3mdv2010.0.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 -->

<LINK rel="stylesheet" href="ciao.css" type="text/css">
<TITLE>The Ciao Prolog System               - Getting started on Un*x-like machines</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_2.html">previous</A>, <A HREF="ciao_4.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC31" HREF="ciao_toc.html#TOC31">Getting started on Un*x-like machines</A></H1>

<P>
<STRONG>Author(s):</STRONG> M.Hermenegildo.


<P>
<STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST)


<P>
<STRONG>Version of last change:</STRONG> 1.7#133 (2001/11/1, 16:34:6 CET)


<P>
 


<P>
This part guides you through some very basic first steps with Ciao on a Un*x-like system. It assumes that Ciao is already installed correctly on your Un*x system. If this is not the case, then follow the instructions in section <A HREF="ciao_231.html#SEC896">Installing Ciao from the source distribution</A> first. 


<P>
We start with by describing the basics of using Ciao from a normal command shell such as <CODE>sh/bash</CODE>, <CODE>csh/tcsh</CODE>, etc. We strongly recommend reading also section <A HREF="ciao_3.html#SEC42">An introduction to the Ciao emacs environment (Un*x)</A> for the basics on using Ciao under 
<A NAME="IDX265"></A>
<CODE>emacs</CODE>, which is a much simpler and much more powerful way of developing Ciao programs, and has the advantage of offering an almost identical environment under Un*x and Windows. 



<UL>
<LI><A HREF="ciao_3.html#SEC32">Testing your Ciao Un*x installation</A>
<LI><A HREF="ciao_3.html#SEC33">Un*x user setup</A>
<LI><A HREF="ciao_3.html#SEC34">Using Ciao from a Un*x command shell</A>
<LI><A HREF="ciao_3.html#SEC42">An introduction to the Ciao emacs environment (Un*x)</A>
<LI><A HREF="ciao_3.html#SEC43">Keeping up to date (Un*x)</A>
</UL>



<H2><A NAME="SEC32" HREF="ciao_toc.html#TOC32">Testing your Ciao Un*x installation</A></H2>

<P>
It is a good idea to start by performing some tests to check that Ciao is installed correctly on your system (these are the same tests that you are instructed to do during installation, so you can obviously skip them if you have done them already at that time). If any of these tests do not succeed either your environment variables are not set properly (see section <A HREF="ciao_3.html#SEC33">Un*x user setup</A> for how to fix this): 


<P>
 

<UL>

<LI>Typing

<A NAME="IDX266"></A>
<CODE>ciao</CODE> (or 
<A NAME="IDX267"></A>
<CODE>ciaosh</CODE>) should start the typical Prolog top-level shell. 

<LI>In the top-level shell, Prolog library modules should load correctly. Type for example <CODE>use_module(library(dec10_io))</CODE> --you should get back a prompt with no errors reported.

<LI>To exit the top level shell, type <CODE>halt.</CODE> as usual, or <KBD>^D</KBD>.

<LI>Typing

<A NAME="IDX268"></A>
<CODE>ciaoc</CODE> should produce the help message from the Ciao 
<A NAME="IDX269"></A>
standalone compiler. 

<LI>Typing

<A NAME="IDX270"></A>
<CODE>ciao-shell</CODE> should produce a message saying that no code was found. This is a Ciao application which can be used to write 
<A NAME="IDX271"></A>
scripts written in Prolog, i.e., files which do not need any explicit compilation to be run. 

</UL>

<P>
Also, the following documentation-related actions should work: 



<UL>

<LI>If the

<A NAME="IDX272"></A>
<CODE>info</CODE> program is installed, typing <CODE>info</CODE> should produce a list of manuals which <EM>should include Ciao manual(s) in a separate area</EM> (you may need to log out and back in so that your shell variables are reinitialized for this to work). 

<LI>Opening with a

<A NAME="IDX273"></A>
WWW browser (e.g., 
<A NAME="IDX274"></A>
<CODE>netscape</CODE>) the directory or <CODE>URL</CODE> corresponding to the <CODE>DOCROOT</CODE> setting should show a series of Ciao-related manuals. Note that 
<A NAME="IDX275"></A>
<A NAME="IDX276"></A>
<EM>style sheets</EM> should be activated for correct formatting of the manual. 

<LI>Typing <CODE>man ciao</CODE> should produce a man page with some very basic general information on Ciao (and pointing to the on-line manuals).

<LI>The <CODE>DOCROOT</CODE> directory should contain the manual also in the other formats such as <CODE>postscript</CODE> or <CODE>pdf</CODE> which specially useful for printing. See section <A HREF="ciao_3.html#SEC41">Printing manuals (Un*x)</A> for instructions.

</UL>



<H2><A NAME="SEC33" HREF="ciao_toc.html#TOC33">Un*x user setup</A></H2>

<P>
<A NAME="IDX277"></A>
<A NAME="IDX278"></A>
<A NAME="IDX279"></A>
<A NAME="IDX280"></A>


<P>
If the tests above have succeeded, the system is probably installed correctly and your environment variables have been set already. In that case you can skip to the next section. 


<P>
Otherwise, if you have not already done so, make the following modifications in your startup scripts, so that these files are used (<CODE>&#60;LIBROOT&#62;</CODE> must be replaced with the appropriate value, i.e., where the Ciao library is installed): 


<P>
 

<UL>

<LI>For users a

<A NAME="IDX281"></A>
<A NAME="IDX282"></A>
<EM>csh-compatible shell</EM> (
<A NAME="IDX283"></A>
<CODE>csh</CODE>, 
<A NAME="IDX284"></A>
<CODE>tcsh</CODE>, ...), add to 
<A NAME="IDX285"></A>
<CODE>~/.cshrc</CODE>: 


<PRE>
        if ( -e &#60;LIBROOT&#62;/ciao/DOTcshrc ) then
           source &#60;LIBROOT&#62;/ciao/DOTcshrc
        endif
</PRE>

<A NAME="IDX286"></A>
<CODE>Mac OS X</CODE> users should add (or modify) the 
<A NAME="IDX287"></A>
<CODE>path</CODE> file in the directory <CODE>~/Library/init/tcsh</CODE>, adding the lines shown above. <STRONG>Note:</STRONG> while this is recognized by the terminal shell, and therefore by the text-mode Emacs which comes with Mac OS X, the Aqua native Emacs 21 does not recognize that initialization. It is thus necessary, at this moment, to set manually the Ciao shell (ciaosh) and Ciao library location by hand. This can be done from the Ciao menu within Emacs after a Ciao Prolog file has been loaded. We suppose that the reason is that Mac OS X does not actually consult the per-user initialization files on startup. It should also be possible to put the right initializations in the .emacs file using the <CODE>setenv</CODE> function of Emacs-lisp, as in 


<PRE>
(setenv "CIAOLIB" "&#60;LIBROOT&#62;/ciao")
</PRE>

The same can be done for the rest of the variables initialized in <CODE>&#60;LIBROOT&#62;/ciao/DOTcshrc</CODE> 
 

<LI>For users of an

<A NAME="IDX288"></A>
<A NAME="IDX289"></A>
<EM>sh-compatible shell</EM> (
<A NAME="IDX290"></A>
<CODE>sh</CODE>, 
<A NAME="IDX291"></A>
<CODE>bash</CODE>, ...), add to 
<A NAME="IDX292"></A>
<CODE>~/.profile</CODE>: 


<PRE>
        if [ -f &#60;LIBROOT&#62;/ciao/DOTprofile ]; then
           . &#60;LIBROOT&#62;/ciao/DOTprofile
        fi
</PRE>

This will set up things so that the Ciao executables are found and you can access the Ciao system manuals using the 
<A NAME="IDX293"></A>
<CODE>info</CODE> command. Note that, depending on your shell, <EM>you may have to log out and back in</EM> for the changes to take effect. 

<LI>Also, if you use

<A NAME="IDX294"></A>
<CODE>emacs</CODE> (highly recommended) add this line to your 
<A NAME="IDX295"></A>
<CODE>~/.emacs</CODE> file: 


<PRE>
        (load-file "&#60;LIBROOT&#62;/ciao/DOTemacs.el")
</PRE>

</UL>

<P>
 


<P>
If after following these steps things do not work properly, then the installation was probably not completed properly and you may want to try reinstalling the system. 




<H2><A NAME="SEC34" HREF="ciao_toc.html#TOC34">Using Ciao from a Un*x command shell</A></H2>


<UL>
<LI><A HREF="ciao_3.html#SEC35">Starting/exiting the top-level shell (Un*x)</A>
<LI><A HREF="ciao_3.html#SEC36">Getting help (Un*x)</A>
<LI><A HREF="ciao_3.html#SEC37">Compiling and running programs (Un*x)</A>
<LI><A HREF="ciao_3.html#SEC38">Generating executables (Un*x)</A>
<LI><A HREF="ciao_3.html#SEC39">Running Ciao scripts (Un*x)</A>
<LI><A HREF="ciao_3.html#SEC40">The Ciao initialization file (Un*x)</A>
<LI><A HREF="ciao_3.html#SEC41">Printing manuals (Un*x)</A>
</UL>



<H3><A NAME="SEC35" HREF="ciao_toc.html#TOC35">Starting/exiting the top-level shell (Un*x)</A></H3>

<P>
<A NAME="IDX296"></A>
<A NAME="IDX297"></A>


<P>
The basic methods for starting/exiting the top-level shell have been discussed above. If upon typing <CODE>ciao</CODE> you get a "command not found" error or you get a longer message from Ciao before starting, it means that either Ciao was not installed correctly or you environment variables are not set up properly. Follow the instructions on the message printed by Ciao or refer to the installation instructions regarding user-setup for details. 




<H3><A NAME="SEC36" HREF="ciao_toc.html#TOC36">Getting help (Un*x)</A></H3>

<P>
<A NAME="IDX298"></A>
<A NAME="IDX299"></A>


<P>
The basic methods for accessing the manual on-line have also been discussed above. Use the table of contents and the indices of <EM>predicates</EM>, <EM>libraries</EM>, <EM>concepts</EM>, etc. to find what you are looking for. 
<A NAME="IDX300"></A>
Context-sensitive help is available within the 
<A NAME="IDX301"></A>
<CODE>emacs</CODE> environment (see below). 
 




<H3><A NAME="SEC37" HREF="ciao_toc.html#TOC37">Compiling and running programs (Un*x)</A></H3>

<P>
<A NAME="IDX302"></A>
<A NAME="IDX303"></A>
<A NAME="IDX304"></A>
<A NAME="IDX305"></A>
<A NAME="IDX306"></A>
<A NAME="IDX307"></A>


<P>
Once the shell is started, you can compile and execute Prolog modules inside the interactive top-level shell in the standard way. E.g., type <CODE>use_module(<EM>file</EM>).</CODE>, <CODE>use_module(library(<EM>file</EM>)).</CODE> for library modules, <CODE>ensure_loaded(<EM>file</EM>).</CODE> for files which are not modules, and <CODE>use_package(<EM>file</EM>).</CODE> for library packages (these are syntactic/semantic packages that extend the Ciao Prolog language in many different ways). Note that the use of 
<A NAME="IDX308"></A>
<CODE>compile/1</CODE> and 
<A NAME="IDX309"></A>
<CODE>consult/1</CODE> is discouraged in Ciao. 


<P>
For example, you may want to type <CODE>use_package(iso)</CODE> to ensure Ciao has loaded all the ISO builtins (whether this is done by default or not depends on your 
<A NAME="IDX310"></A>
<CODE>.ciaorc</CODE> file). Do not worry about any "module already in executable" messages --these are normal and simply mean that a certain module is already pre-loaded in the top-level shell. At this point, typing <CODE>write(hello).</CODE> should work. 


<P>
Note that some predicates that may be built-ins in other Prologs are available through libraries in Ciao. This facilitates making small executables. 


<P>
To change the working directory to, say, the <CODE>examples</CODE> directory in the Ciao root directory, first do: 



<PRE>
      ?- use_module(library(system)).
</PRE>

<P>
(loading the 
<A NAME="IDX311"></A>
<CODE>system</CODE> library makes a number of system-related predicates such as 
<A NAME="IDX312"></A>
<CODE>cd/1</CODE> accessible) and then: 



<PRE>
      ?- cd('$/examples').  
</PRE>

<P>
(in Ciao the sequence <CODE>$/</CODE> <EM>at the beginning of a path name</EM> is replaced by the path of the Ciao root directory). 


<P>
For more information see section <A HREF="ciao_7.html#SEC65">The interactive top-level shell</A>. 




<H3><A NAME="SEC38" HREF="ciao_toc.html#TOC38">Generating executables (Un*x)</A></H3>

<P>
<A NAME="IDX313"></A>
<A NAME="IDX314"></A>
<A NAME="IDX315"></A>
<A NAME="IDX316"></A>


<P>
Executables can be generated from the top-level shell (using 
<A NAME="IDX317"></A>
<CODE>make_exec/2</CODE>) or using the standalone compiler (
<A NAME="IDX318"></A>
<CODE>ciaoc</CODE>). To be able to make an executable, the file should define the predicate 
<A NAME="IDX319"></A>
<CODE>main/1</CODE> (or 
<A NAME="IDX320"></A>
<CODE>main/0</CODE>), which will be called upon startup (see the corresponding manual section for details). In its simplest use, given a top-level <EM>foo</EM><CODE>.pl</CODE> file for an application, the compilation process produces an executable <CODE>foo</CODE>, automatically detecting which other files used by <CODE>foo.pl</CODE> need recompilation. 


<P>
For example, within the 
<A NAME="IDX321"></A>
<CODE>examples</CODE> directory, you can type: 



<PRE>
    ?- make_exec(hw,_).
</PRE>

<P>
which should produce an executable. Typing <CODE>hw</CODE> in a shell (or double-clicking on the icon from a graphical window) should execute it. 


<P>
For more information see section <A HREF="ciao_7.html#SEC65">The interactive top-level shell</A> and section <A HREF="ciao_6.html#SEC57">The stand-alone command-line compiler</A>. 




<H3><A NAME="SEC39" HREF="ciao_toc.html#TOC39">Running Ciao scripts (Un*x)</A></H3>

<P>
<A NAME="IDX322"></A>
<A NAME="IDX323"></A>
<A NAME="IDX324"></A>
<A NAME="IDX325"></A>
<A NAME="IDX326"></A>
<A NAME="IDX327"></A>


<P>
Ciao allows writing 
<A NAME="IDX328"></A>
Prolog scripts. These are files containing Prolog source but which get executed without having to explicitly compile them (in the same way as, e.g., <CODE>.bat</CODE> files or programs in scripting languages). As an example, you can run the file 
<A NAME="IDX329"></A>
<CODE>hw</CODE> in the 
<A NAME="IDX330"></A>
<CODE>examples</CODE> directory of the Ciao distribution and look at the source with an editor. You can try changing the <CODE>Hello world</CODE> message and running the program again (no need to recompile!). 


<P>
As you can see, the file should define the predicate 
<A NAME="IDX331"></A>
<CODE>main/1</CODE> (not 
<A NAME="IDX332"></A>
<CODE>main/0</CODE>), which will be called upon startup. The two header lines are necessary in Un*x in. In Windows you can leave them in or you can take them out, but you need to rename the script to 
<A NAME="IDX333"></A>
<CODE>hw.pls</CODE>. Leaving the lines in has the advantage that the script will also work in Un*x without any change. 


<P>
For more information see section <A HREF="ciao_10.html#SEC86">The script interpreter</A>. 




<H3><A NAME="SEC40" HREF="ciao_toc.html#TOC40">The Ciao initialization file (Un*x)</A></H3>

<P>
<A NAME="IDX334"></A>
<A NAME="IDX335"></A>
<A NAME="IDX336"></A>
<A NAME="IDX337"></A>


<P>
The Ciao toplevel can be made to execute upon startup a number of commands (such as, e.g., loading certain files or setting certain Prolog flags) contained in an initialization file. This file should be called 
<A NAME="IDX338"></A>
<CODE>.ciaorc</CODE> and placed in your <EM>home</EM> directory (e.g., <CODE>~</CODE>, the same in which the 
<A NAME="IDX339"></A>
<CODE>.emacs</CODE> file is put). You may need to set the environment variable <CODE>HOME</CODE> to the path of this directory for the Ciao toplevel shell to be able to locate this file on startup. 




<H3><A NAME="SEC41" HREF="ciao_toc.html#TOC41">Printing manuals (Un*x)</A></H3>

<P>
<A NAME="IDX340"></A>
<A NAME="IDX341"></A>
<A NAME="IDX342"></A>
<A NAME="IDX343"></A>


<P>
As mentioned before, the manual is available in several formats in the <CODE>reference</CODE> directory within the <CODE>doc</CODE> directory in the Ciao distribution, including <CODE>postscript</CODE> or <CODE>pdf</CODE>, which are specially useful for printing. These files are also available in the <CODE>DOCROOT</CODE> directory specified during installation. Printing can be done using an application such as 
<A NAME="IDX344"></A>
<CODE>ghostview</CODE> (freely available from <A HREF="http://www.cs.wisc.edu/~ghost/index.html">http://www.cs.wisc.edu/~ghost/index.html</A>) or 
<A NAME="IDX345"></A>
<CODE>acrobat reader</CODE> (<A HREF="http://www.adobe.com">http://www.adobe.com</A>, only <CODE>pdf</CODE>). 
<A NAME="IDX346"></A>
<A NAME="IDX347"></A>
<A NAME="IDX348"></A>
<A NAME="IDX349"></A>
 




<H2><A NAME="SEC42" HREF="ciao_toc.html#TOC42">An introduction to the Ciao emacs environment (Un*x)</A></H2>

<P>
 
<A NAME="IDX350"></A>
<A NAME="IDX351"></A>
While it is easy to use Ciao with any editor of your choice, using it within the 
<A NAME="IDX352"></A>
<CODE>emacs</CODE> editor/program development system is highly recommended: Ciao includes an 
<A NAME="IDX353"></A>
<CODE>emacs</CODE> <EM>mode</EM> which provides a very complete 
<A NAME="IDX354"></A>
<A NAME="IDX355"></A>
<EM>application development environment</EM> which greatly simplifies many program development tasks. See section <A HREF="ciao_12.html#SEC93">Using Ciao inside GNU emacs</A> for details on the capabilities of 
<A NAME="IDX356"></A>
<CODE>ciao</CODE>/
<A NAME="IDX357"></A>
<CODE>emacs</CODE> combination. 


<P>
If the (freely available) 
<A NAME="IDX358"></A>
<CODE>emacs</CODE> editor/environment is not installed in your system, we highly recommend that you also install it at this point (there are instructions for where to find 
<A NAME="IDX359"></A>
<CODE>emacs</CODE> and how to install it in the Ciao installation instructions). After having done this you can try for example the following things: 



<UL>

<LI>A few basic things:

 

<UL>

<LI>Typing <KBD>^H</KBD> <KBD>i</KBD> (or in the menus <CODE>Help-&#62;Manuals-&#62;Browse Manuals with Info</CODE>) should open a list of manuals in info format in which the Ciao manual(s) should appear.

<LI>When opening a Prolog file, i.e., a file with <CODE>.pl</CODE> or <CODE>.pls</CODE> ending, using <KBD>^X</KBD><KBD>^F</KBD><CODE>filename</CODE> (or using the menus) the code should appear highlighted according to syntax (e.g., comments in red), and <CODE>Ciao/Prolog</CODE> menus should appear in the menu bar on top of the

<A NAME="IDX360"></A>
<CODE>emacs</CODE> window. 

<LI>Loading the file using the <CODE>Ciao/Prolog</CODE> menu (or typing <KBD>^C</KBD> <KBD>l</KBD>) should start in another emacs buffer the Ciao toplevel shell and load the file. You should now be able to switch the the toplevel shell and make queries from within

<A NAME="IDX361"></A>
<CODE>emacs</CODE>. 

</UL>

<STRONG>Note:</STRONG> when using 
<A NAME="IDX362"></A>
<CODE>emacs</CODE> it is <EM>very convenient</EM> to swap the locations of the (normally not very useful) <KBD>Caps Lock</KBD> key and the (very useful in 
<A NAME="IDX363"></A>
<CODE>emacs</CODE>) <KBD>Ctrl</KBD> key on the keyboard. How to do this is explained in the 
<A NAME="IDX364"></A>
<CODE>emacs</CODE> frequently asked questions FAQs (see the 
<A NAME="IDX365"></A>
<CODE>emacs</CODE> download instructions for their location). 

(if these things do not work the system or emacs may not be installed properly). 

<LI>You can go to the location of most of the errors that may be reported during compilation by typing <KBD>^C</KBD> <KBD>`</KBD>.

<LI>You can also, e.g., create executables from the <CODE>Ciao/Prolog</CODE> menu, as well as compile individual files, or generate active modules.

<LI>Loading a file for source-level debugging using the <CODE>Ciao/Prolog</CODE> menu (or typing <KBD>^C</KBD> <KBD>d</KBD>) and then issuing a query should start the source-level debugger and move a marker on the code in a window while execution is stepped through in the window running the Ciao top level.

<LI>You can add the lines needed in Un*x for turning any file defining

<A NAME="IDX366"></A>
<CODE>main/1</CODE> into a script from the Ciao/Prolog menu or by typing <KBD>^C</KBD> <KBD>I</KBD> <KBD>S</KBD>. 

<LI>You can also work with the preprocessor and auto-documenter directly from emacs: see their manuals or browse through the corresponding menus that appear when editing <CODE>.pl</CODE> files.

</UL>

<P>
We encourage you once more to read section <A HREF="ciao_12.html#SEC93">Using Ciao inside GNU emacs</A> to discover the many other functionalities of this environment. 




<H2><A NAME="SEC43" HREF="ciao_toc.html#TOC43">Keeping up to date (Un*x)</A></H2>

<P>
You may want to read section <A HREF="ciao_233.html#SEC912">Beyond installation</A> for instructions on how to sign up on the Ciao user's mailing list, receive announcements regarding new versions, download new versions, report bugs, etc. 


<P><HR><P>
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_2.html">previous</A>, <A HREF="ciao_4.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
</BODY>
</HTML>