58 lines
1.8 KiB
TeX
58 lines
1.8 KiB
TeX
|
\section{Evaluating expression in ``safe'' environments}
|
||
|
%
|
||
|
\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}
|
||
|
%
|
||
|
|
||
|
\subsection{Overview}
|
||
|
\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.
|
||
|
|
||
|
\subsection{The \protect{\texttt{loser}} package}
|
||
|
The \ex{loser} package exports only one procedure:
|
||
|
|
||
|
\begin{defundesc}{loser}{name}{nothing}
|
||
|
Raises an error like ``Illegal call \var{name}''.
|
||
|
\end{defundesc}
|
||
|
|
||
|
\subsection{The \protect{\texttt{toothless}} package}
|
||
|
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.
|
||
|
|
||
|
\subsection{The \protect{\texttt{toothless-eval}} package}
|
||
|
|
||
|
\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
|
||
|
%%% TeX-master: t
|
||
|
%%% End:
|