KL references

The target of a reference (meaning the thing that the reference refers/points to) can be any one of these:

* A boxed record instance (meaning a standalone instance of a record).
* An unboxed record instance (meaning an instance of a record embedded/inline in another record).
* An attribute (member/component) of a record instance.
* A command local variable in the Activation Record (record instance) of a Command Implementation.
* A constant value that was used in the program (numeric, text, or other type).
* An item in an array in a record instance.
* Another reference in a record instance (meaning a reference to a reference).
* A Command Implementation (invokable via the reference).

## OLD INFO TO UPDATE

\*\*\*\*\*\*\*\*\* TO DO: Update this webpage. Object references have been removed and replaced with attribute/variable references. And variables are now capable of storing "objects" directly (the concept of objects is basically removed). \*\*\*\*\*\*\*\*\*

KRE supports the concept of object references (references to objects). An object reference is something that refers to a particular/specific object. It is a way of identifying a specific object, and also locating it.

An object reference is similar to a street address (for example, "81 Acland Street"). If a house is an object, then the street address is the reference.

It is possible to have multiple references to the one same object, in much the same way as you can write the same street address on multiple envelopes or letters.

A "variable" in a program is like a named box, slot, or container for storing something such as a number. It is important to realize that if your program has a text object variable, then the variable does NOT contain the text object. Rather the variable contains a reference to a text object. Variables in KRE are capable of storing numbers but are incapable of storing objects -- however they are capable of storing references (to objects). This difference may be subtle but is important.

## Reference-Type Variables

A "variable" in a program is like a named box, slot, or container for storing something such as a number. A variable can be defined to be a reference to an object. In this case, the variable contains a reference. Variables never contain the objects themselves. Following is an example of how to define a variable of a reference type:

```
var msg, RText, null;

```

"msg" is the name of the new variable to define, "RText" is the type of the variable (in this case a reference to a text object), and "null" is the initial value of the variable.

The only possible initial value for a reference variable is "null", the null reference, meaning none or no reference. The initial value cannot be another reference variable because initial values must be constant values and other reference variables are not constant values.

Using the "var" command to define a variable as an object reference type never causes an actual object to be created. It only causes a reference variable to be created. The initial value of "null" is required to be specified (despite the fact it can be nothing else) as a reminder that an object is NOT being created by the "var" command, and also for consistency with the syntax of "var" when defining integer variables.