diff options
author | Alain Frisch <alain@frisch.fr> | 2015-11-30 14:11:01 +0100 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2015-11-30 14:11:01 +0100 |
commit | d2e6aa14fa171cda13067fcc87530d1c37dba7c6 (patch) | |
tree | 8755c0affe0ba59cc6de3d4ba360eaed5b028691 | |
parent | 33e6f7bf83f2bf801fe7ded3cf178982c0efe5cc (diff) | |
download | ocaml-d2e6aa14fa171cda13067fcc87530d1c37dba7c6.tar.gz |
Promote 'assert' to core language.
-rw-r--r-- | manual/manual/refman/expr.etex | 30 | ||||
-rw-r--r-- | manual/manual/refman/exten.etex | 29 |
2 files changed, 29 insertions, 30 deletions
diff --git a/manual/manual/refman/expr.etex b/manual/manual/refman/expr.etex index 4e9548ff84..999dd95b9f 100644 --- a/manual/manual/refman/expr.etex +++ b/manual/manual/refman/expr.etex @@ -69,6 +69,7 @@ expr: | '(' expr ':>' typexpr ')' | '(' expr ':' typexpr ':>' typexpr ')' | '{<' [ inst-var-name '=' expr { ';' inst-var-name '=' expr } [';'] ] '>}' + | 'assert' expr ; %BEGIN LATEX \end{syntax} \begin{syntax} @@ -116,7 +117,7 @@ precedence come first. For infix and prefix symbols, we write \entree{". .( .[ .{" (see section~\ref{s:bigarray-access})}{--} \entree{"#"\ldots}{--} \entree{function application, constructor application, tag - application, "assert" (see~\ref{s:assert}), + application, "assert", "lazy" (see~\ref{s:lazy})}{left} \entree{"- -." (prefix)}{--} \entree{"**"\ldots" lsl lsr asr"}{right} @@ -834,4 +835,31 @@ For abstract and private types, the variance must be given explicitly otherwise the default is nonvariant. This is also the case for constrained arguments in type definitions. + +\subsection{Other} + +\subsubsection*{Assertion checking} + + +\ikwd{assert\@\texttt{assert}} + +OCaml supports the @"assert"@ construct to check debugging assertions. +The expression @"assert" expr@ evaluates the expression @expr@ and +returns @"()"@ if @expr@ evaluates to @"true"@. If it evaluates to +@"false"@ the exception +"Assert_failure" is raised with the source file name and the +location of @expr@ as arguments. Assertion +checking can be turned off with the "-noassert" compiler option. In +this case, @expr@ is not evaluated at all. + +As a special case, @"assert false"@ is reduced to +@'raise' '('@"Assert_failure ..."@')'@, which gives it a polymorphic +type. This means that it can be used in place of any expression (for +example as a branch of any pattern-matching). It also means that +the @"assert false"@ ``assertions'' cannot be turned off by the +"-noassert" option. +% +\index{Assertfailure\@\verb`Assert_failure`} + + %% \newpage diff --git a/manual/manual/refman/exten.etex b/manual/manual/refman/exten.etex index 8e0a9fe334..ad4e4f029e 100644 --- a/manual/manual/refman/exten.etex +++ b/manual/manual/refman/exten.etex @@ -103,35 +103,6 @@ An expression @@e@@ is said to be {\em immediately linked to} the variable is immediately linked to @name@. \end{itemize} -\section{Assertion checking}\label{s:assert} -\ikwd{assert\@\texttt{assert}} - -(Introduced in Objective Caml 1.06) - -\begin{syntax} -expr: ... - | 'assert' expr -\end{syntax} - -OCaml supports the @"assert"@ construct to check debugging assertions. -The expression @"assert" expr@ evaluates the expression @expr@ and -returns @"()"@ if @expr@ evaluates to @"true"@. If it evaluates to -@"false"@ the exception -"Assert_failure" is raised with the source file name and the -location of @expr@ as arguments. Assertion -checking can be turned off with the "-noassert" compiler option. In -this case, @expr@ is not evaluated at all. - -As a special case, @"assert false"@ is reduced to -@'raise' '('@"Assert_failure ..."@')'@, which gives it a polymorphic -type. This means that it can be used in place of any expression (for -example as a branch of any pattern-matching). It also means that -the @"assert false"@ ``assertions'' cannot be turned off by the -"-noassert" option. -% -\index{Assertfailure\@\verb`Assert_failure`} - - \section{Lazy evaluation} \label{s:lazy} \ikwd{lazy\@\texttt{lazy}} |