1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
\subsection{error}
\label{laberror}
\noindent Name: \textbf{error}\\
\phantom{aaa}expression representing an input that is wrongly typed or that cannot be executed\\[0.2cm]
\noindent Library names:\\
\verb| sollya_obj_t sollya_lib_error()|\\
\verb| int sollya_lib_obj_is_error(sollya_obj_t)|\\[0.2cm]
\noindent Usage:
\begin{center}
\textbf{error} : \textsf{error}\\
\end{center}
\noindent Description: \begin{itemize}
\item The variable \textbf{error} represents an input during the evaluation of
which a type or execution error has been detected or is to be
detected. Inputs that are syntactically correct but wrongly typed
evaluate to \textbf{error} at some stage. Inputs that are correctly typed
but containing commands that depend on side-effects that cannot be
performed or inputs that are wrongly typed at meta-level (cf. \textbf{parse}),
evaluate to \textbf{error}.
Remark that in contrast to all other elements of the \sollya language,
\textbf{error} compares neither equal nor unequal to itself. This provides a
means of detecting syntax errors inside the \sollya language itself
without introducing issues of two different wrongly typed inputs being
equal.
\end{itemize}
\noindent Example 1:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> print(5 + "foo");
error
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 2:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> error;
error
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 3:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> error == error;
false
> error != error;
false
\end{Verbatim}
\end{minipage}\end{center}
\noindent Example 4:
\begin{center}\begin{minipage}{15cm}\begin{Verbatim}[frame=single]
> correct = 5 + 6;
> incorrect = 5 + "foo";
> correct == correct;
true
> incorrect == incorrect;
false
> errorhappened = !(incorrect == incorrect);
> errorhappened;
true
\end{Verbatim}
\end{minipage}\end{center}
See also: \textbf{void} (\ref{labvoid}), \textbf{parse} (\ref{labparse}), \textbf{$==$} (\ref{labequal}), \textbf{!$=$} (\ref{labneq})
|