Commit 0ab0a470 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2005-06-24 11:22:54 by beppe] Empty log message

Original author: beppe
Date: 2005-06-24 11:22:54+00:00
parent bba6b878
......@@ -270,7 +270,21 @@ variable <code>parents</code> it matches it against the type
type <code>ParentBook</code>) then it performs the assignment (the variable
<code>x</code> is bound to the result of the load_xml expression by the pattern
<code>x&amp;ParentBook</code>) otherwise it raises an exception.
Of course an exception such as "parents.xml is not a document of type ParentBook" it is not
very informative about why the document failed the match an where the error might be. In CDuce it is
possible to ask the program to perform this check and raise an informative exception (a string
that describes and localize the problem) by using the dynamic type check construction <code>(%%e%%:?%%t%%)</code> which
checks whether the expression <code>%%exp%%</code> has type <code>%%t%%</code> and it either returns the result of
<code>%%exp%%</code> or raise an informative exception. The dynamic type check can be also used in a let construction as follows
let parents :? ParentBook = load_xml "parents.xml"
which does the same test as the previous program but in case of failure give
information to the programmer on the reasons why the type check failed.
The command <code>load_xml "parents.xml"</code> is just an abbreviated form for
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment