Re:GUIDs Are Not the Only Answer
by winrid on Tuesday January 05, 2021 @06:39PM
(#25652849)
This is one thing I like about type systems where you can declare a primitive type as MyImportantThing. This ensures the string or what have you is explicitly defined as MyImportantThing. Rust does this pretty well. C/C++ AFAIK will let you pass in the raw string, and so will Java if you "extend String".
[ Parent
| on HN ]
You're talking about what is called the newtype pattern in Rust, and the newtype language feature in e.g. Haskell, right?
What does it mean to “extend String” in Java? You can’t, of course, literally do that.