Next Previous Up Top Contents Index

1 Conventions in this Manual

1.5 Immutability of objects

Most DUIM objects are immutable, that is, at the API level none of their components can be modified once the object is created. Examples of immutable objects include all of the members of the <region> classes, pens, brushes, colors, and text styles. Since immutable objects by definition never change, functions in the DUIM API can safely capture immutable objects without first copying them. This also allows DUIM to cache immutable objects. Any make methods that return immutable objects are free to either create and return a new object, or return an already existing object.

A few DUIM objects are mutable. Some components of mutable objects can be modified once the object has been created, usually via setter functions.

In DUIM, object immutability is maintained at the class level. Throughout this specification, the immutability or mutability of a class will be explicitly specified.

Some immutable classes also allow interning. A class is said to be interning if it guarantees that two instances that are equivalent will always be ==. For example, the class <text-style> is interned, so calling make-text-style twice with the same arguments would return identical values.

In some rare cases, DUIM will modify objects that are members of immutable classes. Such objects are referred to as being volatile. Extreme care must be take with volatile objects. For example, objects of class <bounding-box> are often volatile.

1.5.1 - Behavior of interfaces

Functional Developer Library Reference: DUIM - 3 Dec 1998

Next Previous Up Top Contents Index