4 ms·
2) Value types in structures would need to be nominal, not structural. I really don't care if I get a tuple of [Int32, String], I very rarely care what the mac
by stcredzero 7y ago
2) Value types in structures would need to be nominal, not structural. I really don't care if I get a tuple of
[Int32, String], I very rarely care what the machine level types are, what I really want is [ProductID, ProductName],
what the underlying types are doesn't really matter to me.
In Go, there's a practice called "microtyping" (credit goes to HN user jerf) where everything is type defined to a semantic name. So you never have a struct with a string for ProductID and ProductName. Instead, you have a struct containing a ProductID and a ProductName. This makes it very easy to change your mind. I used to have a base64 encoded UUID as an EntityID in my MMO. I implemented microtyping, and after that, changing EntityID to 128 bits was a breeze!
- dvlsg 7y agoF# is good for this, too. It _kind_ of works in typescript, but it's not enforced by tsc. Definitely helps readability, though.