sketch of the malete Tcl binding
| records are proper Tcl data objects |
A record is represented as a standard Tcl data object.
It can be assigned to a variable, a slot in an array or to a proc's
return value (the interp's result).
The objects's string rep is the standard serialization
(without trailing blank line; blank lines are ignored when de-serializing).
The object's internal rep is a Malete List, i.e. a modifiable record.
| records are accessed by views |
Just like Tcl image objects are accessed using the command "image",
there are several commands to access records.
Different commands interpret the records in different ways:
A basic command provides a plain list view on the array,
while derived extensions may provide a view on
or other specialized record types.
Unlike the "image" command, record views are stateful. They may
- be bound to a "current" record object
- maintain a cursor position in the current record
- have a current frame (subrecord)
- have an associated field definition to resolve symbolic names
- have an associated database name (defaulting to the view's name)
The view commands may be cloned in order to maintain several such states
in parallel. A different view command may be used for every record
resulting in a Tk-style "object oriented" feel.
The typical application, however, will use only a small number of views
like "v" and "w" or some database names.
The actual work of accessing field definitions and databases
will be handed over to additional configurable procedures,
which are typically implemented in Tcl.
| view command |
Many commands take an index expression , which
- selects some of the record's fields
- cuts some part out of these fields, typically subfields
When invoked with no parameters, the current record object is returned.
Most commonly used in rendering record contents is the one-parameter form
v _index_, returning a field based on the cursor and current record.
In all other forms, the first parameter denotes a view function:
- list _index_
returns all data addressed by _index_ as a list
- array _index_
returns all data addressed by _index_ as a names and values list like
the Tcl command "array get"
- head _index_
get parts of header
- with _record_ [args ...]
Without args, binds the view to _record_.
With args, temporarily binds the view to _record_ for the execution of
the view command given by args.
- do _script_
execute script. Syntactic sugar for with _record_ do _script_
In the basic implementation,
a view may only modify a record if it's the only view bound to this record.
As the record's struct Tcl_Obj provides a twoPtrValue from which only one
pointer is needed to refer to the list,
the ptr2 may be used to point to a view for synchronization purposes
(and views bound to the same record may be chained).
Database access: read, write (ins/upd)