#4. Packages. By a package we mean a collection of related objects (net vertices), each having a specific function and a name attached to this function; usually a package contains a few procedures and the remaining objects are used as common data which the procedures can access and possibly change. Packages are similar to SIMULA objects and ADA tasks; they differ from ADA packages in that in this system one may work concurrently with several packages of the same type.

In a programming system a package can be used to support some permanent collection of data, e.g. a file for symbolic input. Such a file will have procedures to read a single character, to read a single word, to step one word back, to go to the next line, etc. The data common to all of those procedures consist of system control blocks, input buffers, current line and character pointers, etc. Another example of a package is support of a table of properties of some set of objects, that may require procedures to add a new object, to enter, read, or update some property of an existing object, to remove an object, etc. Often a package needs procedures for initialization (opening the package) and for correct completion (closing the package).

In this system a package is represented by a node with outgoing arcs to vertices representing the procedures or data. Each of the arcs has a name corresponding to the function of the object in the package. E.g., a package to control an input file can have arcs with names meaning "read a character", "read a word" leading to corresponding procedures, as well as arcs with names meaning "line number", "column number" leading to corresponding integers. It is convenient to use standard names for opening and closing procedures in all packages. In this implementation the names #OPEN and #CLOSE are used (it is not mandatory but has some advantages). At every given moment there can be several packages of the same type with the same arc names and similar (or even the same) procedures but with different sets of data.

In this system no distiction is made between open (public) objects and hidden (private) objects. Accessibility of package objects from an external program depends on whether the program knows the names of their functions in the package.

This system has a special primitive for calling a procedure contained in a package, it is distinct from an ordinary call (and more frequently used). For this operation one specifies the node representing the package and the function name (i.e., the name of the arc leading to the procedure), rather than the procedure itself. Thus, if there is an internal variable SYSIN whose value is the node representing the mentioned package for control of an input file, reading a single letter may look as follows
USE SYSIN,OP=GETCHAR,TO=X Here GETCHAR ("get a character") is the name of the character reading function and X is an internal variable to which the result is assigned. At this operation the procedure is called in a special way so that its own context is the node representing the package, and from this node the procedure can access all the data needed. (A procedure with the same sequence of statements can be attached to a different package and then it would access the data of that other package).

If at using a package there is no arc with the name specified, no action is performed and the operation is completed (if there were a parameter and the caller expected a result the parameter value is returned).

There is one more possibility at using a package. To the node representing the package one may attach along a given arc a set of procedures rather than a single procedure (i.e., a node with unnamed arcs leading to all of these procedures); then all procedures are called in succession. Therefore at merging two nodes, each representing some package, one can obtain a new package comprising the functions of both packages; if both packages used the same function name and the respective procedures were attached by unnamed arcs, the merged package will do for this function the job of both original packages.

The implementation allows one more possibility at using packages: instead of a procedure one may have its name (an atom) attached to the package.

Any node can be treated as a package, possibly with an empty set of functions. Some system operations on arbitrary nodes involve using their functions. E.g., before merging two nodes the system calls automatically a function of each node with a special name (#MRGTEST in this implementation), passing the other node as the parameter. Thus by attaching to a node a procedure with an arc of this name one can specify additional actions for an attempt to merge this node with another node.

In using this system the following problem was encountered. If, at using a package, a set of procedures is called all of them get the same external context (the parameter) and the same own context (the node representing the package itself). Sometimes an additional facility is desirable to distinguish the elements of the set by their own contexts; the implementation lacks such facility.