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
e40bd112
Commit
e40bd112
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2004-07-04 01:16:43 by afrisch] Doc
Original author: afrisch Date: 2004-07-04 01:17:46+00:00
parent
3e6e8fbf
Changes
13
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
e40bd112
...
...
@@ -10,6 +10,10 @@
* Allow structured constants in default value patterns (p := c)
* Default value patterns in regexps don't consume an element.
* Logical operators &&, ||, and not
- Incompatible changes:
* argv is now an operator of type [] -> [ String* ]
* the --dump, --load, --save options are deprecated
- Implementation:
* Code upgraded to Ocaml 3.07.
...
...
@@ -22,7 +26,7 @@
- Other:
* Added configure script.
* Various Makefile improvments
* Various Makefile improv
e
ments
- OCaml/CDuce interface
...
...
doc/cduce.1
View file @
e40bd112
.\" $Header: /cvsroot/cduce/doc/cduce.1,v 1.1
2
2004/07/0
3
0
9:30:38
afrisch Exp $
.\" $Header: /cvsroot/cduce/doc/cduce.1,v 1.1
3
2004/07/0
4
0
1:16:43
afrisch Exp $
.\"
.\" transcript compatibility for postscript use.
.\"
...
...
@@ -58,110 +58,16 @@ cduce \(em The CDuce compiler/interpreter/toplevel
.PP
\fBcduce\fR [ \fBOPTIONS\fP \&...] [\fB--arg \fBargument\fP\fP \&...]
.PP
\fBcduce\fR [ \fBOPTIONS\fP \&...] [
\fB\fBfile
[
.cd
]
\fP\fP] [\fB--arg \fBargument\fP\fP \&...]
\fBcduce\fR [ \fBOPTIONS\fP \&...] [\fB
\fBfile.cd\fP
| --stdin
\fP] [\fB--arg \fBargument\fP\fP \&...]
.PP
\fBcduce --compile\fR [ \fBOPTIONS\fP \&...] [
\fB\fBfile
[
.cd
]
\fP\fP]
\fBcduce --compile\fR [ \fBOPTIONS\fP \&...] [ \fB\fBfile.cd\fP\fP
]
.PP
\fBcduce --run\fR [ \fBOPTIONS\fP \&...] [ \fB\fBfile
[
.cdo
]
\fP\fP \&...] [\fB--arg \fBargument\fP\fP \&...]
\fBcduce --run\fR [ \fBOPTIONS\fP \&...] [ \fB\fBfile.cdo\fP\fP \&...] [\fB--arg \fBargument\fP\fP \&...]
.SH "Description"
.PP
According to the command line arguments,
the \fBcduce\fR command behaves
either as an interactive toplevel, an interpreter, a compiler, or
a loader.
See the CDuce users' manual:
When no input file is given, the command operates as an interactive
toplevel. Toplevel phrases are processed after each
\fB;;\fR. Mutually recursive declarations of types or
functions must be contained in a single adjacent sequence of phrases
(without \fB;;\fR inbetween).
With the \fB--compile\fP option,
the command produces a .cdo file with intermediate code.
One or several .cdo files can be run
later by \fBcduce --run\fR.
When a .cd file is given, but not the \fB--compile\fP,
the unit is compiled and immediatly evaluated, without
producing a .cdo file.
All the arguments that follow the \fB--arg\fP option are
passed to the CDuce program (useless in \fB--compile\fP mode).
.PP
In order to allow persistence in the toplevel(options
\fB--dump\fP, \fB--load\fP, and
\fB--save\fP) to operate, you must quit the toplevel with
\fB#quit\fR toplevel directive and not with
\fBCtrl-D\fR or \fBCtrl-C\fR. This
persistence mechanism is deprecated since the introduction of separate
compilation and will be removed in future releases.
.SH "CDuce/OCaml interface"
.PP
If the CDuce/OCaml interface is enabled, the compiler
looks for a corresponding \fBfoo.cmi\fP file when
compiling a \fBfoo.cd\fP unit.
The resulting \fBfoo.cdo\fP contains the ML stub code
(to export CDuce values to OCaml, and to import OCaml values into CDuce).
When the unit uses OCaml functions, it is not possible to run it
with the \fB--run\fR option. Instead, you have to compile
and link it with the OCaml linker. Please refer to the man page for the
\fBcdo2ml\fR command.
.SH "Options"
.PP
This program follows usual syntax,
with long options starting with two dashes (`--'). A
summary of the options supported by \fBcduce\fR is included below.
.SS "Generic Options"
.IP "\fB--compile\fP \fBfile\fP" 10
Produce a file in an intermediate code that can be run by
\fBcduce --run\fR.
.IP "\fB--run\fP \fBfiles ...\fP" 10
Execute .cdo files produced by \fBcduce --compile\fR.
.IP "\fB--verbose\fP" 10
(for \fB--compile\fP) Display the type of values in the compiled
unit.
.IP "\fB--obj-dir\fP \fBdir\fP" 10
(for \fB--compile\fP) Set the directory where to create
the .cdo file.
.IP "\fB-I\fP \fBdir\fP" 10
Add \fBdir\fP to the list of directory used to find .cdo and .cmi files.
.IP "\fB--stdin\fP" 10
Read CDuce script on standard input.
.IP "\fB--no\fP feature" 10
Disable one of the built-in optional features. The list
of feature and their symbolic name can be obtained with the
\fB-v\fP option. Can be used
for instance to turn the Expat parser off, in order to use PXP,
if both have been included at compile time.
.IP "\fB--debug\fP" 10
Pprint profiling/debugging information.
.IP "\fB-v\fP, \fB--version\fP" 10
Show version information and exit.
.IP "\fB--license\fP" 10
Show license information and exit.
.IP "\fB--dump \fBfile\fP\fP" 10
(Deprecated)
This option is equivalent to restore the environment previously saved in
\fBfile\fP by the \fB--load \fBfile\fP\fP \fB--save \fBfile\fP\fP.
.IP "\fB--load \fBfile\fP\fP" 10
(Deprecated)
Restore the environment previously saved in
\fBfile\fP by the \fB--save\fP option.
.IP "\fB--save \fBfile\fP\fP" 10
(Deprecated)
This options allows persistence between several invocations of the
interpreter: the current environment (i.e., the set defined types and values) is saved in
\fBfile\fP when the interpreter terminates so that it
can be succesively restored by using \fB--load\fP option
.IP "\fB--help\fP" 10
Display a short help message and exit.
.SS "PROGRAM OPTIONS"
.PP
.IP "\fB--arg \fBarguments\fP\fP" 10
All the arguments following \fB--arg\fP are passed to the CDuce
program. They can be fetched from the CDuce program
with the built-in operator \fBargv\fR (of type \fB[] -> [ String*
]\fR).
\fBhttp://www.cduce.org/manual_interpreter.html\fP.
.SH "Reporting bugs"
.PP
Report bugs to devel@cduce.org.
...
...
@@ -170,9 +76,9 @@ Report bugs to devel@cduce.org.
A complete documentation, reference manual, tutorial, technical articles on
implementation and theoretical issues, benchmarks, source code, mailing lists
and forums can be found on the \fICDuce\fP website:
\fBhttp://www.cduce.org\fP.
\fBhttp://www.cduce.org
/
\fP.
.SH "Authors"
.PP
Alain Frisch <Alain.Frisch@ens.fr>. Small contributions by
Giuseppe Castagna <Giuseppe.Castagna@ens.fr>, Julien Demouth <Julien.Demouth@ens.fr>, and Stefano Zacchiroli <zack@di.ens.fr>.
.\" created by instant / docbook-to-man, S
at
0
3
Jul 2004,
11:28
.\" created by instant / docbook-to-man, S
un
0
4
Jul 2004,
03:11
doc/cduce.docbook
View file @
e40bd112
...
...
@@ -28,9 +28,7 @@
<arg
choice=
"opt"
rep=
"repeat"
>
<option>
OPTIONS
</option>
</arg>
<arg
choice=
"opt"
>
<option><filename>
file[.cd]
</filename></option>
</arg>
<arg
choice=
"opt"
><option>
<filename>
file.cd
</filename>
| --stdin
</option></arg>
<arg
choice=
"opt"
rep=
"repeat"
><option>
--arg
<filename>
argument
</filename></option></arg>
</cmdsynopsis>
...
...
@@ -39,9 +37,7 @@
<arg
choice=
"opt"
rep=
"repeat"
>
<option>
OPTIONS
</option>
</arg>
<arg
choice=
"opt"
>
<option><filename>
file[.cd]
</filename></option>
</arg>
<arg
choice=
"opt"
>
<option><filename>
file.cd
</filename></option>
</arg>
</cmdsynopsis>
<cmdsynopsis>
...
...
@@ -50,7 +46,7 @@
<option>
OPTIONS
</option>
</arg>
<arg
choice=
"opt"
rep=
"repeat"
>
<option><filename>
file
[
.cdo
]
</filename></option>
<option><filename>
file.cdo
</filename></option>
</arg>
<arg
choice=
"opt"
rep=
"repeat"
><option>
--arg
<filename>
argument
</filename></option></arg>
</cmdsynopsis>
...
...
@@ -59,236 +55,10 @@
<refsect1>
<title>
Description
</title>
<para>
According to the command line arguments,
the
<command>
cduce
</command>
command behaves
either as an interactive toplevel, an interpreter, a compiler, or
a loader.
When no input file is given, the command operates as an interactive
toplevel. Toplevel phrases are processed after each
<command>
;;
</command>
. Mutually recursive declarations of types or
functions must be contained in a single adjacent sequence of phrases
(without
<command>
;;
</command>
inbetween).
See the CDuce users' manual:
With the
<option>
--compile
</option>
option,
the command produces a .cdo file with intermediate code.
One or several .cdo files can be run
later by
<command>
cduce --run
</command>
.
When a .cd file is given, but not the
<option>
--compile
</option>
,
the unit is compiled and immediatly evaluated, without
producing a .cdo file.
All the arguments that follow the
<option>
--arg
</option>
option are
passed to the CDuce program (useless in
<option>
--compile
</option>
mode).
<filename>
http://www.cduce.org/manual_interpreter.html
</filename>
.
</para>
<para>
In order to allow persistence in the toplevel(options
<option>
--dump
</option>
,
<option>
--load
</option>
, and
<option>
--save
</option>
) to operate, you must quit the toplevel with
<command>
#quit
</command>
toplevel directive and not with
<command>
Ctrl-D
</command>
or
<command>
Ctrl-C
</command>
. This
persistence mechanism is deprecated since the introduction of separate
compilation and will be removed in future releases.
</para>
</refsect1>
<refsect1>
<title>
CDuce/OCaml interface
</title>
<para>
If the CDuce/OCaml interface is enabled, the compiler
looks for a corresponding
<filename>
foo.cmi
</filename>
file when
compiling a
<filename>
foo.cd
</filename>
unit.
The resulting
<filename>
foo.cdo
</filename>
contains the ML stub code
(to export CDuce values to OCaml, and to import OCaml values into CDuce).
When the unit uses OCaml functions, it is not possible to run it
with the
<command>
--run
</command>
option. Instead, you have to compile
and link it with the OCaml linker. Please refer to the man page for the
<command>
cdo2ml
</command>
command.
</para>
</refsect1>
<refsect1>
<title>
Options
</title>
<para>
This program follows usual syntax,
with long options starting with two dashes (`--'). A
summary of the options supported by
<command>
cduce
</command>
is included below.
</para>
<refsect2>
<title>
Generic Options
</title>
<variablelist>
<varlistentry>
<term><option>
--compile
</option>
<filename>
file
</filename></term>
<listitem>
<para>
Produce a file in an intermediate code that can be run by
<command>
cduce --run
</command>
.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--run
</option>
<filename>
files ...
</filename></term>
<listitem>
<para>
Execute .cdo files produced by
<command>
cduce --compile
</command>
.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--verbose
</option></term>
<listitem>
<para>
(for
<option>
--compile
</option>
) Display the type of values in the compiled
unit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--obj-dir
</option>
<filename>
dir
</filename></term>
<listitem>
<para>
(for
<option>
--compile
</option>
) Set the directory where to create
the .cdo file.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
-I
</option>
<filename>
dir
</filename></term>
<listitem>
<para>
Add
<filename>
dir
</filename>
to the list of directory used to find .cdo and .cmi files.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--stdin
</option></term>
<listitem>
<para>
Read CDuce script on standard input.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--no
</option>
feature
</term>
<listitem>
<para>
Disable one of the built-in optional features. The list
of feature and their symbolic name can be obtained with the
<option>
-v
</option>
option. Can be used
for instance to turn the Expat parser off, in order to use PXP,
if both have been included at compile time.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--debug
</option></term>
<listitem>
<para>
Pprint profiling/debugging information.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
-v
</option>
,
<option>
--version
</option></term>
<listitem>
<para>
Show version information and exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--license
</option></term>
<listitem>
<para>
Show license information and exit.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--dump
<filename>
file
</filename></option></term>
<listitem>
<para>
(Deprecated)
This option is equivalent to restore the environment previously saved in
<filename>
file
</filename>
by the
<option>
--load
<filename>
file
</filename></option>
<option>
--save
<filename>
file
</filename></option>
.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--load
<filename>
file
</filename></option></term>
<listitem>
<para>
(Deprecated)
Restore the environment previously saved in
<filename>
file
</filename>
by the
<option>
--save
</option>
option.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--save
<filename>
file
</filename></option></term>
<listitem>
<para>
(Deprecated)
This options allows persistence between several invocations of the
interpreter: the current environment (i.e., the set defined types and values) is saved in
<filename>
file
</filename>
when the interpreter terminates so that it
can be succesively restored by using
<option>
--load
</option>
option
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>
--help
</option></term>
<listitem>
<para>
Display a short help message and exit.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>
<title>
PROGRAM OPTIONS
</title>
<para>
<variablelist>
<varlistentry>
<term><option>
--arg
<filename>
arguments
</filename></option></term>
<listitem>
<para>
All the arguments following
<option>
--arg
</option>
are passed to the CDuce
program. They can be fetched from the CDuce program
with the built-in operator
<command>
argv
</command>
(of type
<command>
[] -> [ String*
]
</command>
).
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsect1>
<refsect1>
...
...
@@ -298,9 +68,6 @@ Report bugs to <email>devel@cduce.org</email>.
</para>
</refsect1>
<refsect1>
<title>
See also
</title>
...
...
@@ -308,7 +75,7 @@ Report bugs to <email>devel@cduce.org</email>.
A complete documentation, reference manual, tutorial, technical articles on
implementation and theoretical issues, benchmarks, source code, mailing lists
and forums can be found on the
<emphasis>
CDuce
</emphasis>
website:
<filename>
http://www.cduce.org
</filename>
.
<filename>
http://www.cduce.org
/
</filename>
.
</para>
</refsect1>
...
...
doc/dtd2cduce.1
View file @
e40bd112
.\" $Header: /cvsroot/cduce/doc/dtd2cduce.1,v 1.
2
2004/07/0
3
0
8:42:38
afrisch Exp $
.\" $Header: /cvsroot/cduce/doc/dtd2cduce.1,v 1.
3
2004/07/0
4
0
1:16:43
afrisch Exp $
.\"
.\" transcript compatibility for postscript use.
.\"
...
...
@@ -56,12 +56,12 @@
dtd2cduce \(em Transform a DTD file into a set of CDuce type declarations
.SH "SYNOPSIS"
.PP
\fBdtd2cduce\fR
[
prefix
]
file.dtd
\fBdtd2cduce\fR prefix
\fB\fB
file.dtd
\fP\fP
.SH "Description"
.PP
The \fBdtd2cduce\fR reads the file \fBfile.dtd\fP and outputs on the stadard
in
put
that
set of CDuce type declarations that
translate the DTD.
If a
prefix
is
given in the command line
then it
is used to
prefix all the type names generated by the command
The \fBdtd2cduce\fR reads the file \fBfile.dtd\fP and outputs on the sta
n
dard
out
put
a
set of CDuce type declarations that
translate the DTD.
The
prefix given in the command line is used to
prefix all the type names generated by the command
.
.SH "TODO"
.PP
To specify on the command line the elements that can be explicitly
...
...
@@ -71,5 +71,5 @@ kept in the translation in order to factorize it.
Report bugs to bugs@cduce.org.
.SH "AUTHOR"
.PP
Alain Frisch Alain.Frisch@ens.fr.
.\" created by instant / docbook-to-man, S
at
0
3
Jul 2004, 0
9:53
Alain Frisch
<
Alain.Frisch@ens.fr
>
.
.\" created by instant / docbook-to-man, S
un
0
4
Jul 2004, 0
3:15
doc/dtd2cduce.docbook
View file @
e40bd112
...
...
@@ -15,12 +15,8 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>
dtd2cduce
</command>
<arg
choice=
"opt"
>
prefix
</arg>
<arg
choice=
"req"
>
file.dtd
</arg>
<arg
choice=
"req"
>
prefix
</arg>
<arg
choice=
"req"
><option><filename>
file.dtd
</filename></option></arg>
</cmdsynopsis>
</refsynopsisdiv>
...
...
@@ -28,9 +24,9 @@
<title>
Description
</title>
<para>
The
<command>
dtd2cduce
</command>
reads the file
<filename>
file.dtd
</filename>
and outputs on the stadard
in
put
that
set of CDuce type declarations that
translate the DTD.
If a
prefix
is
given in the command line
then it
is used to
prefix all the type names generated by the command
and outputs on the sta
n
dard
out
put
a
set of CDuce type declarations that
translate the DTD.
The
prefix given in the command line is used to
prefix all the type names generated by the command
.
</para>
</refsect1>
...
...
@@ -57,7 +53,7 @@ Report bugs to <email>bugs@cduce.org</email>.
<refsect1>
<title>
AUTHOR
</title>
<para>
Alain Frisch
<email>
Alain.Frisch@ens.fr
</email>
.
Alain Frisch
<email>
<
Alain.Frisch@ens.fr
>
</email>
.
</para>
</refsect1>
...
...
ocamliface/mlstub.ml
View file @
e40bd112
...
...
@@ -46,7 +46,8 @@ and typ_descr = function
|
Abstract
"char"
->
Builtin_defs
.
char_latin1
|
Abstract
"string"
->
Builtin_defs
.
string_latin1
|
Abstract
s
->
Types
.
abstract
(
Types
.
Abstract
.
atom
s
)
|
Builtin
(
"list"
,
[
t
])
->
Types
.
descr
(
Sequence
.
star_node
(
typ
t
))
|
Builtin
(
"list"
,
[
t
])
|
Builtin
(
"array"
,
[
t
])
->
Types
.
descr
(
Sequence
.
star_node
(
typ
t
))
|
Builtin
(
"Pervasives.ref"
,
[
t
])
->
Builtin_defs
.
ref_type
(
typ
t
)
|
Builtin
(
"Cduce_lib.Value.t"
,
[]
)
->
Types
.
any
|
Builtin
(
"unit"
,
[]
)
->
Sequence
.
nil_type
...
...
@@ -227,7 +228,7 @@ and to_cd_descr e = function
let
cases
=
List
.
map
(
function
|
(
lab
,
[]
)
->
<:
patt
<
$
u
id
:
lab
$
>>,
atom_ascii
lab
|
(
lab
,
[]
)
->
<:
patt
<
$
l
id
:
p
^
lab
$
>>,
atom_ascii
lab
|
(
lab
,
tl
)
->
let
vars
=
mk_vars
tl
in
<:
patt
<
$
lid
:
p
^
lab
$
$
pat_tuple
vars
$
>>,
...
...
@@ -254,6 +255,8 @@ and to_cd_descr e = function
|
Builtin
(
"list"
,
[
t
])
->
(* Value.sequence_rev (List.rev_map fun_t <...>) *)
<:
expr
<
Value
.
sequence_rev
(
List
.
rev_map
$
lid
:
to_cd_fun
t
$
$
e
$
)
>>
|
Builtin
(
"array"
,
[
t
])
->
<:
expr
<
Value
.
sequence_rev
(
List
.
rev_map
$
lid
:
to_cd_fun
t
$
(
Array
.
to_list
$
e
$
))
>>
|
Builtin
(
"Pervasives.ref"
,
[
t
])
->
(* let x = <...> in
Value.mk_ext_ref t (fun () -> t(!x)) (fun y -> x := t'(y)) *)
...
...
@@ -381,6 +384,9 @@ and to_ml_descr e = function
|
Builtin
(
"list"
,
[
t
])
->
(* List.rev_map fun_t (Value.get_sequence_rev <...> *)
<:
expr
<
List
.
rev_map
$
lid
:
to_ml_fun
t
$
(
Value
.
get_sequence_rev
$
e
$
)
>>
|
Builtin
(
"array"
,
[
t
])
->
(* List.rev_map fun_t (Value.get_sequence_rev <...> *)
<:
expr
<
Array
.
of_list
(
List
.
rev_map
$
lid
:
to_ml_fun
t
$
(
Value
.
get_sequence_rev
$
e
$
))
>>
|
Builtin
(
"Pervasives.ref"
,
[
t
])
->
(* ref t(Eval.eval_apply (Value.get_field <...> "get") Value.nil) *)
let
e
=
<:
expr
<
Value
.
get_field
$
e
$
$
label_ascii
"get"
$
>>
in
...
...
ocamliface/mltypes.ml
View file @
e40bd112
...
...
@@ -80,7 +80,7 @@ let new_slot () =
let
builtins
=
List
.
fold_left
(
fun
m
x
->
StringMap
.
add
x
()
m
)
StringMap
.
empty
[
"list"
;
"Pervasives.ref"
;
"CDuce_all.Value.t"
;
"unit"
]
[
"list"
;
"Pervasives.ref"
;
"CDuce_all.Value.t"
;
"unit"
;
"array"
]
let
vars
=
ref
[]
...
...
query/query_run.ml
View file @
e40bd112
let
()
=
Run
.
specs
:=
(
"--noquery-optim"
,
Arg
.
Set
Query
.
nooptim
,
" do not optimize queries "
)
::
!
Run
.
specs
let
()
=
Run
.
specs
:=
!
Run
.
specs
@
[
"--noquery-optim"
,
Arg
.
Set
Query
.
nooptim
,
" do not optimize queries "
]
tests/ocaml/Makefile
View file @
e40bd112
...
...
@@ -24,5 +24,12 @@ cdsdl:
ocamlfind ocamlc
-o
cdsdl
-pp
"
$(CDO2ML)
-static"
-impl
cdsdl.cdo
-package
cduce,ocamlsdl
-linkpkg
./cdsdl
.PHONY
:
cdmysql
cdmysql
:
$(CDUCE)
--compile
$@
.cd
-I
`
ocamlfind query mysql
`
ocamlfind ocamlc
-o
$@
-pp
"
$(CDO2ML)
-static"
-impl
$@
.cdo
-package
cduce,mysql
-linkpkg
./
$@
clean
:
rm
-f
*
.cmo
*
.cmx
*
.o
*
.cdo
*
.cmi a.ml
*
~ a
web/manual/interface.xml
View file @
e40bd112
...
...
@@ -64,7 +64,8 @@ Labels and optional labels on the argument of the arrow are discarded.
<li>
A list type
<code>
%%t%% list
</code>
is translated to an homogenous
sequence type
<code>
[ T(%%t%%)* ]
</code>
.
sequence type
<code>
[ T(%%t%%)* ]
</code>
. An array type
<code>
%%t%% array
</code>
has the same translation.
</li>
<li>
...
...
@@ -97,43 +98,64 @@ OCaml reference is created (copy semantics).
</li>
<li>
The type
<code>
C
D
uce_
all
.Value.t
</code>
is translated to the CDuce
The type
<code>
C
d
uce_
lib
.Value.t
</code>
is translated to the CDuce
type
<code>
Any
</code>
. The corresponding translation functions are the
identity. This can be used to avoid multiple copies when translating
a complex value back and forth between CDuce and OCaml.
</li>
</ul>
<p>
The canonical translation is summarized in the following box
</p>
<sample>
<![CDATA[
T($$bool$$) = Bool
T($$char$$) = Byte
T($$int$$) = -1073741824 -- 1073741823
T($$string$$) = Latin1
T($$unit$$) = []
T($$%%t1%%$$$$*$$...$$*$$$$%%tn%%$$) = ( T($$%%t1%%$$), (...,T($$%%tn%%$$))... )
T($$%%t%%$$ $$->
$$ $$%%u%%$$) = T($$%%t%%$$) -> T($$%%u%%$$)
T($$%%t%%$$ $$|$$ $$%%u%%$$) = T($$%%t%%$$) | T($$%%u%%$$)
T($$%%t%%$$ $$list$$) = [ T($$%%t%%$$)* ]
T($$%%t%%$$ $$ref$$) = ref T($$%%t%%$$)
T($$A$$) = `A
T($$A of$$ $$%%t%%$$) = ( `A, T($$%%t%%$$) )
| { u : T($$%%t%%$$) } if in contravariant (argument) position
T($${ u :$$ $$%%t%%$$ $$}$$) =
<
| {| u : T($$%%t%%$$) |} if in covariant (result) position
]]>
</sample>
<
p
>
<
li
>
A
<em>
monomorphic
</em>
abstract type
<code>
t
</code>
is translated to
the CDuce type
<code>
!t
</code>
. This type just acts as a container for
values of the abstract type. CDuce never produces a value of this
type, and it cannot inspect the content of such a value (apart
from checking its type).
</li>
</ul>
<p>
The canonical translation is summarized in the following box:
</p>
<table
border=
"1"
style=
"align:middle"
>
<tr>
<th>
CDuce type
<tt><i>
t
</i></tt></th>
<th>
OCaml type
<tt>
T(
<i>
t
</i>
)
</tt></th>
</tr>
<tr><td><tt>
char
</tt></td><td><tt>
Byte = '\0;'--'\255;'
</tt></td></tr>
<tr><td><tt>
int
</tt></td><td><tt>
-1073741824 -- 1073741823
</tt></td></tr>
<tr><td><tt>
string
</tt></td><td><tt>
Latin1 = [ Byte* ]
</tt></td></tr>
<tr><td><tt>
unit
</tt></td><td><tt>
[] = `nil
</tt></td></tr>
<tr><td><tt>
bool
</tt></td><td><tt>
Bool = `true | `false
</tt></td></tr>