Skip to content

Deciding between typeids and nominal types

Andrew Matthews edited this page Aug 30, 2025 · 1 revision

title: Deciding between typeids and nominal types tags:

  • problem
  • unsolved
  • fifthlang
  • design
  • type/system
  • type/checking
  • type/inference solution: ... project: fifthlang date: 2024-09-04 parent: "meta/tables-of-contents/Problems"

Deciding between Type IDs and Nominal Types

PROBLEM

Deciding between Type IDs and Nominal Types

Right now, I use type ids to distinguish between types that have been registered in a type registry. In addition, I make use of a hierarchical symbol table to keep track of what variables are available at a certain point in the code. Type checking in nominal types is easy - it's just string comparison, and in the case of a type id, it is just integer comparison. The problem I face is in moving back and forth between IDs and names. At the earliest stage of the parse process the only thing I have is a name. But elsewhere, after type resolution, all I might have is an ID. So, I need a way to get from one to the other and back again easily.

The point of this design is to understand what benefits I get from type IDs that I don't get using purely type names.

REQUIREMENTS

  • A decision on whether to retire the TypeID solution in favour of passing around type names, or to stick with what I've got and adapt it to work with names if that is all that is available at the time.

ISSUES

Benefits of Type IDs:

  1. Simple
  2. Can be easily generated from anywhere
  3. small

Cons of type IDs:

  1. not available till a type is registered
  2. not human readable
  3. opaque

QUESTIONS

  • A sequence of things that you don't know (but need to)

REFERENCES

IDEAS

  • Idea 1
  • Idea 2

Outline of the Solution

  1. Part 1
  2. Part 2
Clone this wiki locally