-
Couldn't load subscription status.
- Fork 0
Deciding between typeids and nominal types
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
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.
- 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.
Benefits of Type IDs:
- Simple
- Can be easily generated from anywhere
- small
Cons of type IDs:
- not available till a type is registered
- not human readable
- opaque
- A sequence of things that you don't know (but need to)
- Idea 1
- Idea 2
- Part 1
- Part 2