* more documentation.

This commit is contained in:
Abdulaziz Ghuloum 2007-10-22 16:47:51 -04:00
parent 3cca074ca2
commit d23267745e
1 changed files with 266 additions and 69 deletions

View File

@ -3,13 +3,16 @@
\usepackage{fontspec} \usepackage{fontspec}
\defaultfontfeatures{Scale=MatchLowercase} \defaultfontfeatures{Scale=MatchLowercase}
\setmainfont[Mapping=tex-text]{Cochin} %\setmainfont[Mapping=tex-text]{Cochin}
%\setmainfont[Mapping=tex-text]{Palatino} %\setmainfont[Mapping=tex-text]{Palatino}
%\setmainfont[Mapping=tex-text]{Baskerville}
\setmainfont[Mapping=tex-text]{Perpetua}
\setsansfont[Mapping=tex-text]{Geneva} \setsansfont[Mapping=tex-text]{Geneva}
\setmonofont{Monaco} \setmonofont{Monaco}
\usepackage{fancyhdr} \usepackage{fancyhdr}
\usepackage{makeidx} \usepackage{makeidx}
\usepackage{fancyvrb}
\makeindex \makeindex
\usepackage[dvipdfm,CJKbookmarks,bookmarks=true,bookmarksopen=true]{hyperref} \usepackage[dvipdfm,CJKbookmarks,bookmarks=true,bookmarksopen=true]{hyperref}
@ -30,7 +33,6 @@
\usepackage{rotating} \usepackage{rotating}
\usepackage{multicol,ragged2e} \usepackage{multicol,ragged2e}
%\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}} \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{} \fancyhf{}
@ -60,6 +62,8 @@
\newcommand{\testfile}[2]{\texttt{tests-{\ref{#1}}-{#2}.ss}} \newcommand{\testfile}[2]{\texttt{tests-{\ref{#1}}-{#2}.ss}}
\newcommand{\idxtt}[1]{\index{#1 @ \texttt{#1}}\texttt{#1}}
\newenvironment{Language} \newenvironment{Language}
{ {
\begin{center} \begin{center}
@ -73,6 +77,19 @@
\end{center} \end{center}
} }
\DefineVerbatimEnvironment{CodeInline}{Verbatim}
{gobble=0, xleftmargin=2em, xrightmargin=0em,
%numbers=left, numbersep=2mm,
frame=lines ,framerule=1pt}
\DefineVerbatimEnvironment{CodeInlineIdx}{Verbatim}
{gobble=0, xleftmargin=3em, xrightmargin=0em,
numbers=left, numbersep=1ex,
frame=lines ,framerule=1pt}
\begin{document} \begin{document}
@ -97,7 +114,10 @@ Ikarus Scheme User's Guide
{\fontsize{18}{18} {\fontsize{18}{18}
\fontspec{Hoefler Text Italic} \fontspec{Hoefler Text Italic}
\hfill{} \hfill{}
Volume 1: Quick Start (Preliminary Document) % Quick Start\\
% \rnrs{6} Crash Course\\
% Ikarus
(Preliminary Document)
} }
\vfill \vfill
{ {
@ -117,7 +137,7 @@ Volume 1: Quick Start (Preliminary Document)
\vfill{} \vfill{}
\noindent \noindent
Ikarus Scheme User's Guide\\ Ikarus Scheme User's Guide\\
Volume 1: Quick Start (Preliminary Document)\\ %Volume 1: Quick Start (Preliminary Document)\\
Copyright \copyright{} 2007, Abdulaziz Ghuloum\\ Copyright \copyright{} 2007, Abdulaziz Ghuloum\\
\noindent \noindent
@ -179,6 +199,8 @@ interpreters and compilers, and many mathematical and scientific
packages. It is our hope that this release will encourage the packages. It is our hope that this release will encourage the
Scheme community to write and to share their most useful \rnrs{6} Scheme community to write and to share their most useful \rnrs{6}
libraries. libraries.
\newpage \newpage
\section{Technology Overview} \section{Technology Overview}
@ -411,7 +433,9 @@ of the boot file using the following strategy:
\begin{enumerate} \begin{enumerate}
\item If \texttt{ikarus} was started by supplying an explicit \item If \texttt{ikarus} was started by supplying an explicit
location (e.g. \texttt{/usr/local/bin/ikarus} or \texttt{./ikarus}), location such as
\texttt{/usr/local/bin/ikarus} or
\texttt{./ikarus},
then the name of the boot file is the concatenation of a then the name of the boot file is the concatenation of a
\texttt{.boot} prefix to the executable file name (e.g. \texttt{.boot} prefix to the executable file name (e.g.
\texttt{/usr/local/bin/ikarus.boot} or \texttt{./ikarus.boot}). \texttt{/usr/local/bin/ikarus.boot} or \texttt{./ikarus.boot}).
@ -420,8 +444,8 @@ then the name of the boot file is the concatenation of a
location in the \texttt{PATH} environment variable. In that case, location in the \texttt{PATH} environment variable. In that case,
it searches for the location of \texttt{ikarus} in the it searches for the location of \texttt{ikarus} in the
\texttt{PATH}. If \texttt{ikarus} is found in \texttt{PATH}. If \texttt{ikarus} is found in
\texttt{/some/location/ikarus}, then the name of the boot file \texttt{/path/to/ikarus}, then the name of the boot file
becomes \texttt{/some/location/ikarus.boot}. becomes \texttt{/path/to/ikarus.boot}.
\item Failing both guesses, \texttt{ikarus} prints an error message \item Failing both guesses, \texttt{ikarus} prints an error message
and exits. and exits.
@ -442,13 +466,13 @@ boot file is loaded.
\item \texttt{ikarus --r6rs-script script-file-name [arguments ...]} \item \texttt{ikarus --r6rs-script script-file-name [arguments ...]}
\index{\rnrs{6} Script} The \texttt{--r6rs-script} argument \index{R6RS Script@\rnrs{6} Script} The \texttt{--r6rs-script} argument
instructs Ikarus that the supplied file is an \rnrs{6} script. See instructs Ikarus that the supplied file is an \rnrs{6} script. See
Section~\ref{sec:scripts} for a short introduction to writing \rnrs{6} Section~\ref{sec:scripts} for a short introduction to writing \rnrs{6}
scripts. The script file name and any additional optional scripts. The script file name and any additional optional
\texttt{arguments} \texttt{arguments}
can be obtained by calling the can be obtained by calling the
\index{\texttt{command-line}}\texttt{command-line} procedure. \idxtt{command-line} procedure.
\begin{verbatim} \begin{verbatim}
$ cat test.ss $ cat test.ss
@ -482,106 +506,279 @@ subsystems in the future.}
\end{itemize} \end{itemize}
\section{Executable Scripts}
FIXME
\newpage \subsection{Mac OS X}
FIXME
\subsection{GNU/Linux}
FIXME
\subsection{Windows/Cygwin}
FIXME
\chapter{\rnrs{6} Crash Course} \chapter{\rnrs{6} Crash Course}
* Describe major differences between r6 and r5 The major difference between \rnrs{5} and \rnrs{6} is the way
in which programs are loaded and evaluated.
* Explain what a top-level program is In \rnrs{5}, Scheme implementations typically start as an
interactive session (often referred to as the REPL, or
read-eval-print-loop). Inside the interactive session, the user
enters definitions and expressions one at a time using the keyboard.
Files, which also contain definitions and expressions, can be loaded
and reloaded by calling the \texttt{load} procedure. The
environment in which the interactive session starts often contains
implementation-specific bindings that are not found \rnrs{5} and
users may redefine any of the initial bindings. The semantics of a
loading a file depends on the state of the environment at the time
the file contents are evaluated.
* Explain what a library is \index{R6RS Script@\rnrs{6} Script!Import}
\rnrs{6} differs from \rnrs{5} in that it specifies how \emph{whole
* Explain what the standard R6RS libraries are programs}, or scripts, are compiled and evaluated. An \rnrs{6}
script is closed in the sense that all the identifiers found in the
body of the script must either be defined in the script or imported
from a library. \rnrs{6} also specifies how \emph{libraries} can be
defined and used. While files in \rnrs{5} are \emph{loaded}
imperatively into the top-level environments, \rnrs{6} libraries can
be \emph{imported} declaratively in scripts and in other \rnrs{6}
libraries.
\section{\label{sec:scripts}Writing a simple script} \section{\label{sec:scripts}Writing a simple script}
* Hello World example An \rnrs{6} script is a set of definitions and expressions preceeded
by an \texttt{import} form. The \texttt{import} form specifies
the language (i.e. the variable and keyword bindings) in which the
library body is written. A very simple example of an \rnrs{6}
script is listed below.
* Definitions (procedures) \index{Examples!Hello World@\textit{Hello World}}
\begin{CodeInline}
(import (rnrs))
(display "Hello World!\n")
\end{CodeInline}
The first line imports the \texttt{(rnrs)} library. All the
bindings exported from the \texttt{(rnrs)} library are made
available to be used within the body of the library.
The exports of the \texttt{(rnrs)} library include variables
(e.g. \texttt{cons}, \texttt{car}, \texttt{display}, etc.) and
keywords (e.g. \texttt{define}, \texttt{lambda}, \texttt{quote},
etc.). The second line displays the string \texttt{Hello World!}
followed by a new line character.
In addition to expressions, such as the call to \texttt{display} in
the previous example, a script may define some variables. The
script below defines the variable \texttt{greeting} and calls the
procedure bound to it.
\begin{CodeInline}
(import (rnrs))
(define greeting
(lambda ()
(display "Hello World!\n")))
(greeting)
\end{CodeInline}
Additional keywords may be defined within a script. In the example
below, we define the \texttt{(do-times n exprs ...)} macro that
evaluates the expressions \texttt{exprs} \texttt{n} times. Running
the script displays \texttt{Hello World} 3 times.
\newpage
\begin{CodeInline}
(import (rnrs))
(define greeting
(lambda ()
(display "Hello World!\n")))
(define-syntax do-times
(syntax-rules ()
[(_ n exprs ...)
(let f ([i n])
(unless (zero? i)
exprs ...
(f (- i 1))))]))
(do-times 3 (greeting))
\end{CodeInline}
* Simple macros.
\section{Writing simple libraries} \section{Writing simple libraries}
\section{\rnrs{6} Standard Libraries} A script is intended to be a small piece of the program---useful
abstractions belong to libraries. The \texttt{do-times} macro that
was defined in the previous section may be useful in places other
than printing greeting messages. So, we can create a small library,
\texttt{(iterations)} that contains common iteration forms.
\subsection{\texttt{(rnrs (6))}} An \rnrs{6} library form is made of four essential parts: (1) the
a library name, (2) the set of identifiers that the library exports,
\subsection{\texttt{(rnrs arithmetic bitwise (6))}} (3) the set of libraries that the library imports, and (4) the body
a of the library.
\subsection{\texttt{(rnrs arithmetic fixnums (6))}}
a
\subsection{\texttt{(rnrs arithmetic flonums (6))}} The library name can be any non-empty list of identifiers.
a \rnrs{6}-defined libraries includes \texttt{(rnrs)},
\subsection{\texttt{(rnrs bytevectors (6))}} \texttt{(rnrs~unicode)}, \texttt{(rnrs~bytevectors)}, and so on.
a
\subsection{\texttt{(rnrs conditions (6))}} The library exports are a set of identifiers that are made available
a to importing libraries. Every exported identifier must be bound: it
\subsection{\texttt{(rnrs control (6))}} may either be defined in the libraries or imported from another
a library.
\subsection{\texttt{(rnrs enums (6))}} %\emph{re-exported} identifiers}.
a Library exports include variables, keywords, record names, condition
\subsection{\texttt{(rnrs exceptions (6))}} names.
a
\subsection{\texttt{(rnrs files (6))}} Library imports are similar to script imports: they specify the set
a of libraries whose exports are made visible within the body of the
\subsection{\texttt{(rnrs hashtables (6))}} library.
\index{Invoke}
The body of a library contains definitions (variable, keyword,
record, condition, etc.) followed by an optional set of expressions.
The expressions are evaluated for side effect when needed.
The \texttt{(iteration)} library may be written as follows:
\begin{CodeInline}
(library (iteration)
(export do-times)
(import (rnrs))
(define-syntax do-times
(syntax-rules ()
[(_ n exprs ...)
(let f ([i n])
(unless (zero? i)
exprs ...
(f (- i 1))))])))
\end{CodeInline}
To use the \texttt{(iteration)} library in our script, we add the
name of the library to the script's \texttt{import} form. This
makes all of \texttt{(iteration)}'s exported identifiers, e.g.
\texttt{do-times}, visible in the body of the script.
\begin{CodeInline}
(import (rnrs) (iteration))
(define greeting
(lambda ()
(display "Hello World!\n")))
(do-times 3 (greeting))
\end{CodeInline}
% \begin{CodeInline}
% (library (iteration)
% (export do-times)
% (import (rnrs))
% (define-syntax do-times
% (syntax-rules ()
% [(_ n exprs ...)
% (do-times-proc n (lambda () exprs ...))]))
% (define do-times-proc
% (lambda (n proc)
% (unless (zero? n)
% (proc)
% (do-times-proc (- n 1) proc)))))
% \end{CodeInline}
\chapter{\rnrs{6} Standard Libraries}
\newpage
\section{\texttt{(rnrs)}}
\newpage
\section{\texttt{(rnrs base)}}
\newpage
\section{\texttt{(rnrs arithmetic bitwise)}}
\newpage
\section{\texttt{(rnrs arithmetic fixnums)}}
\newpage
\section{\texttt{(rnrs arithmetic flonums)}}
\newpage
\section{\texttt{(rnrs bytevectors)}}
\newpage
\section{\texttt{(rnrs conditions)}}
\newpage
\section{\texttt{(rnrs control)}}
\newpage
\section{\texttt{(rnrs enums)}}
\newpage
\section{\texttt{(rnrs exceptions)}}
\newpage
\section{\texttt{(rnrs files)}}
\newpage
\section{\texttt{(rnrs hashtables)}}
\cite{ghuloum07hashtables} \cite{ghuloum07hashtables}
\newpage
\subsection{\texttt{(rnrs io ports (6))}} \section{\texttt{(rnrs io ports)}}
a \newpage
\subsection{\texttt{(rnrs io simple (6))}} \section{\texttt{(rnrs io simple)}}
a \newpage
\subsection{\texttt{(rnrs lists (6))}} \section{\texttt{(rnrs lists)}}
a \newpage
\subsection{\texttt{(rnrs mutable-pairs (6))}} \section{\texttt{(rnrs mutable-pairs)}}
a \newpage
\subsection{\texttt{(rnrs mutable-strings (6))}} \section{\texttt{(rnrs mutable-strings)}}
a \newpage
\subsection{\texttt{(rnrs programs (6))}} \section{\texttt{(rnrs programs)}}
a \newpage
\subsection{\texttt{(rnrs r5rs (6))}} \section{\texttt{(rnrs r5rs)}}
a \newpage
\subsection{\texttt{(rnrs records inspection (6))}} \section{\texttt{(rnrs records inspection)}}
a \newpage
\subsection{\texttt{(rnrs records procedural (6))}} \section{\texttt{(rnrs records procedural)}}
a \newpage
\subsection{\texttt{(rnrs records syntactic (6))}} \section{\texttt{(rnrs records syntactic)}}
a \newpage
\subsection{\texttt{(rnrs sorting (6))}} \section{\texttt{(rnrs sorting)}}
a \newpage
\subsection{\texttt{(rnrs syntax-case (6))}} \section{\texttt{(rnrs syntax-case)}}
a \newpage
\subsection{\texttt{(rnrs unicode (6))}} \section{\texttt{(rnrs unicode)}}
a \newpage
\chapter{Ikarus's Built-in Libraries} \chapter{Ikarus Library Collection}
* list all ikarus libraries. * list all ikarus libraries.
* explain each of the exports. * explain each of the exports.
\newpage
\section{\label{lib:ikarus}\texttt{(ikarus)}} \section{\label{lib:ikarus}\texttt{(ikarus)}}
\newpage
\section{\texttt{(ikarus files)}} \section{\texttt{(ikarus files)}}
\newpage
\section{\texttt{(ikarus parameters)}} \section{\texttt{(ikarus parameters)}}
\newpage
\section{\texttt{(ikarus posix)}} \section{\texttt{(ikarus posix)}}
\newpage
\section{\texttt{(ikarus printing)}} \section{\texttt{(ikarus printing)}}
\newpage
\section{\texttt{(ikarus symbols)}} \section{\texttt{(ikarus symbols)}}
\newpage
\section{\texttt{(ikarus timers)}} \section{\texttt{(ikarus timers)}}
\newpage
\section{\texttt{(ikarus tracing)}} \section{\texttt{(ikarus tracing)}}
\newpage
\section{\texttt{(ikarus unicode)}} \section{\texttt{(ikarus unicode)}}
\newpage
\section{\texttt{(ikarus guardians)}} \section{\texttt{(ikarus guardians)}}
\cite{dybvig93guardians} \cite{dybvig93guardians}
\newpage
\section{\texttt{(ikarus weak-pairs)}} \section{\texttt{(ikarus weak-pairs)}}
\newpage
\section{\texttt{(ikarus modules)}} \section{\texttt{(ikarus modules)}}
\newpage
\section{\texttt{(ikarus library-manager)}} \section{\texttt{(ikarus library-manager)}}
\newpage
% \chapter{Additional Libraries} % \chapter{Additional Libraries}
% %