Why I Gave Up on Smart Nil-Checking in My Programming Language
Union Types and Option Types

After experimenting with union types in his low-level language Copper, the author settles on option types (T?) as a simpler alternative. He implements them by reserving a nil value per type, adds an 'as' operator for safe refinement, and tries compiler-inferred nil-checking like TypeScript's. Despite its benefits, he abandons the inferred approach due to two-pass loop analysis, poor genericity, and unpredictable edge cases, reverting to explicit refinement.
Last but not least, it's a kind of black magic: the validity of the program depends on the power of the nil-checker.
- p1necone
One simple but non obvious (at least to me) trick when implementing tagged unions: put the union discriminator/tag at the end, not the beginning - that way a pointer to a union is also a pointer to the value, no need to increment the pointer to point past the tag after discriminating.
- ks2048
What is the best source for cross-language description of language features? Eg: “optional types”: which langs have them and how do they work? Same with “union types” etc.
- gnabgib
(2025) And about CopperLang (203 points, 3 days ago, 120 comments) https://news.ycombinator.com/item?id=50308754