Data Types

In this section, we will discuss the various data types supported by Type-C. The language provides a set of built-in types, as well as the ability to define custom types.

Type-C offers the following datatypes:

  • Primitive Types: Basic types such as bool, u32, f64, etc.
  • Structs: Structured types that group together other types.
  • Enums: Enumerated types that can hold one of several values.
  • Variants: Variants, also known as algebraic data types, that can hold one of several types, with constructors.
  • Arrays: Arrays, a collection of elements of the same type.
  • Functions: Functions as data types, since Type-C supports first-class functions, functions need to be typed as well.
  • Interfaces: Interfaces, the basic building blocks of interface-oriented programming in type-c. Defines a set of methods that a class must implement.
  • Classes: Classes, a subset of object-oriented programming in type-c.
  • Tuples: Tuples, a type that can hold a fixed number of elements of different types. Though it is only used for function return types and unpacking those values.
  • Nullables: Nullables, a type that can hold either a value or null.

In further sections, we will discuss type system and type compatibility of Type-C, to understand how these data types interact with each other.


Kudos! Keep reading!