Commit 93dca53c authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-05-04 22:56:22 by beppe] Started a page on references

Original author: beppe
Date: 2004-05-04 22:56:22+00:00
parent 964db0ff
......@@ -9,6 +9,7 @@
<include file="tutorial/overloading.xml"/>
<include file="tutorial/patterns.xml"/>
<include file="tutorial/errors.xml"/>
<include file="tutorial/references.xml"/>
<include file="tutorial/queries.xml"/>
<include file="tutorial/higherorder.xml"/>
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<page name="tutorial_references">
You can cut and paste the code on this page and
test it on the <a href="cgi-bin/cduce">online interpreter</a>.
<box title="Introduction" link="xpath">
<b style="color:#FF0080">TO BE DONE (for the moment see the user manual</b>
<box title="Advanced programming" link="sel">
The fact that reference types are encoded rather than primitives have some advantaes. Noteworthy is the fact that our encoding allows the programmer to modify the default beahvior of the <code>get</code> and <code>set</code> functions can be modified. So a programmer can define a reference that whenever is read, records the access in a log file, or it performs some sanity checks before performing a writing.
For instance ... (write some code here of the form
let x =
let hidden = ref Int 0 in
{ get = %%some extra code%%; hidden.get ;
set = function (x:Int):[]
if %%some condition%%
then hidden.set(x)
else raise %%some exeption%%
However use the encoding also cause some weirdness ...
<b style="color:#FF0080">TO BE DONE</b>
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