Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
edb1fa6a
Commit
edb1fa6a
authored
Oct 05, 2007
by
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
bc8567a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
web/tutorial/getting_started.xml
View file @
edb1fa6a
...
...
@@ -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
&
ParentBook
</code>
) otherwise it raises an exception.
</p>
<p>
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
</p>
<sample>
<![CDATA[
let parents :? ParentBook = load_xml "parents.xml"
]]>
</sample>
<p>
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.
</p>
<p>
The command
<code>
load_xml "parents.xml"
</code>
is just an abbreviated form for
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment