Core Data Types for Librified tla
Most APIs in librified tla
will accept ordinary and parameters of
only a very few generic types.
Great is going into making these types general enough to not be a limitation, simple, robust, and fast. The interfaces are being designed to make memory managment for these data structures easy for clients to get right.
API documentation for the new types is not ready yet. This is just a high level description.
Values
A Value is an immutable, boxed scalar type. The scalar contained in a Value may be a (constant) string, a number, a boolean value, or other type. A Value carries a type tag which records the type of data it contains.
Example: In tla 1.2
, the "arch namespace functions" accept and
return string arguments of type t_uchar *
(pointer to unsigned
character). In librified tla
, the analogous functions will accept
and return generic Values.
Lists
Lists are random-access, list-editable, finite sequences of Values.
For access patterns with a high degree of locality, and in the absense of list insertion and deletion operations, Lists have access patterns similar to packed arrays. For insertions and deletions with a high degree of locality, Lists have performance characteristics comparable to interval splay trees or gap buffers.
Arrays
Arrays are random-access, list-editable, finite sequences of Lists. They have performance characteristics analogous to those of lists.
Associative Tables
Associative Tables are mutable, explicitly enumerated mappings from Values to Values.
Additional Value Kinds -- Maybe
Future additions to the kinds of Value (besides strings and numbers, for example) include:
streams -- file descriptors and similar entities.
paths -- file names as abstract things rather than strings
immutable lists
immutable arrays
immutable associative tables -- this would allow, for
example, an associative table whose values include
other associative tables without risking the possibilitiy
of circular references
Memory Management Trick
The ARCH_FN_
macros (see the function template) include facilities for automatically freeing
temporary Values, Lists, Array, and Associative tables which
are allocated as local variable values during a function call.
In other words: far less reason to have to write so many
lim_free
calls and str_free
calls and free_rel_table
calls and
.... !!
Copyright
Copyright (C) 2004 Tom Lord
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
See the file COPYING
for further information about
the copyright and warranty status of this work.