summaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
Diffstat (limited to 'manual')
-rw-r--r--manual/manual/refman/exten.etex24
-rw-r--r--manual/manual/refman/typedecl.etex4
2 files changed, 25 insertions, 3 deletions
diff --git a/manual/manual/refman/exten.etex b/manual/manual/refman/exten.etex
index 18309a9143..28e9c0deb4 100644
--- a/manual/manual/refman/exten.etex
+++ b/manual/manual/refman/exten.etex
@@ -1503,7 +1503,7 @@ typedef: ...
| typedef item-attribute
;
exception-definition:
- 'exception' constr-name { attribute } [ 'of' typexpr { '*' typexpr } ]
+ 'exception' constr-decl
| 'exception' constr-name '=' constr
;
module-items:
@@ -2096,3 +2096,25 @@ let invalid = function
| Point p -> p (* INVALID *)
| ...
\end{verbatim}
+
+
+\section{Local exceptions}
+\ikwd{let\@\texttt{let}}
+\ikwd{exception\@\texttt{exception}}
+
+(Introduced in OCaml 4.04)
+
+It is possible to define local exceptions in expressions:
+
+\begin{syntax}
+expr:
+ ...
+ | "let" "exception" constr-decl "in" expr
+\end{syntax}
+
+
+The syntactic scope of the exception constructor is the inner
+expression, but nothing prevents exception values created with this
+constructor from escaping this scope. Two executions of the definition
+above result in two incompatible exception constructors (as for any
+exception definition).
diff --git a/manual/manual/refman/typedecl.etex b/manual/manual/refman/typedecl.etex
index 86f1043022..61315bc4fa 100644
--- a/manual/manual/refman/typedecl.etex
+++ b/manual/manual/refman/typedecl.etex
@@ -201,7 +201,7 @@ appear in the type equation and the type declaration.
\begin{syntax}
exception-definition:
- 'exception' constr-name [ 'of' typexpr { '*' typexpr } ]
+ 'exception' constr-decl
| 'exception' constr-name '=' constr
\end{syntax}
@@ -209,7 +209,7 @@ Exception definitions add new constructors to the built-in variant
type \verb"exn" of exception values. The constructors are declared as
for a definition of a variant type.
-The form @'exception' constr-name ['of' typexpr {'*' typexpr}]@
+The form @'exception' constr-decl@
generates a new exception, distinct from all other exceptions in the system.
The form @'exception' constr-name '=' constr@
gives an alternate name to an existing exception.