C
ATS
(
TM
) P
ROGRAMMING
L
ANGUAGE
O
VERVIEW
As revised 2006.08.23
Bionic Buffalo Tech Note #84
Security:
Unrestricted
entire buffer. On the other hand, adding elements to a
list
always requires memory allocation. Some
applications will work better with
sequence
s, others will be more efficient with
list
s. The best
choice will depend largely on how stable the number of elements will be, whether insertions or deletions
are made to or from the middle, and how big each element is.
plex
is an array with variable bounds. The minimum or maximum subscript values may be positive or
negative. A
plex
is implemented similarly to a
sequence
, and behaves the same except that negative
subscripts do not reference elements from the end.
sparse sequence
and
sparse plex
allow missing elements. In other words, there may be no
element corresponding to a subscript. As with ordinary sequence or plex types, deleting an element
using the exclamation operator (as in
seq1[n!]
) causes the remaining elements to move up or down to
fill the space. With
sparse
sequence
or
plex
, using a double exclamation mark (
seq1[n!!]
)
causes the subscript to become invalid, even though it is in the middle of a valid sequence of subscripts.
The
vacancy_of
operator refers to the value of the
sparse
sequence
or
plex
to be used when
reference is made to a nonexistent element.
bit
represents a single bit, while
bit(n)
represents an array of
n
bits. These types can be used in
arrays, sequences,
list
s, and
plex
es. Individual bits are referenced using subscripts. Unlike with the
bit field notation (such as
struct X { int a:5; }
) available with C, the
bit
type is guaranteed
to be packed as tightly as possible, and does not have to appear within a structure. Furthermore, Cats
implementations of
sequence
and
plex
can optimize access to large
bit
types.
typecode
is an opaque type which describes the type of a variable. There are various operations on
typecode
which return values allowing an application to know the variable's type and parameters. For
some types (such as
int
or
unsigned short
) there are no type parameters. For other types, such as
arrays and structures, additional parameters are needed for length, member types and so on.
any
is a type which can contain any type. The
type_of
operator returns the
typecode
, and the
value_of
operator refers to the value. Assigning to an
any
sets the type and value. Assigning to
value_of any1
is equivalent to assigning to a fixed type.
set
is an unordered collection without duplicates. A
set
containing values of type
X
is declared
set(X)
. Sets are manipulated the same way as lists and sequences, except that attempting to add an
element which duplicates an existing element is ignored.
bag
is a set which allows duplicates.
map
is an association between a key and content. It is declared by
map(X,Y)
, where
X
and
Y
are the
key and content type. It is similar to an associative array or Perl hash. The content is referenced by using
the key value as a subscript. Elements are added by assignment to a subscripted reference (as
map1[key1]=content1
), and removed using the exclamation mark notation (as
map1[key1!]
).
Copyright 2006 Bionic Buffalo. All rights reserved.
File tn0084; Modified 20060830 08:00:17
http://www.tatanka.com/doc/technote/index.html
Email:
query@tatanka.com
Page 5 of 12