Commit of 3.99.0 version
This commit is contained in:
+101
-263
@@ -1,280 +1,118 @@
|
||||
%
|
||||
% STk Reference manual (Appendix: Miscellaneous Informations)
|
||||
% STk Reference manual (Appendix: Modules)
|
||||
%
|
||||
% Author: Erick Gallesio [eg@unice.fr]
|
||||
% Creation date: 21-Dec-1994 12:05
|
||||
% Last file update: 8-Jul-1996 22:18
|
||||
% Creation date: 6-Apr-1998 11:19
|
||||
% Last file update: 8-Apr-1998 10:10
|
||||
%
|
||||
|
||||
\section{Introduction}
|
||||
This appendix list a number of things which cannot go elsewhere in this
|
||||
document. The only link between the items listed her is that they should
|
||||
ease your life when using {\stk}.
|
||||
|
||||
\section{About \stk}
|
||||
|
||||
\subsection{Last release}
|
||||
|
||||
{\stk} distribution is available on various sites. The original distribution
|
||||
site is {\tt kaolin.unice.fr} {\tt (193.48.229.225)}. Files are available
|
||||
through anonymous ftp and are located in the {\tt /pub}
|
||||
directory. Distribution file names have the form {\tt STk-x.y.tar.gz}, where {\tt
|
||||
x} and {\tt y} represent the version and the release of the package. You can
|
||||
also find interim releases of {\stk}. Interim releases are stored in file
|
||||
whose name have the form {\tt STk-x.y.z.tar.gz} where {\tt z} is the interim
|
||||
release number.
|
||||
|
||||
David Fox maintains a mirror site of {\tt kaolin.unice.fr}. This site is
|
||||
located in the USA and is available at the following URL:
|
||||
{\tt ftp://cs.nyu.edu/pub/local/fox/stk}.
|
||||
|
||||
\subsection{Sharing Code}
|
||||
|
||||
If you have written code that you want to share with the (small) {\stk}
|
||||
community, you can deposit it in the directory {\tt /pub/Incoming} of {\tt
|
||||
kaolin.unice.fr}. Mail me a small note when you deposit a file in this
|
||||
directory so I can put in in its definitive place ({\tt /pub/Contrib}
|
||||
directory contains the contributed code).
|
||||
|
||||
\subsection{{\stk} Mailing list}
|
||||
|
||||
There is a mailing list for {\stk} located on {\tt kaolin.unice.fr}. The
|
||||
intent of this mailing list is to permit to {\stk} users to share experiences,
|
||||
expose problems, submit ideas and \ldots everything which you find interesting
|
||||
(and which is related to \stk).
|
||||
|
||||
To subscribe to the mailing list, simply send a message with the word {\tt
|
||||
subscribe} in the {\tt Subject:} field of you mail. Mail must be sent to the
|
||||
following address: {\tt stk-request@kaolin.unice.fr}
|
||||
|
||||
To unsubscribe from the mailing list, send a mail at previous email address with the word {\tt unsubscribe} in the {\tt Subject:} field.
|
||||
|
||||
For more information on the mailing list management send a message with the
|
||||
word {\tt help} in the {\tt Subject:} field of your mail. In particular, it
|
||||
is possible to find all the messages which have already been sent on the {\stk}
|
||||
mailing list.
|
||||
|
||||
Subscription/un-subscription/information requests are processed
|
||||
automatically without human intervention. If you something goes wrong, send a
|
||||
mail to {\tt eg@unice.fr}.
|
||||
|
||||
Once you have properly subscribe to the mailing list,
|
||||
\begin{itemize}
|
||||
\item you can send your messages about {\stk} to {\tt stk@kaolin.unice.fr},
|
||||
\item you will receive all the messages of the mailing list to the email
|
||||
address you used when you subscribed to the list.
|
||||
\end{itemize}
|
||||
|
||||
\subsection{{\stk} FAQ}
|
||||
|
||||
Marc Furrer has set up a FAQ{\index{FAQ} for {\stk}.
|
||||
This FAQ is regularly posted on the {\stk} mailing list. It can
|
||||
also be accessed through {\tt
|
||||
http://ltiwww.epfl.ch/~furrer/STk/FAQ.html}. ASCII version of the FAQ is
|
||||
available from {\tt http://ltiwww.epfl.ch/~furrer/STk/FAQ.txt}.
|
||||
|
||||
\subsection{Reporting a bug}
|
||||
|
||||
When you find a bug in {\stk}, please send its description to the following
|
||||
address {\tt stk-bugs@kaolin.unice.fr}. Don't forget to indicate the version
|
||||
you use and the architecture the system is compiled on. {\stk} version and
|
||||
architecture can be found by using the {\tt version} and {\tt machine-type}
|
||||
Scheme primitives. If possible, try to find a small program which exhibit the bug.
|
||||
|
||||
\section{{\stk} and Emacs}
|
||||
|
||||
The Emacs family editors\index{Emacs editor} can be customized to ease
|
||||
viewing and editing programs of a particular sort. Hints given below
|
||||
enable a fine ``integration'' of {\stk} in Emacs.
|
||||
|
||||
\subsection*{Automatic scheme-mode setting}
|
||||
|
||||
Emacs mode can be chosen automatically on the file's name. To edit file
|
||||
ended by {\tt .stk }or {\tt .stklos} in Scheme mode, you have to set the
|
||||
Elisp variable {\tt auto-mode-alist} to control the correspondence between
|
||||
those suffixes and the scheme mode. The simpler way to set this variable
|
||||
consists to add the following lines in your .{\tt emacs} startup file.
|
||||
This appendix shows some usages of the {\stk} modules. Most of the
|
||||
examples which are exhibited here are derived from the Tung and Dybvig paper
|
||||
\cite{Tung-Dybvig-96}.
|
||||
|
||||
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
;; Add the '.stk' and '.stklos' suffix in the auto-mode-alist Emacs
|
||||
;; variable. Setting this variable permits to automagically place the
|
||||
;; buffer in scheme-mode.
|
||||
(setq-default auto-mode-alist (append auto-mode-alist
|
||||
("\\.stk$" . scheme-mode)
|
||||
("\\.stklos$" . scheme-mode)))
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
\subsection*{Interactive Redefinition}
|
||||
|
||||
\subsection*{Using Emacs and {\em CMU Scheme}}
|
||||
Consider first the definitions,
|
||||
\begin{scheme}
|
||||
(define-module A
|
||||
(export square)
|
||||
(define square
|
||||
(lambda (x) (+ x x))))
|
||||
|
||||
{\em CMU Scheme} package\index{CMU Scheme} package} permits to run the {\stk} interpreter in an Emacs
|
||||
window. Once the package is loaded, you can send text to the inferior
|
||||
{\stk} interpreter from other buffers containing Scheme source.
|
||||
The {\em CMU Scheme} package is distributed with Emacs (both FSF-Emacs and
|
||||
Xemacs) and you should have it if you are running this editor.
|
||||
(define-module B
|
||||
(import A)
|
||||
(define distance
|
||||
(lambda (x y)
|
||||
(sqrt (+ (square x) (square y))))))
|
||||
\end{scheme}
|
||||
Obviously, the \texttt{square} function exported from \texttt{A} is
|
||||
incorrect, as we can see in its usage below:
|
||||
\begin{scheme}
|
||||
(with-module B (round (distance 3 4))) \lev 4.0
|
||||
\end{scheme}
|
||||
|
||||
To use the {\em CMU Scheme} package with {\stk}, place the following lines in
|
||||
your {\tt .emacs} startup file.
|
||||
The function can be redefined (\textit{corrected}) by the following expression:
|
||||
\begin{scheme}
|
||||
(with-module A
|
||||
(set! square
|
||||
(lambda (x) (* x x))))
|
||||
\end{scheme}
|
||||
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
;; Use cmu-scheme rather than xscheme which is launched by default
|
||||
;; whence running 'run-scheme' (xscheme is wired with CScheme)
|
||||
(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme" t)
|
||||
(setq scheme-program-name "stk")
|
||||
(setq inferior-scheme-mode-hook '(lambda() (split-window)))
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
And now,
|
||||
\begin{scheme}
|
||||
(with-module B (round (distance 3 4))) \lev 5
|
||||
\end{scheme}
|
||||
|
||||
which is correct.
|
||||
|
||||
\subsection*{Lexical principle}
|
||||
|
||||
This example reuses the modules \texttt{A} and \texttt{B} of previous
|
||||
section and adds a \texttt{Compare} module that exports the
|
||||
\texttt{less-than-4?} predicates, which states if the distance from a
|
||||
point to the origin is less than 4.
|
||||
|
||||
\begin{scheme}
|
||||
(define-module A
|
||||
(export square)
|
||||
(define square (lambda (x) (* x x))))
|
||||
|
||||
(define-module B
|
||||
(import A)
|
||||
(export distance)
|
||||
|
||||
(define distance
|
||||
(lambda (x y) (sqrt (+ (square x) (square y))))))
|
||||
|
||||
(define-module Compare
|
||||
(import B)
|
||||
(define less-than-4? (lambda (x y) (< (distance x y) 4)))
|
||||
(define square (lambda (x) (+ x x))))
|
||||
\end{scheme}
|
||||
|
||||
Consider now the call,
|
||||
\begin{scheme}
|
||||
(with-module compare (less-than-4? 3 4)) \lev \schfalse
|
||||
\end{scheme}
|
||||
|
||||
The call to \texttt{distance} done from \texttt{less-than-4?}
|
||||
indirectly calls the \texttt{square} procedure of module \texttt{A} rather than
|
||||
the one defined locally in module \texttt{Compare}.
|
||||
|
||||
|
||||
After having entered those lines in your {\tt .emacs} file, you can simply
|
||||
run the {\stk} interpreter by typing
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
M-x run-scheme
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
\subsection*{Mutually Referential Modules}
|
||||
This example uses two mutually referential modules taht import and
|
||||
export to each other to implement mutually recursive even? and odd?
|
||||
procedures
|
||||
|
||||
\begin{scheme}
|
||||
(define-module Odd) ;; Forward declaration
|
||||
|
||||
(define-module Even
|
||||
(import Odd)
|
||||
(export even?)
|
||||
(define even? (lambda (x) (if (zero? x) \schtrue (odd? (- x 1))))))
|
||||
|
||||
(define-module Odd
|
||||
(import Even)
|
||||
(export odd?)
|
||||
(define odd? (lambda (x) (if (zero? x) \schfalse (even? (- x 1))))))
|
||||
\end{scheme}
|
||||
|
||||
Hereafter are some usages of theses procedures:
|
||||
\begin{scheme}
|
||||
(with-module Odd (odd? 3)) \lev \schtrue
|
||||
(with-module Odd (odd? 10)) \lev \schfalse
|
||||
|
||||
(with-module Even (even? 3)) \lev \schfalse
|
||||
(with-module Even (even? 10)) \lev \schtrue
|
||||
\end{scheme}
|
||||
|
||||
|
||||
Read the {\em CMU Scheme} documentation (or use the describe-mode Elisp command)
|
||||
for a complete description of this package.
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master:"manual"
|
||||
%%% End:
|
||||
|
||||
\subsection*{Using Emacs and the {\em Ilisp} package}
|
||||
|
||||
{\em Ilisp}\index{Ilisp package} is another scheme package which allows to
|
||||
run the {\stk} interpreter in an Emacs window. This is a rich package with
|
||||
a lot of nice features. {\em Ilisp} comes pre-installed with Xemacs; it
|
||||
has to be installed with FSF Emacs (the last version of {\em Ilisp} can be
|
||||
ftp'ed anonymously from {\tt ftp.cs.cmu.edu} (128.2.206.173) in the {\tt
|
||||
/user/ai/lang/lisp/util/emacs/ilisp} directory).
|
||||
|
||||
To use the {\em Ilisp} package with {\stk}, place the following lines in
|
||||
your {\tt .emacs} startup file.
|
||||
|
||||
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
(autoload 'run-ilisp "ilisp" "Select a new inferior LISP." t)
|
||||
(autoload 'stk "ilisp" "Run stk in ILISP." t)
|
||||
(add-hook 'ilisp-load-hook
|
||||
'(lambda ()
|
||||
(require 'completer)
|
||||
|
||||
;; Define STk dialect characteristics
|
||||
(defdialect stk "STk Scheme"
|
||||
scheme
|
||||
(setq comint-prompt-regexp "^STk> ")
|
||||
(setq ilisp-program "stk -interactive")
|
||||
(setq comint-ptyp t)
|
||||
(setq comint-always-scroll t)
|
||||
(setq ilisp-last-command "*"))))
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
|
||||
|
||||
After having entered those lines in your {\tt .emacs} file, you can simply
|
||||
run the {\stk} interpreter by typing
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
M-x stk
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
|
||||
|
||||
The Ilisp package comes with a rich documentation which describe how to
|
||||
customize the package.
|
||||
|
||||
\subsection*{Other packages}
|
||||
|
||||
Another way to use {\stk} and Emacs consists to use a special purpose
|
||||
{\stk} mode. You can find two such modes in the {\tt /pub/Contrib}
|
||||
directory of {\tt kaolin.unice.fr}.
|
||||
|
||||
\subsection {Using the SLIB package with \stk}
|
||||
|
||||
Aubrey Jaffer maintains a package called {\em SLIB}\index{SLIB package}
|
||||
which is a portable Scheme library which provides compatibility and utility
|
||||
functions for all standard Scheme implementations. To use this package, you
|
||||
have just to type
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
(require "slib")
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
and follow the instructions given in the {\em SLIB} library to use a
|
||||
particular package.
|
||||
\begin{note}
|
||||
{\em SLIB} uses also the {\em require/provide} mechanism to load components
|
||||
of the library. Once {\em SLIB} has been loaded, the standard {\stk}
|
||||
{\tt require}\schindex{require} and {\tt provide}\schindex{provide}
|
||||
are overloaded such as if their parameter
|
||||
is a string this is the old {\stk} procedure which is called, and if their
|
||||
parameter is a symbol, this is the {\em SLIB} one which is called.
|
||||
\end{note}
|
||||
|
||||
\section{Getting information about Scheme}
|
||||
|
||||
\subsection{The {\rrrr} document}
|
||||
|
||||
{\rrrr}{\index{R4RS}} is the document which fully describe the Scheme
|
||||
Programming Language, it can be found in the Scheme repository
|
||||
(see~\ref{scheme-repository}) in the directory:
|
||||
\begin{quote}
|
||||
{\tt ftp.cs.indiana.edu:/pub/scheme-repository/doc}
|
||||
\end{quote}
|
||||
|
||||
Aubrey Jaffer has also translated this document in HTML. A version of this
|
||||
document is available at
|
||||
\begin{quote}
|
||||
{\tt file://swiss-ftp.ai.mit.edu/pub/scm/HTML/r4rs\_toc.html}
|
||||
\end{quote}
|
||||
|
||||
\subsection{The Scheme Repository}
|
||||
|
||||
The main site where you can find (many) informations about Scheme is
|
||||
located in the University of Indiana. The Scheme repository\index{Scheme
|
||||
Repository} is maintained by David Eby. The repository currently consists
|
||||
of the following areas:
|
||||
\begin{itemize}
|
||||
\item Lots of scheme code meant for benchmarking, library/support, research, education, and fun.
|
||||
\item On-line documents: Machine readable standards documents, standards proposals, various Scheme-related tech reports, conference papers, mail archives, etc.
|
||||
\item Most of the publicly distributable Scheme Implementations.
|
||||
\item Material designed primarily for instruction.
|
||||
\item Freely-distributable promotional or demonstration material for Scheme-related products.
|
||||
\item Utilities (e.g., Schemeweb, SLaTeX).
|
||||
\item Extraneous stuff, extensions, etc.
|
||||
\end{itemize}
|
||||
|
||||
You can access the Scheme repository with
|
||||
{\tt
|
||||
\begin{itemize}
|
||||
\item ftp.cs.indiana.edu:/pub/scheme-repository
|
||||
\item http://www.cs.indiana.edu/scheme-repository/SRhome.html
|
||||
\end{itemize}
|
||||
}
|
||||
|
||||
The Scheme Repository is mirrored in Europe:
|
||||
{\tt
|
||||
\begin{itemize}
|
||||
\item ftp.inria.fr:/lang/Scheme
|
||||
\item faui80.informatik.uni-erlangen.de:/pub/scheme/yorku
|
||||
\item ftp.informatik.uni-muenchen.de:/pub/comp/programming/languages/scheme/scheme-repository
|
||||
\end{itemize}
|
||||
}
|
||||
\subsection{Usenet newsgroup and other addresses}
|
||||
|
||||
There is a usenet newsgroup about the Scheme Programming language: {\tt
|
||||
comp.lang.scheme}.
|
||||
|
||||
Following addresses contains also material about the Scheme language
|
||||
|
||||
\begin{itemize}
|
||||
\item {\tt http://www.cs.cmu.edu:8001/Web/Groups/AI/html/faqs/lang/scheme/top.html}
|
||||
contains the Scheme FAQ.
|
||||
\item {\tt http://www-swiss.ai.mit.edu/scheme-home.html} is the Scheme Home page
|
||||
at MIT
|
||||
\item {\tt http://www.ai.mit.edu/projects/su/su.html} is the Scheme Underground
|
||||
web page
|
||||
\end{itemize}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
%
|
||||
% STk Reference manual (Appendix: Changes)
|
||||
%
|
||||
% Author: Erick Gallesio [eg@unice.fr]
|
||||
% Creation date: 21-Dec-1997 20:09
|
||||
% Last file update: 21-Dec-1997 21:56
|
||||
%
|
||||
|
||||
\section*{Introduction}
|
||||
|
||||
This appendix lists the main differences\footnote{ Only the
|
||||
differences which affect the language or new ports are reported here.
|
||||
In particular, internal changes, packages written in Scheme or
|
||||
performance enhancement are not discussed here.}.among the various
|
||||
recent versions of STk. Differences with older versions as well as
|
||||
implementation changes are described in the CHANGES file located in
|
||||
the main directory of the STk distribution.
|
||||
|
||||
\section*{Release 3.1.1}
|
||||
|
||||
\small{\emph{Release date: 09/26/96}}
|
||||
|
||||
This release is a bug correction release. It corrects a lot of bugs.
|
||||
A lot of these bugs prevent to install it on some architectures.
|
||||
|
||||
|
||||
\section*{Release 3.1}
|
||||
|
||||
\small{\emph{Release date: 07/24/96}}
|
||||
|
||||
\begin{itemize}
|
||||
\item Version of Tk is now at Tk4.1 level.
|
||||
\item STk has been ported on Windows 95 and Windows NT.
|
||||
\item Ports can have a handler which is executed when port becomes
|
||||
readable or writable (see primitives \texttt{when-port-readable} and
|
||||
\texttt{when-port-writable}.
|
||||
\item Sockets in server mode allow multiple concurrent connection.
|
||||
\item \stklos{}: Two new methods: \texttt{object-eqv?} and
|
||||
\texttt{object-equal?} which are called when applying \texttt{eqv?}
|
||||
or \texttt{equal?} to instances.
|
||||
\item New primitive:\texttt{setenv!}
|
||||
|
||||
\end{itemize}
|
||||
\section*{Release 3.0}
|
||||
|
||||
\small{\emph{Release date: 01/22/96}}
|
||||
\begin{itemize}
|
||||
\item Version of Tk is at Tk4.0p2 level.
|
||||
\item Closures are fully supported by Tk. That means that a callback can be
|
||||
now a Scheme closure with its environment. GC problems with closures
|
||||
and usage of the dirty \texttt{address-of} are definitively gone.
|
||||
\item Strings can contain null charters (printing of strings is more
|
||||
friendly in write mode).
|
||||
\item Signals can be redirected to Scheme closures. The end of a GC
|
||||
is seen as a signal.
|
||||
\item Traces on variables are changed (and re-work now): the
|
||||
associated trace must be a thunk.
|
||||
\item New options for some widgets to be more friendly with Scheme world
|
||||
\item \stklos{}: if a method M is defined and if it is already bound
|
||||
to a procedure, the old procedure is called when no method is
|
||||
applicable.
|
||||
\begin{scheme}
|
||||
(define-method car ((x <integer>)) (- x 1))
|
||||
(car 10) \lev 9
|
||||
(car (cons 'a 'b)) \lev a
|
||||
\end{scheme}
|
||||
\item Small change in the STklos hierarchy. \texttt{<widget>} is now a
|
||||
subclass of \texttt{<procedure>} and its meta class is
|
||||
\texttt{<procedure-metaclass>}.
|
||||
\end{itemize}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "manual"
|
||||
%%% End:
|
||||
@@ -0,0 +1,277 @@
|
||||
%
|
||||
% STk Reference manual (Appendix: Miscellaneous Informations)
|
||||
%
|
||||
% Author: Erick Gallesio [eg@unice.fr]
|
||||
% Creation date: 21-Dec-1994 12:05
|
||||
% Last file update: 6-Apr-1998 11:17
|
||||
%
|
||||
|
||||
\section{Introduction}
|
||||
This appendix lists a number of things which cannot go elsewhere in this
|
||||
document. The only link between the items listed her is that they should
|
||||
ease your life when using {\stk}.
|
||||
|
||||
\section{About \stk}
|
||||
|
||||
\subsection{Latest release}
|
||||
|
||||
{\stk} distribution is available on various sites. The original distribution
|
||||
site is {\tt kaolin.unice.fr} {\tt (134.59.132.7)}. Files are available
|
||||
through anonymous ftp and are located in the {\tt /pub/STk}
|
||||
directory. Distribution file names have the form {\tt STk-x.y.z.tar.gz}, where {\tt
|
||||
x} and {\tt y} represent the version the release and sub-release numbers of the package.
|
||||
|
||||
%David Fox maintains a mirror site of {\tt kaolin.unice.fr}. This site is
|
||||
%located in the USA and is available at the following URL:
|
||||
%{\tt ftp://cs.nyu.edu/pub/local/fox/stk}.
|
||||
|
||||
\subsection{Sharing Code}
|
||||
|
||||
If you have written code that you want to share with the (small) {\stk}
|
||||
community, you can deposit it in the directory {\tt /pub/STk/Incoming} of {\tt
|
||||
kaolin.unice.fr}. Mail me a small note when you deposit a file in this
|
||||
directory so I can put in in its definitive place ({\tt /pub/STk/Contrib}
|
||||
directory contains the contributed code).
|
||||
|
||||
\subsection{{\stk} Mailing list}
|
||||
|
||||
There is a mailing list for {\stk} located on {\tt kaolin.unice.fr}. The
|
||||
intent of this mailing list is to permit to {\stk} users to share experiences,
|
||||
expose problems, submit ideas and \ldots everything which you find interesting
|
||||
(and which is related to \stk).
|
||||
|
||||
To subscribe to the mailing list, simply send a message with the word {\tt
|
||||
subscribe} in the {\tt Subject:} field of you mail. Mail must be sent to the
|
||||
following address: {\tt stk-request@kaolin.unice.fr}
|
||||
|
||||
To unsubscribe from the mailing list, send a mail at previous email address with the word {\tt unsubscribe} in the {\tt Subject:} field.
|
||||
|
||||
For more information on the mailing list management send a message with the
|
||||
word {\tt help} in the {\tt Subject:} field of your mail. In particular, it
|
||||
is possible to find all the messages which have already been sent on the {\stk}
|
||||
mailing list.
|
||||
|
||||
Subscription/un-subscription/information requests are processed
|
||||
automatically without human intervention. If you something goes wrong, send a
|
||||
mail to {\tt eg@unice.fr}.
|
||||
|
||||
Once you have properly subscribe to the mailing list,
|
||||
\begin{itemize}
|
||||
\item you can send your messages about {\stk} to {\tt stk@kaolin.unice.fr},
|
||||
\item you will receive all the messages of the mailing list to the email
|
||||
address you used when you subscribed to the list.
|
||||
\end{itemize}
|
||||
|
||||
\subsection{{\stk} FAQ}
|
||||
|
||||
Marc Furrer has set up a FAQ{\index{FAQ} for {\stk}.
|
||||
This FAQ is regularly posted on the {\stk} mailing list. It can
|
||||
also be accessed through {\tt
|
||||
http://ltiwww.epfl.ch/~furrer/STk/FAQ.html}. ASCII version of the FAQ is
|
||||
available from {\tt http://ltiwww.epfl.ch/~furrer/STk/FAQ.txt}.
|
||||
|
||||
\subsection{Reporting a bug}
|
||||
|
||||
When you find a bug in {\stk}, please send its description to the following
|
||||
address {\tt stk-bugs@kaolin.unice.fr}. Don't forget to indicate the version
|
||||
you use and the architecture the system is compiled on. {\stk} version and
|
||||
architecture can be found by using the {\tt version} and {\tt machine-type}
|
||||
Scheme primitives. If possible, try to find a small program which exhibit the bug.
|
||||
|
||||
\section{{\stk} and Emacs}
|
||||
|
||||
The Emacs family editors\index{Emacs editor} can be customized to ease
|
||||
viewing and editing programs of a particular sort. Hints given below
|
||||
enable a fine ``integration'' of {\stk} in Emacs.
|
||||
|
||||
\subsection*{Automatic scheme-mode setting}
|
||||
|
||||
Emacs mode can be chosen automatically on the file's name. To edit file
|
||||
ended by {\tt .stk }or {\tt .stklos} in Scheme mode, you have to set the
|
||||
Elisp variable {\tt auto-mode-alist} to control the correspondence between
|
||||
those suffixes and the scheme mode. The simpler way to set this variable
|
||||
consists to add the following lines in your .{\tt emacs} startup file.
|
||||
|
||||
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
;; Add the '.stk' and '.stklos' suffix in the auto-mode-alist Emacs
|
||||
;; variable. Setting this variable permits to automagically place the
|
||||
;; buffer in scheme-mode.
|
||||
(setq-default auto-mode-alist (append auto-mode-alist
|
||||
("\\.stk$" . scheme-mode)
|
||||
("\\.stklos$" . scheme-mode)))
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
|
||||
\subsection*{Using Emacs and {\em CMU Scheme}}
|
||||
|
||||
{\em CMU Scheme} package\index{CMU Scheme} package} permits to run the {\stk} interpreter in an Emacs
|
||||
window. Once the package is loaded, you can send text to the inferior
|
||||
{\stk} interpreter from other buffers containing Scheme source.
|
||||
The {\em CMU Scheme} package is distributed with Emacs (both FSF-Emacs and
|
||||
Xemacs) and you should have it if you are running this editor.
|
||||
|
||||
To use the {\em CMU Scheme} package with {\stk}, place the following lines in
|
||||
your {\tt .emacs} startup file.
|
||||
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
;; Use cmu-scheme rather than xscheme which is launched by default
|
||||
;; whence running 'run-scheme' (xscheme is wired with CScheme)
|
||||
(autoload 'run-scheme "cmuscheme" "Run an inferior Scheme" t)
|
||||
(setq scheme-program-name "stk")
|
||||
(setq inferior-scheme-mode-hook '(lambda() (split-window)))
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
|
||||
|
||||
After having entered those lines in your {\tt .emacs} file, you can simply
|
||||
run the {\stk} interpreter by typing
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
M-x run-scheme
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
|
||||
|
||||
Read the {\em CMU Scheme} documentation (or use the describe-mode Elisp command)
|
||||
for a complete description of this package.
|
||||
|
||||
\subsection*{Using Emacs and the {\em Ilisp} package}
|
||||
|
||||
{\em Ilisp}\index{Ilisp package} is another scheme package which allows to
|
||||
run the {\stk} interpreter in an Emacs window. This is a rich package with
|
||||
a lot of nice features. {\em Ilisp} comes pre-installed with Xemacs; it
|
||||
has to be installed with FSF Emacs (the last version of {\em Ilisp} can be
|
||||
ftp'ed anonymously from {\tt ftp.cs.cmu.edu} (128.2.206.173) in the {\tt
|
||||
/user/ai/lang/lisp/util/emacs/ilisp} directory).
|
||||
|
||||
To use the {\em Ilisp} package with {\stk}, place the following lines in
|
||||
your {\tt .emacs} startup file.
|
||||
|
||||
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
(autoload 'run-ilisp "ilisp" "Select a new inferior LISP." t)
|
||||
(autoload 'stk "ilisp" "Run stk in ILISP." t)
|
||||
(add-hook 'ilisp-load-hook
|
||||
'(lambda ()
|
||||
(require 'completer)
|
||||
|
||||
;; Define STk dialect characteristics
|
||||
(defdialect stk "STk Scheme"
|
||||
scheme
|
||||
(setq comint-prompt-regexp "^STk> ")
|
||||
(setq ilisp-program "stk -interactive")
|
||||
(setq comint-ptyp t)
|
||||
(setq comint-always-scroll t)
|
||||
(setq ilisp-last-command "*"))))
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
|
||||
|
||||
After having entered those lines in your {\tt .emacs} file, you can simply
|
||||
run the {\stk} interpreter by typing
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
M-x stk
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
|
||||
|
||||
The Ilisp package comes with a rich documentation which describe how to
|
||||
customize the package.
|
||||
|
||||
\subsection*{Other packages}
|
||||
|
||||
Another way to use {\stk} and Emacs consists to use a special purpose
|
||||
{\stk} mode. You can find two such modes in the {\tt /pub/Contrib}
|
||||
directory of {\tt kaolin.unice.fr}.
|
||||
|
||||
\subsection {Using the SLIB package with \stk}
|
||||
|
||||
Aubrey Jaffer maintains a package called {\em SLIB}\index{SLIB package}
|
||||
which is a portable Scheme library which provides compatibility and utility
|
||||
functions for all standard Scheme implementations. To use this package, you
|
||||
have just to type
|
||||
\begin{quote}
|
||||
\begin{verbatim}
|
||||
(require "slib")
|
||||
\end{verbatim}
|
||||
\end{quote}
|
||||
and follow the instructions given in the {\em SLIB} library to use a
|
||||
particular package.
|
||||
\begin{note}
|
||||
{\em SLIB} uses also the {\em require/provide} mechanism to load components
|
||||
of the library. Once {\em SLIB} has been loaded, the standard {\stk}
|
||||
{\tt require}\schindex{require} and {\tt provide}\schindex{provide}
|
||||
are overloaded such as if their parameter
|
||||
is a string this is the old {\stk} procedure which is called, and if their
|
||||
parameter is a symbol, this is the {\em SLIB} one which is called.
|
||||
\end{note}
|
||||
|
||||
\section{Getting information about Scheme}
|
||||
|
||||
\subsection{The {\rrrr} document}
|
||||
|
||||
{\rrrr}{\index{R4RS}} is the document which fully describe the Scheme
|
||||
Programming Language, it can be found in the Scheme repository
|
||||
(see~\ref{scheme-repository}) in the directory:
|
||||
\begin{quote}
|
||||
{\tt ftp.cs.indiana.edu:/pub/scheme-repository/doc}
|
||||
\end{quote}
|
||||
|
||||
Aubrey Jaffer has also translated this document in HTML. A version of this
|
||||
document is available at
|
||||
\begin{quote}
|
||||
{\tt file://swiss-ftp.ai.mit.edu/pub/scm/HTML/r4rs\_toc.html}
|
||||
\end{quote}
|
||||
|
||||
\subsection{The Scheme Repository}
|
||||
|
||||
The main site where you can find (many) informations about Scheme is
|
||||
located in the University of Indiana. The Scheme repository\index{Scheme
|
||||
Repository} is maintained by David Eby. The repository currently consists
|
||||
of the following areas:
|
||||
\begin{itemize}
|
||||
\item Lots of scheme code meant for benchmarking, library/support, research, education, and fun.
|
||||
\item On-line documents: Machine readable standards documents, standards proposals, various Scheme-related tech reports, conference papers, mail archives, etc.
|
||||
\item Most of the publicly distributable Scheme Implementations.
|
||||
\item Material designed primarily for instruction.
|
||||
\item Freely-distributable promotional or demonstration material for Scheme-related products.
|
||||
\item Utilities (e.g., Schemeweb, SLaTeX).
|
||||
\item Extraneous stuff, extensions, etc.
|
||||
\end{itemize}
|
||||
|
||||
You can access the Scheme repository with
|
||||
{\tt
|
||||
\begin{itemize}
|
||||
\item ftp.cs.indiana.edu:/pub/scheme-repository
|
||||
\item http://www.cs.indiana.edu/scheme-repository/SRhome.html
|
||||
\end{itemize}
|
||||
}
|
||||
|
||||
The Scheme Repository is mirrored in Europe:
|
||||
{\tt
|
||||
\begin{itemize}
|
||||
\item ftp.inria.fr:/lang/Scheme
|
||||
\item faui80.informatik.uni-erlangen.de:/pub/scheme/yorku
|
||||
\item ftp.informatik.uni-muenchen.de:/pub/comp/programming/languages/scheme/scheme-repository
|
||||
\end{itemize}
|
||||
}
|
||||
\subsection{Usenet newsgroup and other addresses}
|
||||
|
||||
There is a usenet newsgroup about the Scheme Programming language: {\tt
|
||||
comp.lang.scheme}.
|
||||
|
||||
Following addresses contains also material about the Scheme language
|
||||
|
||||
\begin{itemize}
|
||||
\item {\tt http://www.cs.cmu.edu:8001/Web/Groups/AI/html/faqs/lang/scheme/top.html}
|
||||
contains the Scheme FAQ.
|
||||
\item {\tt http://www-swiss.ai.mit.edu/scheme-home.html} is the Scheme Home page
|
||||
at MIT
|
||||
\item {\tt http://www.ai.mit.edu/projects/su/su.html} is the Scheme Underground
|
||||
web page
|
||||
\end{itemize}
|
||||
+12
-6
@@ -3,26 +3,32 @@
|
||||
TEX= manual.tex commands.tex Reference1.tex Reference2.tex \
|
||||
Appendix-A.tex Appendix-B.tex Appendix-C.tex Appendix-D.tex
|
||||
|
||||
all: dvi ps
|
||||
all: dvi ps
|
||||
|
||||
dvi: manual.dvi
|
||||
ps: manual.ps
|
||||
|
||||
manual.dvi: $(TEX)
|
||||
manual.dvi: bibli $(TEX)
|
||||
echo -n > index.tex
|
||||
latex manual.tex
|
||||
tr A-Z a-z < manual.idx> manual2.idx
|
||||
mv manual2.idx manual.idx
|
||||
STK_LIBRARY=../../Lib ../../Src/stk -no -file index.stk
|
||||
bibtex manual
|
||||
latex manual.tex
|
||||
latex manual.tex
|
||||
|
||||
|
||||
manual.ps: manual.dvi
|
||||
dvips -t a4 -f manual.dvi > manual.ps
|
||||
|
||||
bibli: manual.bbl
|
||||
|
||||
manual.bbl: $(TEX) ../bibliography.bib
|
||||
echo -n > index.tex
|
||||
latex manual.tex
|
||||
bibtex manual
|
||||
latex manual.tex
|
||||
|
||||
clean:
|
||||
rm -f *.aux *.idx *.log *.aux *.bbl *.blg *.idx *.toc *~ index.tex
|
||||
rm -f *.bbl *.aux *.idx *.log *.aux *.blg *.idx *.toc *~ index.tex
|
||||
|
||||
very-clean: clean
|
||||
rm -f manual.ps manual.dvi
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
%
|
||||
% Author: Erick Gallesio [eg@unice.fr]
|
||||
% Creation date: ??-Nov-1993 ??:??
|
||||
% Last file update: 24-Jul-1996 13:38
|
||||
% Last file update: 16-Dec-1997 19:09
|
||||
%
|
||||
|
||||
\section*{Introduction}
|
||||
@@ -27,7 +27,6 @@ problem, since programmers using this kind of languages are generally not
|
||||
inclined to system programming, and few of them will bridge the gap between
|
||||
the different abstraction levels.
|
||||
|
||||
|
||||
~~~~Tk\index{Tk toolkit}\index{toolkit} is a powerful graphical tool\-kit
|
||||
promising to fill that gap. It was developed at the University of Berkeley
|
||||
by John Ousterhout~\cite{Ouster-Tk}. The toolkit offers high level widgets
|
||||
@@ -52,17 +51,24 @@ some situations.
|
||||
|
||||
\subsection{Comments}
|
||||
|
||||
As in the {\rrrr}, a semicolon (;) indicates the start of a comment.
|
||||
In {\stk}, comments can also be introduced by \sharpsign$!$. This
|
||||
extension is particularly useful for building {\stk} scripts. On most
|
||||
Unix implementations, if the first line of a script looks like this:
|
||||
\begin{scheme}
|
||||
\sharpsign$!$/usr/local/bin/stk -file
|
||||
\end{scheme}
|
||||
then the script can be started directly as if it were a binary. {\stk}
|
||||
is loaded behind the scenes and reads and executes the script as a
|
||||
Scheme program. Of course this assumes that {\stk} is located in {\tt
|
||||
/usr/local/bin}.
|
||||
There are three types of comments in {\stk}:
|
||||
\begin{enumerate}
|
||||
\item a semicolon (;) indicates the start of a comment.
|
||||
This kind of comment extends to the end of the line (as described in \rrrr).
|
||||
\item multi-lines comment use the classical lisp conventions: a comment
|
||||
begins with \verb+#|+ and ends with \verb+|#+.
|
||||
\item comments can also be introduced by \sharpsign$!$. This
|
||||
extension is particularly useful for building {\stk} scripts. On most
|
||||
Unix implementations, if the first line of a script looks like this:
|
||||
\begin{scheme}
|
||||
\sharpsign$!$/usr/local/bin/stk -file
|
||||
\end{scheme}
|
||||
then the script can be started directly as if it were a binary. {\stk}
|
||||
is loaded behind the scenes and reads and executes the script as a
|
||||
Scheme program. Of course this assumes that {\stk} is located in {\tt
|
||||
/usr/local/bin}.
|
||||
\end{enumerate}
|
||||
|
||||
|
||||
\subsection{Other notations}
|
||||
|
||||
@@ -82,7 +88,7 @@ Scheme program. Of course this assumes that {\stk} is located in {\tt
|
||||
\item[\tt\sharpsign.<expr>] is read as the evaluation of the Scheme
|
||||
expression {\tt <expr>}. The evaluation is done during the
|
||||
\ide{read} process, when the \var{\sharpsign.} is encountered.
|
||||
Evalustaion is done in the global-environment.
|
||||
Evaluation is done in the global environment.
|
||||
\begin{scheme}
|
||||
(define foo 1)
|
||||
\sharpsign.foo \lev 1
|
||||
@@ -361,6 +367,26 @@ keywords into account. On keywords, \ide{eq?} behaves like \ide{eqv?}.
|
||||
\doc
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{remq}{ obj list}{procedure}
|
||||
\proto{remv}{ obj list}{procedure}
|
||||
\proto{remove}{ obj list}{procedure}}
|
||||
\saut
|
||||
Each function return a copy of \var{list} where all the occurences of \var{obj}
|
||||
have been deleted. The predicate used to test the presence of \var{obj} in
|
||||
\var{list} is respectively \ide{eq}, \ide{eqv} and \ide{equal}.
|
||||
|
||||
\begin{note}
|
||||
It is not an error if \var{obj} does not appear in \var{list}.
|
||||
\end{note}
|
||||
\begin{scheme}
|
||||
(remq 1 '(1 2 3)) \ev (2 3)
|
||||
(remq "foo" '("foo" "bar")) \ev ("foo" "bar")
|
||||
(remove "foo" '("foo" "bar"))
|
||||
\ev ("bar")
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{list*}{ obj}{procedure}}
|
||||
\saut
|
||||
@@ -780,6 +806,20 @@ Returns the index of where \vari{string} is a substring of
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{split-string}{ string}{procedure}
|
||||
\proto{split-string}{ string delimiters}{procedure}}
|
||||
\saut
|
||||
This function parses \vari{string} and returns a list of tokens ended by
|
||||
a character of the \vari{delimiters} string. If \vari{delimiters} is omitted,
|
||||
it defaults to a string containing a space, a tabulation and a newline
|
||||
characters.
|
||||
\begin{scheme}
|
||||
(split-string "/usr/local/bin" "/") \ev ("usr" "local" "bin")
|
||||
(split-string "once upon a time") \ev ("once" "upon" "a" "time")
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{string-lower}{ string}{procedure}}
|
||||
\saut
|
||||
@@ -1234,25 +1274,35 @@ undefined. Otherwise, it returns the handler currently associated to
|
||||
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{load}{ filename}{procedure}}
|
||||
\proto{load}{ filename}{procedure}
|
||||
\proto{load}{ filename environment}{procedure}}
|
||||
\saut
|
||||
\doc
|
||||
|
||||
The first form is identical to \rrrr{}. The second one loads the
|
||||
content of \var{filename} in the given \var{environment}. So, the first
|
||||
form is equivalent to
|
||||
\begin{scheme}
|
||||
(load filename (global-environment))
|
||||
\end{scheme}
|
||||
\begin{note}
|
||||
The \var{load} primitive has been extended to allow loading of
|
||||
object files, though this is not implemented on all systems
|
||||
\footnote{Current version (\stkversion) allows image dumping
|
||||
only on some platforms:SunOs~4.1.x, SunOs~5.3, NetBSD~1.0,
|
||||
HPUX, Irix 5.3}. See~\cite{STkExtension} for more details.
|
||||
object files, though this is not implemented on all systems.
|
||||
This extension uses dynamic loading on systems which support it
|
||||
\footnote{Current version (\stkversion) allows dynamic loading
|
||||
only on some platforms: SunOs~4.1.x, SunOs~5.x, NetBSD~1.0,
|
||||
Linux~2.0, HPUX, Irix 5.3}. See~\cite{STkExtension} for more details.
|
||||
\end{note}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{try-load}{ filename}{procedure}}
|
||||
\proto{try-load}{ filename}{procedure}
|
||||
\proto{try-load}{ filename environment}{procedure}}
|
||||
\saut
|
||||
Tries to load the file named \var{filename}. If \var{filename} exists and is
|
||||
readable, it is loaded, and \ide{try-load} returns {\schtrue}.
|
||||
Otherwise, the result of the call is {\schfalse}.
|
||||
The second form of \var{try-load} tries to load the content of \var{filename}
|
||||
in the given \var{environment}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
|
||||
+433
-561
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,846 @@
|
||||
%
|
||||
% STk Reference manual (Part 3)
|
||||
%
|
||||
% Author: Erick Gallesio [eg@unice.fr]
|
||||
% Creation date: 16-Dec-1997 14:00
|
||||
% Last file update: 8-Apr-1998 11:04
|
||||
%
|
||||
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%
|
||||
%%%% Section 6.22: Sockets
|
||||
%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
\subsection{Sockets}
|
||||
|
||||
\label{socket-type}
|
||||
{\stk} defines sockets, on systems which support them, as first class
|
||||
objects. Sockets permits processes to communicate even if they are on
|
||||
different machines. Sockets are useful for creating client-server
|
||||
applications.
|
||||
|
||||
\begin{entry}{
|
||||
\proto{make-client-socket}{ hostname port-number}{procedure}}
|
||||
\saut
|
||||
\ide{make-client-socket} returns a new socket object. This socket
|
||||
establishes a link between the running application listening on port
|
||||
\var{port-number} of \var{hostname}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket?}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns \schtrue{} if \var{socket} is a socket, otherwise returns
|
||||
{\schfalse}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-host-name}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns a string which contains the name of the distant host attached to
|
||||
\var{socket}. If \var{socket} has been created with \ide{make-client-socket}
|
||||
this procedure returns the official name of the distant machine used for
|
||||
connection. If \var{socket} has been created with \ide{make-server-socket},
|
||||
this function returns the official name of the client connected to the socket.
|
||||
If no client has used yet the socket, this function returns \schfalse.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-host-address}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns a string which contains the IP\mainindex{IP number} number of
|
||||
the distant host attached to \var{socket}. If \var{socket} has been
|
||||
created with \ide{make-client-socket} this procedure returns the
|
||||
IP number of the distant machine used for connection. If
|
||||
\var{socket} has been created with \ide{make-server-socket}, this
|
||||
function returns the address of the client connected to the
|
||||
socket. If no client has used yet the socket, this function returns
|
||||
\schfalse.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-local-address}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns a string which contains the IP\mainindex{IP number} number of
|
||||
the local host attached to \var{socket}.
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-port-number}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns the integer number of the port used for \var{socket}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-input} { socket}{procedure}
|
||||
\proto{socket-output}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns the file port associated for reading or writing with the program
|
||||
connected with \var{socket}. If no connection has already been established,
|
||||
these functions return \schfalse.
|
||||
|
||||
The following example shows how to make a client socket. Here we create a
|
||||
socket on port 13 of the machine ``{\tt kaolin.unice.fr}''\footnote{Port 13
|
||||
is generally used for testing: making a connection to it permits to know
|
||||
the distant system's idea of the time of day.}:
|
||||
\begin{scheme}
|
||||
(let ((s (make-client-socket "kaolin.unice.fr" 13)))
|
||||
(format {\schtrue} "Time is: {\tilda}A\verb+\+n" (read-line (socket-input s)))
|
||||
(socket-shutdown s))
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{make-server-socket}{}{procedure}
|
||||
\proto{make-server-socket}{ port-number}{procedure}}
|
||||
\saut
|
||||
\ide{make-server-socket} returns a new socket object. If \var{port-number}
|
||||
is specified, the socket is listening on the specified port; otherwise, the
|
||||
communication port is chosen by the system.
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-accept-connection}{ socket}{procedure}}
|
||||
\saut
|
||||
\ide{socket-accept-connection} waits for a client connection on the given
|
||||
\var{socket}. If no client is already waiting for a connection, this
|
||||
procedure blocks its caller; otherwise, the first connection request on the
|
||||
queue of pending connections is connected to \var{socket}.
|
||||
This procedure must be called on a server socket created
|
||||
with \ide{make-server-socket}. The result of \ide{socket-accept-connection}
|
||||
is undefined.
|
||||
|
||||
The following example is a simple server which waits for a connection
|
||||
on the port 1234\footnote{Under Unix, you can simply connect to
|
||||
listening socket with the {\tt telnet} command. With the given
|
||||
example, this can be
|
||||
achieved by typing the following command in a window shell:\\
|
||||
{\tt \$ telnet localhost 1234}}. Once the connection with the
|
||||
distant program is established, we read a line on the input port
|
||||
associated to the socket and we write the length of this line on its
|
||||
output port.
|
||||
\begin{scheme}
|
||||
(let ((s (make-server-socket 1234)))
|
||||
(socket-accept-connection s)
|
||||
(let ((l (read-line (socket-input s))))
|
||||
(format (socket-output s) "Length is: {\tilda}A\verb+\+n" (string-length l))
|
||||
(flush (socket-output s)))
|
||||
(socket-shutdown s))
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-shutdown}{ socket}{procedure}
|
||||
\proto{socket-shutdown}{ socket close}{procedure}}
|
||||
\saut
|
||||
\ide{Socket-shutdown} shutdowns the connection associated to \var{socket}.
|
||||
\var{Close} is a boolean; it indicates if the socket must be closed or not, when
|
||||
the connection is destroyed. Closing the socket forbids further connections on
|
||||
the same port with the \ide{socket-accept-connection} procedure.
|
||||
Omitting a value for \var{close} implies the closing of socket.
|
||||
The result of \ide{socket-shutdown} is undefined.
|
||||
|
||||
The following example shows a simple server: when there is a new connection
|
||||
on the port number 1234, the server displays the first line sent to it by the
|
||||
client, discards the others and go back waiting for further client connections.
|
||||
\begin{scheme}
|
||||
(let ((s (make-server-socket 1234)))
|
||||
(let loop ()
|
||||
(socket-accept-connection s)
|
||||
(format {\schtrue} "I've read: {\tilda}A\verb+\+n" (read-line (socket-input s)))
|
||||
(socket-shutdown s \schfalse)
|
||||
(loop)))
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-down?}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns {\schtrue} if \var{socket} has been previously closed
|
||||
with \ide{socket-shutdown}. It returns {\schfalse} otherwise.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{socket-dup}{ socket}{procedure}}
|
||||
\saut
|
||||
Returns a copy of \var{socket}. The original and the copy socket can be used
|
||||
interchangeably. However, if a new connection is accepted on one socket,
|
||||
the characters exchanged on this socket are not visible on the other socket.
|
||||
Duplicating a socket is useful when a server must accept multiple simultaneous
|
||||
connections.
|
||||
The following example creates a server listening on port 1234. This server is
|
||||
duplicated and, once two clients are present, a message is sent on both
|
||||
connections.
|
||||
\begin{scheme}
|
||||
(define s1 (make-server-socket 1234))
|
||||
(define s2 (socket-dup s1))
|
||||
(socket-accept-connection s1)
|
||||
(socket-accept-connection s2)
|
||||
;; blocks until two clients are present
|
||||
(display "Hello,\verb+\+n" (socket-output s1))
|
||||
(display "world\verb+\+n" (socket-output s2))
|
||||
(flush (socket-output s1))
|
||||
(flush (socket-output s2))
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{when-socket-ready}{ socket handler}{procedure}
|
||||
\proto{when-socket-ready}{ socket}{procedure}}
|
||||
\saut
|
||||
Defines a handler for \var{socket}. The handler is a thunk which is
|
||||
executed when a connection is available on \var{socket}. If the special value
|
||||
\schfalse{} is provided as \var{handler}, the current handler for \var{socket}
|
||||
is deleted. If a handler is provided, the value returned by
|
||||
\ide{when-socket-ready} is undefined. Otherwise, it
|
||||
returns the handler currently associated to \var{socket}.
|
||||
|
||||
This procedure, in conjunction with \ide{socket-dup} permits to build
|
||||
multiple-clients servers which work asynchronously. Such a server is
|
||||
shown below.
|
||||
\begin{scheme}
|
||||
(define p (make-server-socket 1234))
|
||||
(when-socket-ready p
|
||||
(let ((count 0))
|
||||
(lambda ()
|
||||
(set! count (+ count 1))
|
||||
(register-connection (socket-dup p) count))))
|
||||
|
||||
(define register-connection
|
||||
(let ((sockets '()))
|
||||
(lambda (s cnt)
|
||||
;; Accept connection
|
||||
(socket-accept-connection s)
|
||||
;; Save socket somewhere to avoid GC problems
|
||||
(set! sockets (cons s sockets))
|
||||
;; Create a handler for reading inputs from this new connection
|
||||
(let ((in (socket-input s))
|
||||
(out (socket-output s)))
|
||||
(when-port-readable in
|
||||
(lambda ()
|
||||
(let ((l (read-line in)))
|
||||
(if (eof-object? l)
|
||||
;; delete current handler
|
||||
(when-port-readable in \schfalse)
|
||||
;; Just write the line read on the socket
|
||||
(begin
|
||||
(format out "On {\sharpsign}{\tilda}A --> {\tilda}A\verb+\+n" cnt l)
|
||||
(flush out))))))))))
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%
|
||||
%%%% Section 6.23: FFI
|
||||
%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
\subsection{Foreign Function Interface}
|
||||
|
||||
The {\stk} Foreign Function Interface (FFI for short) has been defined
|
||||
to allow an easy access to functions written in C without needing to
|
||||
build C-wrappers and, consequently, without any need to write C code.
|
||||
Note that the FFI is very machine dependent and that it works only on
|
||||
a limited set of architectures\footnote{In release \stkversion, FFI is
|
||||
known to work on the following architectures : ix86 (but not yet
|
||||
MS Windows), Sun Sparc, HP 9000, SGI.}. Moreover, since FFI
|
||||
allows very low level access, it is easy to crash the interpreter when
|
||||
using an external C function.
|
||||
|
||||
The definition of an external function is done with the syntax
|
||||
\ide{define-external}. This form takes as arguments a typed list of
|
||||
parameters and accepts several options to define the name of the
|
||||
function in the C world, the library which defines this
|
||||
function,~\ldots{} The type of the function result and the types of
|
||||
its arguments are defined in Table~\ref{FfiTypes}. This table lists the various
|
||||
keywords reserved for denoting types and their equivalence between the
|
||||
C and the Scheme worlds.
|
||||
|
||||
\begin{table}[t]
|
||||
\begin{center}
|
||||
|
||||
\begin{tabular}{|p{3cm}|p{5cm}|p{5cm}|}
|
||||
\hline
|
||||
\textbf{Name}&\textbf{Corresponding C type}&\textbf{Corresponding Scheme Type }\\
|
||||
\hline
|
||||
\hline
|
||||
\texttt{:void}&\texttt{void}&\emph{None}\\
|
||||
\hline
|
||||
|
||||
\texttt{:char}&\texttt{char}&Scheme character or Scheme integer\\
|
||||
\hline
|
||||
|
||||
\texttt{:short}&\texttt{short~int}&Scheme integer\\
|
||||
\hline
|
||||
|
||||
\texttt{:ushort}&\texttt{unsigned~short~int}&Scheme integer\\
|
||||
\hline
|
||||
|
||||
\texttt{:int}&\texttt{int}&Scheme integer\\
|
||||
\hline
|
||||
|
||||
\texttt{:uint}&\texttt{unsigned~integer}&Scheme integer\\
|
||||
\hline
|
||||
|
||||
\texttt{:long}&\texttt{long~integer}&Scheme integer\\
|
||||
\hline
|
||||
|
||||
\texttt{:ulong}&\texttt{unsigned~long~integer}&Scheme integer\\
|
||||
\hline
|
||||
|
||||
\texttt{:float}&\texttt{float}&Scheme Real\\
|
||||
\hline
|
||||
|
||||
\texttt{:double}&\texttt{double}&Scheme Real\\
|
||||
\hline
|
||||
|
||||
\texttt{:static-ptr}&pointer on a static area&Scheme C-pointer object or Scheme String\\
|
||||
\hline
|
||||
|
||||
\texttt{:dynamic-ptr}~\emph{or} \texttt{(:void~{*})}&pointer on a dynamic area (\texttt{malloc}ated) &
|
||||
Scheme C-pointer object or Scheme String\\
|
||||
\hline
|
||||
|
||||
\texttt{:string}~\emph{or} \texttt{(:char~{*})}&\texttt{char~{*}}~(pointer on a dynamic string)&Scheme C-pointer object or Scheme String\\
|
||||
\hline
|
||||
|
||||
\texttt{:boolean}&\texttt{int}&Scheme boolean\\
|
||||
\hline
|
||||
\end{tabular}
|
||||
\caption{FFI predefined types}
|
||||
\label{FfiTypes}
|
||||
\end{center}
|
||||
\end{table}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{define-external}{ \hyper{name} \hyper{parameters} \hyper{options}}{\exprtype}}
|
||||
\saut
|
||||
|
||||
The form \ide{define-external} binds a new procedure to \hyper{name}.
|
||||
The arity of this new procedure is defined by the typed list of
|
||||
parameters given by \hyper{parameters}. This parameters list is a list
|
||||
of couples whose first element is the name of the parameter, and the
|
||||
second one is is a keyword representing its type (see table for
|
||||
equivalence). All the types defined in Table~\ref{FfiTypes}, except
|
||||
\texttt{:void}, are allowed for the parameters of a foreign function.
|
||||
\ide{Define-external} accepts several options:
|
||||
\begin{itemize}
|
||||
\item \texttt{:return-type} is used to define the type of the value returned
|
||||
by the foreign function. The type returned must be chosen in the types specified
|
||||
in the table. For instance:
|
||||
\begin{scheme}
|
||||
(define-external maximum((a :int) (b :int))
|
||||
:return-type :int)
|
||||
\end{scheme}
|
||||
defines the foreign function maximum which takes two C integers and
|
||||
returns an integer result. Omitting this option default to a result
|
||||
type equal to \texttt{:void} (i.e. the returned value is
|
||||
\emph{undefined}).
|
||||
|
||||
\item \texttt{:entry-name} is used to specify the name of the foreign
|
||||
function in the C world. If this option is omitted, the entry-name is
|
||||
supposed to be \hyper{name}. For instance:
|
||||
\begin{scheme}
|
||||
(define-external minimum((a :int) (b :int))
|
||||
:return-type :int
|
||||
:entry-name "min")
|
||||
\end{scheme}
|
||||
defines the Scheme function \texttt{minimum} whose application
|
||||
executes the C function called \texttt{min}.
|
||||
\item \texttt{:library-name} is used to specify the library which contains the
|
||||
foreign-function. If necessary, the library is loaded before calling the
|
||||
C function. So,
|
||||
\begin{scheme}
|
||||
(define-external minimum((a :int) (b :int))
|
||||
:return-type :int
|
||||
:entry-name "min"
|
||||
:library-name "libminmax")
|
||||
\end{scheme}
|
||||
defines a function which will execute the function \texttt{min}
|
||||
located in the library \texttt{libminmax.xx} (where \texttt{xx} is
|
||||
the suffix used for shared libraries on the running system (generally \texttt{so}
|
||||
or \texttt{sl}).
|
||||
\end{itemize}
|
||||
|
||||
Hereafter, there are some commented definitions of external functions:
|
||||
\begin{scheme}
|
||||
(define-external isatty ((fd :int))
|
||||
:return-type :boolean)
|
||||
|
||||
(define-external system ((cmd (:char *))) \emph{;; or ((cmd :string))}
|
||||
:return-type :int)
|
||||
|
||||
(define-external malloc ((size :ulong))
|
||||
:return-type (void *))
|
||||
|
||||
(define-external free ( (p (:void *) )) )
|
||||
\end{scheme}
|
||||
|
||||
All these functions are defined in the C standard library, hence it is not
|
||||
necessary to specify the \texttt{:library-name} option.
|
||||
\begin{itemize}
|
||||
\item \texttt{istty} is declared here as a function which takes an
|
||||
integer and returns a boolean (in fact, the value returned by the C
|
||||
function \texttt{isatty} is an \texttt{int}, but we ask here to the
|
||||
FFI system to translate this result as a boolean value in the Scheme
|
||||
world).
|
||||
|
||||
\item \texttt{system} is a function which takes a string as parameter
|
||||
and returns an \texttt{int}. Note that the type of the parameter,
|
||||
can be specified as a \texttt{(:char~*)} or \texttt{:string}, as
|
||||
indicated in Table~\ref{FfiTypes}.
|
||||
|
||||
\item \texttt{malloc} is a function which takes one parameter (an
|
||||
\texttt{unsigned long int} and which returns a \texttt{(:void~*)} (or
|
||||
\texttt{:dynamic-ptr}). Specifying that the result is a dynamic
|
||||
pointer (instead of a static one) means that we want that the Garbage
|
||||
Collector \mainindex{Garbage Collector} takes into account the area
|
||||
allocated by the C function \texttt{malloc} (i.e. if this area
|
||||
becomes no more accessible, the GC disposes it with the
|
||||
\texttt{free} function\footnote{Pointers defined with
|
||||
\texttt{:dynamic-ptr} are always unallocated with \texttt{free}.
|
||||
Consequently, areas allocated with another allocator than the
|
||||
standard one must be declared as \texttt{:static-ptr} and freed
|
||||
by hand}.
|
||||
\item \texttt{free} is a function which takes a dynamic pointer and
|
||||
deallocates the area it points. Since the definition of this function
|
||||
specifies no result type, it is supposed to be \texttt{:void}\footnote{
|
||||
Usage of malloc and free are for illustration purpose here. Their usage
|
||||
in a program must be avoided, if possible, because it can have
|
||||
interact badly with the way the interpreter manages memory or it
|
||||
can conduct to \emph{crashing} programs if you don't take care.}.
|
||||
\end{itemize}
|
||||
|
||||
External functions can also have a variable number of parameters by using
|
||||
the standard Scheme \emph{dot} notation. For instance,
|
||||
\begin{scheme}
|
||||
(define-external printf ((format :string) . l)
|
||||
:return-type :int)
|
||||
\end{scheme}
|
||||
defines a Scheme function with one or more parameters (the first one
|
||||
being a string). Of course, the parameters which constitute the
|
||||
variable parameters list must have a type which appears in the third
|
||||
column of Table~\ref{FfiTypes}. Some examples using the \texttt{printf} function:
|
||||
\begin{scheme}
|
||||
(printf "This is a \verb+%+s test" "good")
|
||||
\lev \emph{displays}~~~This is a good test
|
||||
(printf \verb+"char: '%c' Dec: '%04d' Hex '%04x'" #\space +100 100)
|
||||
\lev \emph{displays}~~~char: ' ' Dec: '0100' Hex '0064'
|
||||
\end{scheme}
|
||||
|
||||
\begin{note}
|
||||
The types \texttt{:dynamic-ptr}, \texttt{:static-ptr} and
|
||||
\texttt{:string} are compatible when used for foreign function
|
||||
parameter. This gives a semantic which is similar to the one of C,
|
||||
where \texttt{void~*} is a compatible with all other pointer types.
|
||||
However, differenciating those types is useful for converting
|
||||
the function return value to a proper Scheme type.
|
||||
\end{note}
|
||||
\par{}
|
||||
\vspace{2mm}
|
||||
\begin{note}
|
||||
When a function has a \texttt{:return-type} which is
|
||||
\texttt{:string}, \texttt{:dynamic-ptr} or \texttt{:static-ptr}, and
|
||||
the return value is the C \texttt{NULL} pointer, the Scheme value
|
||||
returned by the function is, by convention, equal to \schfalse. For
|
||||
instance, the GNU \texttt{readline} function allows line editing
|
||||
\emph{\`a la} Emacs returns \texttt{NULL} when the user has typed an
|
||||
end of file. The following lines show how to make a simple shell-like
|
||||
toplevel using FFIs.
|
||||
\begin{scheme}
|
||||
(define-external system ((var (:char *)))
|
||||
:return-type :int)
|
||||
|
||||
(define-external readline ((prompt :string))
|
||||
:library-name "libreadline"
|
||||
:return-type :string)
|
||||
|
||||
\textbf{;; A Shell-like toplevel}
|
||||
(do ((l (readline "?> ") (readline "?> ")))
|
||||
((not l))
|
||||
(system l))
|
||||
\end{scheme}
|
||||
\end{note}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{external-exists?}{ entry} {procedure}
|
||||
\proto{external-exists?}{ entry library} {procedure}}
|
||||
\saut
|
||||
|
||||
Returns \schtrue{} if \var{entry} is defined as an external symbol in
|
||||
\var{library}. If \var{library} is not provided the symbol is searched
|
||||
in the \stk{} interpreter or in libraries that it uses.
|
||||
This function can be useful to define external functions conditionally:
|
||||
\begin{scheme}
|
||||
(when (external-exists? "dup2")
|
||||
(define-external dup2 ((oldfd :int) (newfd :int))
|
||||
:return-type :int))
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{c-string->string}{ str} {procedure}}
|
||||
\saut
|
||||
|
||||
STk strings are more general than C strings since they accept null
|
||||
character. \ide{c-string->string} takes an area of characters built
|
||||
by a call to a foreign function (typically the result of a function
|
||||
returning a \texttt{:static-ptr}, \texttt{:dynamic-ptr} or
|
||||
\texttt{:string}) and convert it to a proper Scheme string.
|
||||
\begin{scheme}
|
||||
(define-external sprintf ((str :string) (format :string) . l)
|
||||
:return-type :int)
|
||||
|
||||
\verb+(let ((str (make-string 5 #\?)))+
|
||||
\verb+ (sprintf str "%x" 100)+
|
||||
\verb+ (cons str (C-string->string str)))+
|
||||
\lev \verb+("64\0??" . "64")+
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%%%%
|
||||
%%%% Section 6.24: Misc
|
||||
%%%%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
\subsection{Miscellaneous}
|
||||
|
||||
This section lists the primitives defined in {\stk} that did not fit
|
||||
anywhere else.
|
||||
|
||||
\begin{entry}{
|
||||
\proto{eval}{ \hyper{expr}}{syntax}
|
||||
\proto{eval}{ \hyper{expr} \hyper{environment}}{syntax}}
|
||||
\saut
|
||||
Evaluates \hyper{expr} in the given environment. \hyper{Environment} may be
|
||||
omitted, in which case it defaults to the global environment.
|
||||
\begin{scheme}
|
||||
(define foo (let ((a 1)) (lambda () a)))
|
||||
(foo) \ev 1
|
||||
(eval '(set! a 2) (procedure-environment foo))
|
||||
(foo) \ev 2
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{version}{} {procedure}}
|
||||
\saut
|
||||
returns a string identifying the current version of {\stk}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{machine-type}{} {procedure}}
|
||||
\saut
|
||||
returns a string identifying the kind of machine which is running the
|
||||
interpreter. The form of the result is {\tt [os-name]-[os-version]-[processor-type]}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{random}{ n} {procedure}}
|
||||
\saut
|
||||
returns an integer in the range 0, $\var{n}-1$ inclusive.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{set-random-seed!} { seed} {procedure}}
|
||||
\saut
|
||||
Set the random seed to the specified \var{seed}. {\tt Seed} must be an integer
|
||||
which fits in a C {\tt long int}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{eval-string}{ string environment} {procedure}}
|
||||
\saut
|
||||
Evaluates the contents of the given \var{string} in the given
|
||||
\var{environment} and returns its result.
|
||||
If \var{environment} is omitted it defaults to the global
|
||||
environment. If evaluation leads to an error, the result of \ide{eval-string}
|
||||
is undefined.
|
||||
\begin{scheme}
|
||||
(define x 1)
|
||||
(eval-string "(+ x 1)") \lev 2
|
||||
(eval-string "x" (let ((x 2)) (the-environment))) \lev 2
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{read-from-string}{ \hyper{string}} {procedure}}
|
||||
\saut
|
||||
Performs a read from the given \var{string}. If \var{string} is the empty
|
||||
string, an end of file object is returned. If an error occurs during string
|
||||
reading, the result of \ide{read-from-string} is undefined.
|
||||
\begin{scheme}
|
||||
(read-from-string "123 456") \lev 123
|
||||
(read-from-string "") \lev an eof object
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{dump}{ string} {procedure}}
|
||||
\saut
|
||||
\ide{Dump} grabs the current continuation
|
||||
\mainindex{continuation} and creates an image of the current {\stk}
|
||||
interpreter in the file whose name is \var{string}{\footnote{
|
||||
Image creation is not yet implemented on all systems. The current version
|
||||
(\stkversion) allows image dumping only on some platforms:
|
||||
SunOs~4.1.x, Linux~1, FreeBsd}}.
|
||||
This image can be used later to restart the interpreter from the saved
|
||||
state. See the {\stk} man page about the {\tt -image} option for more details.
|
||||
|
||||
\begin{note}
|
||||
Image creation cannot be done if Tk is initialized.
|
||||
\end{note}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{trace-var}{ symbol thunk} {procedure}}
|
||||
\saut
|
||||
\ide{Trace-var} call the given \var{thunk} when the value
|
||||
of the variable denoted by \var{symbol} is changed.
|
||||
\begin{scheme}
|
||||
(define x 1)
|
||||
(define y 0)
|
||||
(trace-var 'x (lambda () (set! y 1)))
|
||||
(set! x 2)
|
||||
(cons x y) \lev (2 . 1)
|
||||
\end{scheme}
|
||||
|
||||
\begin{note}
|
||||
Several traces can be associated with a single symbol. They are executed in
|
||||
reverse order to their definition. For instance, the execution of
|
||||
\begin{scheme}
|
||||
(begin
|
||||
(trace-var 'z (lambda () (display "One")))
|
||||
(trace-var 'z (lambda () (display "Two")))
|
||||
(set! z 10))
|
||||
\end{scheme}
|
||||
will display the string {\tt"Two"} before the string {\tt"One"} on the
|
||||
current output port.
|
||||
\end{note}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{untrace-var}{ symbol} {procedure}}
|
||||
\saut
|
||||
Deletes all the traces associated to the variable denoted by \var{symbol}.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{error}{ string \vri{string} \vrii{obj} \dotsfoo}{procedure}}
|
||||
\saut
|
||||
\ide{error} prints the \var{obj}s according to the specification given in
|
||||
\var{string} on the current error port (or in an error window if Tk is
|
||||
initialized\index{Tk toolkit}\index{toolkit}). The specification string
|
||||
follows the ``tilde conventions'' of \ide{format}(see \ref{format}). Once the
|
||||
message is printed, execution returns to toplevel.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{gc}{}{procedure}}
|
||||
\saut
|
||||
Runs the garbage collector. See \ref{GCSTART} for the signals associated to
|
||||
garbage collection.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{gc-stats}{}{procedure}}
|
||||
\saut %
|
||||
Provides some statistics about current memory usage. This procedure is
|
||||
primarily for debugging the {\stk} interpreter, hence its weird
|
||||
printing format.
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{expand-heap}{ n}{procedure}}
|
||||
\saut %
|
||||
Expand the heap so that it will contains at least \var{n}
|
||||
cells. Normally, the heap automatically grows when more memory is needed.
|
||||
However, using only automatic heap growing is sometimes very penalizing.
|
||||
This is particularly true for programs which uses a lot of temporary data
|
||||
(which are not pointed by any a variable) and a small amount of global
|
||||
data. In this case, the garbage collector will be often called and the heap
|
||||
will not be automatically expanded (since most of the consumed heap will be
|
||||
reclaimed by the GC). This could be annoying specially for program where
|
||||
response time is critical. Using \ide{expand-heap} permits to enlarge
|
||||
the heap size (which is set to 20000 cells by default), to avoid those
|
||||
continual calls to the GC.
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{get-internal-info}{}{procedure}}
|
||||
\saut %
|
||||
Returns a 7-length vector which contains the following informations:
|
||||
\begin{enumerate}
|
||||
\item[0] total cpu used in milli-seconds
|
||||
\item[1] number of cells currently in use.
|
||||
\item[2] total number of allocated cells
|
||||
\item[3] number of cells used since the last call to \ide{get-internal-info}
|
||||
\item[4] number of gc runs
|
||||
\item[5] total time used in the gc
|
||||
\item[6] a boolean indicating if Tk is initialized
|
||||
\end{enumerate}
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{
|
||||
\proto{sort}{ obj predicate}{procedure}}
|
||||
\saut
|
||||
\var{Obj} must be a list or a vector. \ide{Sort} returns a copy of \var{obj} sorted
|
||||
according to \var{predicate}. \var{Predicate} must be a procedure which takes
|
||||
two arguments and returns a true value if the first argument is strictly ``before''
|
||||
the second.
|
||||
\begin{scheme}
|
||||
(sort '(1 2 -4 12 9 -1 2 3) <)
|
||||
\ev (-4 -1 1 2 2 3 9 12)
|
||||
(sort \sharpsign("one" "two" "three" "four")
|
||||
(lambda (x y) (> (string-length x) (string-length y))))
|
||||
\ev \sharpsign("three" "four" "one" "two")
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\label{uncode}
|
||||
\proto{uncode}{ form}{procedure}}
|
||||
\saut %
|
||||
When {\stk} evaluates an expression it encodes it so that further
|
||||
evaluations of this expression will be more efficient. Since encoded
|
||||
forms are generally difficult to read, \ide{uncode} can be used to
|
||||
(re-)obtain the original form.
|
||||
\begin{scheme}
|
||||
(define (foo a b)
|
||||
(let ((x a) (y (+ b 1))) (cons x y)))
|
||||
|
||||
(procedure-body foo)
|
||||
\ev (lambda (a b)
|
||||
(let ((x a) (y (+ b 1))) (cons x y)))
|
||||
(foo 1 2) \ev (1 . 3)
|
||||
(procedure-body foo)
|
||||
\ev (lambda (a b)
|
||||
({\sharpsign}let (x y)
|
||||
({\sharpsign}<local a @0,0)>
|
||||
({\sharpsign}<global +> {\sharpsign}<local b @0,1)> 1))
|
||||
({\sharpsign}<global cons> {\sharpsign}<local x @0,0)>
|
||||
{\sharpsign}<local y @0,1)>)))
|
||||
|
||||
(uncode (procedure-body foo))
|
||||
\ev (lambda (a b)
|
||||
(let ((x a) (y (+ b 1))) (cons x y)))
|
||||
\end{scheme}
|
||||
|
||||
\begin{note}
|
||||
When a macro has been directly expanded into the macro call code, it is not
|
||||
possible to retrieve the original macro call. Set \ide{*debug*} to
|
||||
{\schtrue} to avoid macro expansion in-lining.
|
||||
\end{note}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{
|
||||
\proto{time} { \hyper{expr}}{macro}}
|
||||
\saut
|
||||
Evaluates the expression \hyper{expr} in the current environment. Prints the
|
||||
elapsed CPU time and the number of conses used before returning the result of
|
||||
this evaluation.
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{apropos}{ symbol}{ procedure}}
|
||||
\saut
|
||||
\ide{Apropos} returns a list of symbol whose print name contains the characters
|
||||
of \var{symbol}. Symbols are searched for in the current environment.
|
||||
\begin{scheme}
|
||||
(apropos 'cadd) \lev (caddar caddr cadddr)
|
||||
\end{scheme}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{inspect}{ obj}{ procedure}}
|
||||
\saut %
|
||||
\ide{Inspect} permits to graphically inspect an object. The first call
|
||||
of this procedure creates a top level window containing the object to
|
||||
inspect and its current value. If the inspector window is already on
|
||||
screen, \var{obj} will be appended to the list of inspected objects.
|
||||
The inspector window contains menus which permit to call the viewer or
|
||||
detailer on each inspected object. See the on-line documentation for
|
||||
further details. A view of the general inspector is given in figure~1.
|
||||
|
||||
\begin{note}
|
||||
Tk must be initialized to use \ide{inspect}.
|
||||
\end{note}
|
||||
|
||||
\begin{figure}
|
||||
\centerline{\psfig{figure={Inspector.ps}}}
|
||||
\caption{A view of the Inspector}
|
||||
\end{figure}
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{view}{ obj}{ procedure}}
|
||||
\saut %
|
||||
\ide{View} permits to obtain a graphical representation of an {\stk}
|
||||
object. The type of representation depends on the type of the viewed
|
||||
object. Here again, menus are provided to switch to the inspector or
|
||||
to the detailer. See the on-line documentation for more details. A
|
||||
snapshot of the viewer is given in figure~2.
|
||||
|
||||
\begin{note}
|
||||
Tk must be initialized to use \ide{view}.
|
||||
\end{note}
|
||||
|
||||
\begin{figure}
|
||||
\centerline{\psfig{figure={View.ps}}}
|
||||
\caption{A view of the Viewer}
|
||||
\end{figure}
|
||||
|
||||
\end{entry}
|
||||
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{detail}{ obj}{ procedure}}
|
||||
\saut %
|
||||
\ide{detail} permits to display the fields of a composite Scheme
|
||||
object. The type of detailer depends on the type of the composite
|
||||
object detailed. Here again, menus are provided to go to the inspector
|
||||
or to the viewer. See the on-line documentation for more details.
|
||||
Figure~3 shows the detailer examining a {\em tk-command}.
|
||||
|
||||
\begin{note}
|
||||
Tk must be initialized to use \ide{detail}.
|
||||
\end{note}
|
||||
|
||||
\begin{figure}
|
||||
\centerline{\psfig{figure={Detail.ps}}}
|
||||
\caption{A view of the Detailer}
|
||||
\end{figure}
|
||||
\end{entry}
|
||||
|
||||
\begin{entry}{%
|
||||
\proto{quit}{ retcode} {procedure}
|
||||
\proto{quit}{} {procedure}
|
||||
\proto{exit}{ retcode} {procedure}
|
||||
\proto{exit}{} {procedure}
|
||||
\proto{bye}{ retcode} {procedure}
|
||||
\proto{bye}{} {procedure}}
|
||||
\saut
|
||||
Exits the {\stk} interpreter with the specified integer return code. If
|
||||
omitted, the interpreter terminates with a return code of 0.
|
||||
\end{entry}
|
||||
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "manual"
|
||||
%%% End:
|
||||
Binary file not shown.
+8364
-5833
File diff suppressed because it is too large
Load Diff
@@ -13,12 +13,14 @@
|
||||
%
|
||||
% Author: Erick Gallesio [eg@unice.fr]
|
||||
% Creation date: ??-Nov-1993 ??:??
|
||||
% Last file update: 24-Jul-1996 13:53
|
||||
% Last file update: 10-Apr-1998 09:07
|
||||
%
|
||||
|
||||
\documentclass[10pt,a4paper]{book}
|
||||
\usepackage{a4wide}
|
||||
\usepackage{fancyheadings}
|
||||
\usepackage{epsfig}
|
||||
%\usepackage{times}
|
||||
\pagestyle{fancy}
|
||||
\setlength{\headheight}{15pt}
|
||||
|
||||
@@ -27,7 +29,6 @@
|
||||
\begin{document}
|
||||
|
||||
\input{commands} % Stolen macros from R4RS
|
||||
\input{psfig} % Postscript stuff
|
||||
\parindent 0pt % No indentation at paragraph
|
||||
% beginning
|
||||
\bibliographystyle{unsrt} % Unsorted bibliography
|
||||
@@ -43,7 +44,7 @@
|
||||
%
|
||||
% Some new commands
|
||||
%
|
||||
\newcommand{\stkversion}{3.1}
|
||||
\newcommand{\stkversion}{3.99}
|
||||
\newcommand{\stk}{{\sc STk}}
|
||||
\newcommand{\stklos}{{\sc STklos}}
|
||||
\newcommand{\doc}{{\em Identical to R$^{4}$RS.}}
|
||||
@@ -74,7 +75,7 @@ email: eg@unice.fr}
|
||||
\end{center}
|
||||
\vskip8cm
|
||||
\begin{flushright}
|
||||
July 1996
|
||||
April 1998
|
||||
\end{flushright}
|
||||
\newpage
|
||||
\thispagestyle{empty}
|
||||
@@ -82,7 +83,7 @@ July 1996
|
||||
\vskip2cm
|
||||
{\bf Document Reference}
|
||||
\begin{quote}
|
||||
Erick Gallesio, {\em STk Reference Manual}, RT 95-31b,
|
||||
Erick Gallesio, {\em STk Reference Manual}, RT 95-31d,
|
||||
I3S-CNRS~/~Universit\'e de Nice - Sophia Antipolis, juillet 1995.
|
||||
\end{quote}
|
||||
|
||||
@@ -117,6 +118,7 @@ I3S-CNRS~/~Universit\'e de Nice - Sophia Antipolis, juillet 1995.
|
||||
\thispagestyle{plain}
|
||||
\input{Reference1.tex}
|
||||
\input{Reference2.tex}
|
||||
\input{Reference3.tex}
|
||||
|
||||
%
|
||||
% Annexes
|
||||
@@ -134,9 +136,15 @@ I3S-CNRS~/~Universit\'e de Nice - Sophia Antipolis, juillet 1995.
|
||||
\chapter{An introduction to {\stklos}}
|
||||
\input{Appendix-C}
|
||||
|
||||
\chapter{Miscellaneous Informations}
|
||||
\chapter{Modules: Examples}
|
||||
\input{Appendix-D}
|
||||
|
||||
\chapter{Changes}
|
||||
\input{Appendix-E}
|
||||
|
||||
\chapter{Miscellaneous Informations}
|
||||
\input{Appendix-F}
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\bibliography{bibliography}
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
Reference in New Issue
Block a user