Re:Things I Was Wrong About: Types
by couchand on Sunday September 27, 2020 @11:47AM
(#24607506)
That isn't always a benefit, though. When interfacing with a database schema that uses small integers for ids, I'm all the time defining types like `struct CustomerId(u32)` and `struct InvoiceId(u32)`. It's incredibly valuable that the compiler will not let me mix up a customer and an invoice, even if both of them are 42.
[ Parent
| on HN ]
Re:Things I Was Wrong About: Types
by joshuamorton on Sunday September 27, 2020 @02:33PM
(#24609007)
Ad hoc and structural polymorphism can coexist. You can define an object that contains a customerid and an invoiceid, and they won't get mixed.