@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
6 lines • 9.98 kB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>Using Ciao from the command line — The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">☰</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="GettingStarted.html">↑</a><a class="lpdoc-navbutton" href="Install.html">←</a><a class="lpdoc-navbutton" href="EmacsUse.html">→</a><a class="lpdoc-navbutton" href="ciaosearch.html">🔍</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> »<br/> </li><li><a href="GettingStarted.html">Getting started</a> »<br/> </li><li><a href=""><strong>Using Ciao from the command line</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Starting/exiting the top-level shell">Starting/exiting the top-level shell</a></li><li><a href="#Getting help">Getting help</a></li><li><a href="#Compiling and running programs">Compiling and running programs</a></li><li><a href="#Generating executables">Generating executables</a></li><li><a href="#Running Ciao scripts">Running Ciao scripts</a></li><li><a href="#The Ciao initialization file">The Ciao initialization file</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>Using Ciao from the command line</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#CommandLineUse"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Manuel Hermenegildo" href="ciaosearch.html#Manuel Hermenegildo">Manuel Hermenegildo</a>.<p>
<div id="Starting/exiting the top-level shell"><h2>Starting/exiting the top-level shell</h2> <p><a class="lpdoc-idx-anchor" id="0" href="ciaosearch.html#top-level shell, starting"></a> <p>The basic methods for starting/exiting the top-level shell have been discussed before. If upon typing <tt>ciao</tt> 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.<p></div><div id="Getting help"><h2>Getting help</h2> <p><a class="lpdoc-idx-anchor" id="1" href="ciaosearch.html#help"></a> <p>The basic methods for accessing the manual on-line have also been discussed before. 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 class="lpdoc-idx-anchor" id="2" href="ciaosearch.html#Context-sensitive">Context-sensitive</a> help is available within the <a class="lpdoc-idx-anchor" id="3" href="emacs.html"><tt>emacs</tt></a> environment (see below).<p> </div><div id="Compiling and running programs"><h2>Compiling and running programs</h2> <p><a class="lpdoc-idx-anchor" id="4" href="ciaosearch.html#compiling programs"></a> <a class="lpdoc-idx-anchor" id="5" href="ciaosearch.html#loading programs"></a> <a class="lpdoc-idx-anchor" id="6" href="ciaosearch.html#running programs"></a> <p>Once the shell is started, you can compile and execute modules inside the interactive top-level shell in the standard way. E.g., type <tt>use_module(<em>file</em>).</tt>, <tt>use_module(library(<em>file</em>)).</tt> for library modules, <tt>ensure_loaded(<em>file</em>).</tt> for files which are not modules, and <tt>use_package(<em>file</em>).</tt> for library packages (these are syntactic/semantic packages that extend the Ciao language in many different ways). Note that the use of <a class="lpdoc-idx-anchor" id="7" href="toplevel_doc.html#compile/1"><tt>compile/1</tt></a> and <a class="lpdoc-idx-anchor" id="8" href="toplevel_doc.html#consult/1"><tt>consult/1</tt></a> is discouraged in Ciao.<p>For example, you may want to type <tt>use_package(iso_strict)</tt> to ensure Ciao has loaded all the ISO builtins (whether this is done by default or not depends on your <a class="lpdoc-idx-anchor" id="9" href="ciaosearch.html#.ciaorc"><tt>.ciaorc</tt></a> 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 <tt>write(hello).</tt> should work.<p>Note that some predicates that may be built-ins in typical Prolog implementations are available through libraries in Ciao. This facilitates making small executables.<p>To change the working directory to, say, the <tt>examples</tt> directory from the Ciao root directory, first do:<p><pre class="lpdoc-codeblock"> ?- use_module(library(system)).
</pre> <p>(loading the <a class="lpdoc-idx-anchor" id="10" href="system.html"><tt>system</tt></a> library makes a number of system-related predicates such as <a class="lpdoc-idx-anchor" id="11" href="system.html#cd/1"><tt>cd/1</tt></a> accessible) and then:<p><pre class="lpdoc-codeblock"> ?- cd('examples').
</pre> <p>For more information see <a href="toplevel_doc.html">The interactive top-level shell</a>.<p></div><div id="Generating executables"><h2>Generating executables</h2> <p><a class="lpdoc-idx-anchor" id="12" href="ciaosearch.html#executables, generating"></a> <a class="lpdoc-idx-anchor" id="13" href="ciaosearch.html#compiling programs"></a> <p>Executables can be generated from the top-level shell (using <a class="lpdoc-idx-anchor" id="14" href="toplevel_doc.html#make_exec/2"><tt>make_exec/2</tt></a>) or using the standalone compiler (<a class="lpdoc-idx-anchor" id="15" href="ciaosearch.html#ciaoc"><tt>ciaoc</tt></a>). To be able to make an executable, the file should define the predicate <a class="lpdoc-idx-anchor" id="16" href="ciaosearch.html#main/1"><tt>main/1</tt></a> (or <a class="lpdoc-idx-anchor" id="17" href="ciaosearch.html#main/0"><tt>main/0</tt></a>), which will be called upon startup (see the corresponding manual section for details). In its simplest use, given a top-level <em>foo</em><tt>.pl</tt> file for an application, the compilation process produces an executable <tt>foo</tt>, automatically detecting which other files used by <tt>foo.pl</tt> need recompilation.<p>For example, within the <a class="lpdoc-idx-anchor" id="18" href="ciaosearch.html#examples"><tt>examples</tt></a> directory, you can type:<p><pre class="lpdoc-codeblock"> ?- make_exec(hw,_).
</pre> <p>which should produce an executable. Typing <tt>hw</tt> in a shell (or double-clicking on the icon from a graphical window) should execute it.<p><p>For more information see <a href="toplevel_doc.html">The interactive top-level shell</a> and <a href="ciaoc.html">The standalone command-line compiler</a>.<p></div><div id="Running Ciao scripts"><h2>Running Ciao scripts</h2> <p><a class="lpdoc-idx-anchor" id="19" href="ciaosearch.html#scripts"></a> <a class="lpdoc-idx-anchor" id="20" href="ciaosearch.html#compiling programs"></a> <a class="lpdoc-idx-anchor" id="21" href="ciaosearch.html#running programs"></a> <p>Ciao allows writing <a class="lpdoc-idx-anchor" id="22" href="ciaosearch.html#scripts">scripts</a>. These are files containing Ciao source but which get executed without having to explicitly compile them (in the same way as, e.g., <tt>.bat</tt> files or programs in scripting languages). As an example, you can run the file <a class="lpdoc-idx-anchor" id="23" href="ciaosearch.html#hw"><tt>hw</tt></a> in the <a class="lpdoc-idx-anchor" id="24" href="ciaosearch.html#examples"><tt>examples</tt></a> directory of the Ciao distribution and look at the source with an editor. You can try changing the <tt>Hello world</tt> message and running the program again (no need to recompile!).<p>As you can see, the file should define the predicate <a class="lpdoc-idx-anchor" id="25" href="ciaosearch.html#main/1"><tt>main/1</tt></a> (not <a class="lpdoc-idx-anchor" id="26" href="ciaosearch.html#main/0"><tt>main/0</tt></a>), which will be called upon startup. The two header lines are necessary in Unix in. In Windows you can leave them in or you can take them out, but you need to rename the script to <a class="lpdoc-idx-anchor" id="27" href="ciaosearch.html#hw.pls"><tt>hw.pls</tt></a>. Leaving the lines in has the advantage that the script will also work in Unix without any change.<p>For more information see <a href="ciao-shell.html">The script interpreter</a>.<p></div><div id="The Ciao initialization file"><h2>The Ciao initialization file</h2> <p><a class="lpdoc-idx-anchor" id="28" href="ciaosearch.html#.ciaorc"></a> <a class="lpdoc-idx-anchor" id="29" href="ciaosearch.html#initialization file"></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 Ciao flags) contained in an initialization file. This file should be called <a class="lpdoc-idx-anchor" id="30" href="ciaosearch.html#.ciaorc"><tt>.ciaorc</tt></a> and placed in your <em>home</em> directory (e.g., <tt>~</tt>, the same in which the <a class="lpdoc-idx-anchor" id="31" href="ciaosearch.html#.emacs"><tt>.emacs</tt></a> file is put). You may need to set the environment variable <tt>HOME</tt> to the path of this directory for the Ciao toplevel shell to be able to locate this file on startup. </div><br/></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>