Next: Incompatible and obsolete commands
Up: Embedding into Tcl/Tk
Previous: Obtaining the Interface Type
  Index
Type conversion between Tcl and ECLiPSe
EXDR (ECLiPSe External Data Representation, see also chapter
9) is a data encoding that allows to represent a
significant subset of the ECLiPSe data types. The following Tcl
primitives are provided to handle EXDR-format:
- ec_write_exdr channel data ?format?
-
write an EXDR-term onto the given channel.
The term is constructed using the data argument and
the additional type information provided in the format
argument. If no format is specified, it defaults to S (string).
- ec_read_exdr channel
-
reads an EXDR-term from the given channel and returns it
as a Tcl data structure, according to its type. Note that,
since Tcl does not have a strong type system, some typing
information can get lost in this process (e.g. string vs. atom).
- ec_tcl2exdr data ?format?
-
This is the low-level primitive to encode the given data and
type information in format to an EXDR-string which is
suitable for sending over communication links to ECLiPSe or
other agents which can decode EXDR-format.
If no format is specified, it defaults to S (string).
- ec_exdr2tcl exdr_string
-
This is the low-level primitive to decode an EXDR-string.
It returns a Tcl data structure, according to the type information
encoded in the EXDR-string. Note that,
since Tcl does not have a strong type system, some typing
information can get lost in this process (e.g. string vs. atom).
Since Tcl is an untyped language, all commands which create EXDR terms
accept, in addition to the data, an optional format argument
which allows all EXDR data types to be specified.
The syntax is as follows:
To create EXDR type |
use <format> |
data required |
String |
S |
string (binary) |
String |
U |
string (utf8) |
Integer |
I |
integer |
Double |
D |
double |
List |
[< formats>] |
fixed length list |
List |
[< formats>*] |
list |
Struct |
(< formats>) |
fixed list, first elem functor name |
Struct |
(< formats>*) |
list, first elem functor name |
Anonymous Variable |
_ |
string "_" |
Here are some examples that show which Tcl data/format pair corresponds
to which ECLiPSe term (the curly brackets are just Tcl quotes and
not part of the format string):
Tcl data Tcl format Eclipse term
hello S "hello"
hello () hello
123 S "123"
123 I 123
123 D 123.0
123 () '123'
{a 3 4.5} {[SID]} ["a", 3, 4.5]
{a 3 4.5} S "a 3 4.5"
{1 2 3 4} {[I*]} [1, 2, 3, 4]
{f 1 2 3} {(I*)} f(1,2,3)
{is _ {- 1 2}} {(_(II))} _ is 1-2
Next: Incompatible and obsolete commands
Up: Embedding into Tcl/Tk
Previous: Obtaining the Interface Type
  Index
Warwick Harvey
2004-08-07