2.5 Objects and Patterns

An object generated as an instance of a pattern is only meaningful as an instance of that pattern. Consider the following example:

P: (# ... #);
R: ^P;

&P[] -> R[]; .... (* Save R *)

The object referenced by R is an instance of P. When this object is later read by a program, it must be interpreted by that program execution as an instance of P.

It is not enough that the program reading the object has a declaration of a pattern P which has the same structure as the pattern P which was used to generate the object. It must be the very same pattern.

In order for this to work, it is necessary to give a new interpretation to the notion of betaenv. This new interpretation is described in the next section. Before doing this we will shortly discuss what it means for objects to be instances of the same pattern.

Consider the following object descriptor:

(# T: (#  c: @ integer;
          A: (# b: @integer do c->b #);
          X: @ A;
          Y: @ A
   V: @ T;
   W: @ T

The outermost object has two internal objects V and W which are instances of the pattern T. Each of V and W has internal attributes c, A, X and Y. The attributes of V are different from the attributes of W. This should be obvious for c, X and Y, since they occupy different storage locations in V and W respectively. The pattern attribute A of V is also different from the pattern attribute A of W. The reason is that an instance of V.A is enclosed by V and may therefore refer to attributes of V -- V.A is said to have origin in V. The pattern W.A is an attribute of W and may refer to attributes of W -- W.A has origin in W. An instance of V.A is therefore NOT an instance of W.A.

The objects V.X and V.Y are thus instances of the same pattern V.A. Similarly the objects W.X and W.Y are instances of the same pattern W.A.

Persistence in BETA - Reference Manual
© 1991-2002 Mjølner Informatics
[Modified: Monday October 23rd 2000 at 10:43]