News for hackers. Stuff that matters.
Re:Twenty five thousand dollars of funny money by diarrhea on Saturday December 03, 2022 @04:27PM (#33847551)
At that point, why not have dedicated types and get rid of primitive ones? It shifts all that work to the compiler, whose job it is to excel at this kind of stuff (adding cents to penny types does the right thing automatically etc).
Re:Twenty five thousand dollars of funny money by mrkeen on Sunday December 04, 2022 @09:26AM (#33853961)
Because you still have to co-exist with other software beyond the type system's boundaries. The amounts are going to be converted to/from JSON, put in and out of databases, show up in logs etc.

When it comes time to invoke Amount.fromCents(..) at the boundary of the system, it's nice if the front-end posts a variable called amountInCents.