2002-08-21 10:52:34 -04:00
|
|
|
\chapter{Evaluating expression in ``safe'' environments}
|
2002-02-12 06:50:54 -05:00
|
|
|
%
|
|
|
|
\begin{description}
|
|
|
|
\item[Used files:] none, defined in modules.scm
|
|
|
|
\item[Name of the package:] loser, toothless, toothless-eval \\
|
|
|
|
(you want the last one)
|
|
|
|
\end{description}
|
|
|
|
%
|
|
|
|
|
2002-08-21 10:52:34 -04:00
|
|
|
\section{Overview}
|
2002-02-12 06:50:54 -05:00
|
|
|
\FIXME{Is toothless really R5RS, too?}
|
|
|
|
These modules define an environment that is \RnRS without features that
|
|
|
|
could examine or effect the file system. You can also use it as a
|
|
|
|
model of how to execute code in other protected environments in \scm.
|
|
|
|
|
2002-08-21 10:52:34 -04:00
|
|
|
\section{The \protect{\texttt{loser}} package}
|
2002-02-12 06:50:54 -05:00
|
|
|
The \ex{loser} package exports only one procedure:
|
|
|
|
|
|
|
|
\begin{defundesc}{loser}{name}{nothing}
|
|
|
|
Raises an error like ``Illegal call \var{name}''.
|
|
|
|
\end{defundesc}
|
|
|
|
|
2002-08-21 10:52:34 -04:00
|
|
|
\section{The \protect{\texttt{toothless}} package}
|
2002-02-12 06:50:54 -05:00
|
|
|
The \ex{toothless} package contains everything of \RnRS except
|
|
|
|
that following procedure cause an error if called:
|
|
|
|
\begin{itemize}
|
|
|
|
\item \ex{call-with-input-file}
|
|
|
|
\item \ex{call-with-output-file}
|
|
|
|
\item \ex{load}
|
|
|
|
\item \ex{open-input-file}
|
|
|
|
\item \ex{open-output-file}
|
|
|
|
\item \ex{transcript-on}
|
|
|
|
\item \ex{with-input-from-file}
|
|
|
|
\item \ex{with-input-to-file}
|
|
|
|
\item \ex{eval}
|
|
|
|
\item \ex{interaction-environment}
|
|
|
|
\item \ex{scheme-report-environment}
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
So, \ex{toothless} creates an environment as described in
|
|
|
|
\emph{Overview} above.
|
|
|
|
|
2002-08-21 10:52:34 -04:00
|
|
|
\section{The \protect{\texttt{toothless-eval}} package}
|
2002-02-12 06:50:54 -05:00
|
|
|
|
|
|
|
\begin{defundesc}{eval-safely} {expression} {any result}
|
|
|
|
Creates a brand new package, imports the \ex{toothless} structure,
|
|
|
|
and evaluates \semvar{expression} in it. When the evaluation is
|
|
|
|
done, the environment is thrown away, so \semvar{expression}'s
|
|
|
|
side-effects don't persist from one \ex{eval\=safely} call to the
|
|
|
|
next. If \semvar{expression} raises an error exception, we abort and
|
|
|
|
return \sharpf.
|
|
|
|
\end{defundesc}
|
|
|
|
|
|
|
|
%%% Local Variables:
|
|
|
|
%%% mode: latex
|
2003-01-08 09:14:32 -05:00
|
|
|
%%% TeX-master: "man"
|
2002-02-12 06:50:54 -05:00
|
|
|
%%% End:
|