# Objects and Actors

The standard library contains the two types `core.Object` and `core.TObject`. These are the types that all other class types and actor types in the system inherit from. That is, all class types inherit from `core.Object`, and all actor types inherit from `core.TObject`.

## Object

The type `core.Object` contains the following members:

- `core.Str toS()`

  Create a string representation of the object. The default implementation simply calls `toS(StrBuf)` to create the string representation.

- `void toS(core.StrBuf to)`

  Create a string representation, and write it to the provided string buffer. The default implementation outputs the type of the object and its current address. Note that the address may change during the lifetime of the object, so it is not a stable identifier.

  Many types in the system provide some form of string representation to aid debugging. The preferred method of providing a string representation is to override this version of `toS`.

- `void deepCopy(core.CloneEnv env)`

  Used to provide deep copies of object.

## TObject

The type `core.TObject` is the base class of all actors (`TObject` stands for "Thread Object"). It has the same interface as `core.Object`, except that `deepCopy` does not exist (actors typically don't need to be copied), and it instead contains the member `associatedThread` that specifies which thread the actor is associated with. The associated thread is set through a parameter to the constructor, and it is not possible to change the associated thread after creation.

## Utilities

The standard library also provides the following function for comparing the types of classes. It is useful to compare types for equivalence in a `==` operator, for example.

- `core.Bool sameType(core.Object a, core.Object b)`

  Do the two objects `a` and `b` have the same dynamic type?

The following functions allow inspecting the dynamic type of objects. They are located in `core.lang`:

- `core.lang.Type typeOf(core.Object o)`

  Get the run-time type of a heap-allocated object.

- `core.lang.Type typeOf(core.TObject o)`

  Get the run-time type of a heap-allocated object.