Records in LFE: A Field Guide to Tagged Tuples
Or: How I Learned to Stop Worrying and Love the Syntactic Sugar
The Fundamental Problem (And Why Records Are a Beautiful Hack)
Picture, if you will, a universe where you’ve built an entire application around three-element tuples representing people: #("Joe" 21 "999-999"). It works splendidly until the day someone casually mentions that perhaps—just perhaps—you should also track email addresses.
Suddenly you’re faced with a choice that makes choosing between the red pill and the blue pill look like deciding between tea flavours: either update every single occurrence of these tuples throughout your codebase (all seven thousand of them, naturally), or pretend email doesn’t exist and hope nobody notices.
This is not, as they say in more civilised programming circles, ideal.
Records solve this problem with what can only be described as a masterful compiler trick—the kind of elegant deception that would make a confidence artist weep with professional admiration. They give you named fields while maintaining the speed and memory efficiency of tuples underneath. It’s tuple access by name rather than position, which is approximately 42 times more maintainable than remembering whether age is element 2 or element 3.