Representing Heterogeneous Data (2023)
4 hours ago
- #type-systems
- #game-development
- #programming-languages
- The author is working on converting a dynamically typed game scripting language into a statically typed one, focusing on simplicity and familiarity.
- Heterogeneous data representation is a key problem, addressing optional data and data in different forms.
- Various approaches to handle heterogeneous data are discussed: null, variant types, untagged unions, sum types, and subtyping.
- The author prefers sum types for their language but finds pattern matching syntax less intuitive for an imperative language.
- An alternative approach inspired by Pascal's variant records is proposed, allowing case-specific fields with runtime checks for safety.
- The proposed solution combines shared and case-specific fields in a single construct, balancing simplicity and safety.
- Flow typing is considered but deemed too complex for the language's goals, preferring simpler, more predictable behavior.