Previous: Of Errors, Up: Interpreters And This Library


3.2.6 Referable Objects

Having multiple references to same piece of data, call that piece object, comes handy quite often and at times comes with no alternatives. Yet, having multiple references to objects makes resources management lot more complex.

Complex enough to make its utility in a application extention programming language questionable. In fact, too complex to be useful. Not without some extra assurances from the executive (the program interpreter, that is) that the application will stay safe and tracking allocated resources, even beyond the lacks in the programming skills of those providing programs for execution.

Now, there are quite a few ways of tracking resources and how they refer one each other. Some of the libx1f4i0 provided libraries make use of some type system tracking just that.

See Libraries.

See Libraries For Interpreted Languages.

Call referable object an object (piece of data, resource) that may be referred multiple times.

A referable objects type system provides the means to manage objects of the types observing the type system.

A type system here is merely a set of conventions that some data types are observing. That the management of data of such data types is observing, that is. Such type system does not automatically extends over all data types, and there may be more type systems in use at one time. Type systems with various concerns, including referable objects management.

The design of a data type meant to be operable withing a certain such type system will need to include provisions for accomodating that certain type system. Specifically, provisions need to be made in order to:

The referable objects type system in use with the libx1f4i0 libraries is a reference counting based one.

Reference counting is a trivial mechanism of dealing with references. It maintains a count of the references made to some object, for each object. Each time a new reference is being made to some object, the reference count for that object is incremented. Conversely, when a reference to some object is being destroyed the count is decremented. When the count gets zero there are no references to the object, hence the object is good for destruction (resources allocated for that object are freeable).

Reference counting has some drawbacks, and one that makes it not quite enough for the job: it cannot deal with cycles. Cycles are here sets of objects that refer one each other, without having any reference from outside made to any of them.

The libx1f4i0 type system amends the reference counting mechanism to allow for cycles detection and destruction. And it does that by maintaining an extra list of objects holding the references in excess the reference count.

The drawbacks of such reference tracking system are complexity and performance loss (both in terms of program execution speed and required memory). Still, the system provides for immediate object destruction - resources are freed as soon as no longer needed.

Definitions of referable objects data types are exchanged via the struct x1f4_nodetype_type records.

See struct x1f4_nodetype_type.