STERNO - Objects

# Sterno Objects

Objects in are instantiated from classes with the `new` or `localNew` class-methods. The following instance-fields are defined for each object:

- `self` - Contains the object-command.
- `selfns` - Contains the object's namespace.
- `class` - Contains the class-command that this object is an instance of.
- `classns` - Contains the object's class namespace.

The following standard instance-methods are defined for each class:

- `delete` - Deletes the object.
- `fget` - Returns the value of an instance-field.
- `fset` - Sets the value of an instance-field.
- `fref` - Get the fully qualified reference (name) of an instance-field.
- `fields` - Return a list of fields associate with the object.

In addition, the following instance-method name has special meaning if its defined:

- `construct` - Called when an object is instantiated.
- `destruct` - Called when an object is deleted.

### Instance-method: `delete`

            $cmd delete

Deletes the object.

### Instance-method: `fget`

            $cmd fget name

Returns the value of an instance-field `name`. The argument `name` may refer to a scalar or a array element.

### Instance-method: `fset`

            $cmd fset name

Sets the value of an instance-field `name` to `value`. The argument `name` may refer to a scalar or a array element.

### Instance-method: `fref`

            $cmd fref field

Get the fully qualified reference (name) of instance-field `field` . This allows instance-fields to be passed by name to procedures and commands. For example:

            array names [$obj fref table]

### Instance-method: `fields`

            $cmd fields

Get a list of all fields associated with the object. They may not necessarly have values assigned.

### Instance-method: `construct`

            construct ?arg0? ?arg1? ...

If the `construct` method is defined, it will be called when the object is created to initialize its fields. All arguments specified to `new` or `localNew` class-methods are passed to `construct`, which should have the appropriate number of arguments defined.

### Instance-method: `destruct`

            destruct

If the `destruct` method is defined when the object is instantiated, it will be called the object is deleted. Note, this will not handle that don't not go through the class or object `delete` method; executing `namespace delete` on an object's namespace will product undefined results.