The Object (Top) and Null (Bottom) Types

Type systems with subtyping typically include a Top and Bottom type. The Top type has the property that for any type S, S is a subtype of Top and the Bottom type has the property that for any type S, Bottom is a subtype of S. In the type system for Sym the Top type is named Object and the Bottom type is named Null and the type relationships between these two types and any other type is assumed.

When you create a new type, you don't have to declare subtype relationships between the new type and Object or Null - these type relationships are assumed. See Subtypes.

The Object Type

The type named Object is the top type of the type system. All types are assumed to be subtypes of Object.

The Null Type

The Null type is not the empty set. There are several objects that have the Null type, these include:

  • The null object
  • The Break object
  • The Return object
  • The Exception object(s)

Objects that have the Null type have are handled differently from other objects when we process clauses in functions. In general, if any parameter of an expression has the Null type the whole expression will be replaced with the Null typed parameter. As a result, we can write clauses like:

if the Simplify term evaluates to null, then the whole right-hand side will be null and processing with fall through to the next clause.

Functions where none of the clauses match will return the null object. See Functions