Download An Introduction to IDL

Transcript
CHAPTER 2. USING IDL: A TUTORIAL
4
These requirements dictate some of the design decisions in IDL. We must
have some way to talk about individual programs, and group basic programs
into composite ones. We must be able to describe the abstract informationcontent properties of data structures (the ones all programs can depend on)
separately from the concrete representational properties (the ones that change
from program to program).
2.2 Basic Concepts
A structure is an IDL declaration of a data structure. You can view it as a
schema that describes a collection of object types; the objects form a graph
(technically, a typed attributed directed graph). This section discusses IDL's
facilities for describing and manipulating graphs.
2.2.1 Names
IDL identiers start with a letter and consist of a sequence of letters, digits,
and underscores. IDL ignores case distinctions between letters; the identier
NAME means the same thing as NaMe or name. Underscores do make identiers
dierent; name 1 is not the same as name1. For readability, you should avoid
using consecutive underscores in an identier; it is hard to tell some name from
some name.
IDL reserves several identiers for its own use, typically to dene language
constructs.
2.2.2 Node Types
The basic units from which you build graphs are nodes, which are analogous
to records in typical programming languages. Associated with each node you
may have several attributes, which you can view as information about the node;
they are analogous to record elds. In IDL, what you declare is the node type;
the IDL notation does not include the notion of variables. Thus one might
implement the IDL declaration
item => name : string,
value : integer;
with the Algol-like type declaration
type
pointer to record
item rep =
name : string rep; value : integer rep
end
We use the \ rep" sux to distinguish the implementation language's representation type from the IDL type. The type is a pointer to a record rather