Commit ef6ddbec authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-07-27 15:12:12 by cvscast] Doc references

Original author: cvscast
Date: 2003-07-27 15:12:56+00:00
parent facad96d
......@@ -50,9 +50,8 @@ Important notes:
Efficiency issues:
- OCamlnet: if you plan to load XML file with encodings other than
UTF-8, it is advised to use the CVS version of OCamlnet:
http://sourceforge.net/cvs/?group_id=19774
Indeed, the netconversion module in the latest release (0.95) was
UTF-8, it is advised to use a recent version of OCamlnet (>= 0.96).
Indeed, the netconversion module in the previous release (0.95) was
very slow, and it has been rewritten since then.
------------------------------------------------------------------------------
......
include Makefile.conf
VERSION = 0.1.0
VERSION = 0.1.1
PACKAGES = pxp-engine pxp-lex-iso88591 wlexing camlp4 num cgi pcre netstring
ifeq ($(PXP_WLEX), true)
......
......@@ -49,6 +49,9 @@ Syntactic sugar for projection.
How to perform XSLT-like transformations.
</example>
<example code="reference" title="References">
Mutable values.
</example>
</examples>
......
let stack = ref [Int*] []
let fun push(x : Int) : [] =
stack := (x, !stack)
let fun pop ([] : []) : Int =
match !stack with (x, y) -> stack := y; x | _ -> raise "Empty stack"
;;
push 1;;
push 2;;
push 3;;
pop [];;
pop [];;
pop [];;
pop [];;
......@@ -599,4 +599,27 @@ See <local href="namespaces"/> for more details.
</box>
<box title="References" link="ref">
<p>
The construction <code>ref %%T%% %%e%%</code> is used to build a
<em>reference</em> initialized with the result of the expression
<code>%%e%%</code>; later, the reference can receive any value
of type <code>%%T%%</code>. The reference is actually a value of type
<code>{| get = [] -> T ; set = T -> [] |}</code>.
</p>
<p>
Three syntactic sugar constructions are provided to facilitate
the use of references:
</p>
<sample>
!%%e%% === %%e%%.get [] {{ Dereferencing }}
%%e1%% := %%e2%% === %%e1%%.set %%e2%% {{ Assignment }}
%%e1%% ; %%e2%% === let [] = %%e1%% in %%e2%% {{Sequencing}}
</sample>
</box>
</page>
......@@ -511,4 +511,17 @@ Functional types have no counterpart in patterns.
</box>
<box title="References" link="ref">
<p>
References are mutable memory cells. CDuce has no built-in
reference type. Instead, references are implemented
in an object-oriented way. The type <code>ref %%T%%</code>
denotes references of values of type <code>%%T%%</code>. It
is only syntactic sugar for the type
<code>{| get = [] -> T ; set = T -> [] |}</code>.
</p>
</box>
</page>
......@@ -202,6 +202,17 @@ Tn = tn</code>.</li>
</ul>
</box>
<box title="References" link="ref">
<ul>
<li>Type: <code>ref %%T%%</code>.</li>
<li>Construction: <code>ref %%T%% %%e%%</code>.</li>
<li>Dereferencing: <code>!%%e1%%</code>.</li>
<li>Assignment: <code>%%e1%% := %%e2%%</code>.</li>
</ul>
</box>
<box title="Toplevel statements" link="toplevel">
<ul>
<li>Global expression to evaluate.</li>
......
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