Type Constructors 2

Type Constructor Formal Type
Mapping (array, list, dictionary) IndexType -> ContentType
Recursion (a type that contains one of its own type as a member)

Java Refs on ALL Objects, enums, arrays. No Refs on primitives.


          bool[] arr = new bool[3];    // arr: NULL + Ref(int -> bool)
          Apple[] arr2 = new Apple[3]; // arr2: NULL + Ref(int -> (NULL + Ref(Apple)))
          

C/C++ Refs ONLY on things with *


          boolean arr3[3]; // arr3: int -> boolean
          

Type Constructors

Each language makes its own decisions about how references happen
  • Java says there will always be references on constructed types (class, array, enum, string) and never be references on primitives.
  • C says there can be references as you like on whatever you like when you use * to declare the type.
  • Python says there will always be a reference on everything.
  • What does your project language say?

Type Constructors

Most languages have constructed types. What formal type constructors are behind each one?
  • Java's class is a cartesian and uses a reference
  • What does your project language say?