You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on Martin Fowler:
A large proportion of the computers in this world manipulate money, so it's always puzzled me that money isn't actually a first class data type in any mainstream programming language. The lack of a type causes problems, the most obvious surrounding currencies. If all your calculations are done in a single currency, this isn't a huge problem, but once you involve multiple currencies you want to avoid adding your dollars to your yen without taking the currency differences into account. The more subtle problem is with rounding. Monetary calculations are often rounded to the smallest currency unit. When you do this it's easy to lose pennies (or your local equivalent) because of rounding errors.
The good thing about object-oriented programming is that you can fix these problems by creating a Money class that handles them. Of course, it's still surprising that none of the mainstream base class libraries actually do this.
I assume this proposal can only solve the money problem.
If this proposal need change the golang syntax, than it may make more problems than it solves. (like everyone use the golang need to learn this syntax to understand other's code)
If this proposal do not need change the golang syntax, then it will be better to implement outside GOROOT.
ianlancetaylor
changed the title
proposel: Go 2: introduce a money package
proposal: Go 2: introduce a money package
Dec 7, 2018
Thanks, but in order to move forward we need a specific proposal with an API. At the moment it seems to me that this can be done entirely in a library, and that library doesn't need to be in the standard library. Closing for now but please feel free to comment.
Introduce a money package in Go2
Based on Martin Fowler:
A large proportion of the computers in this world manipulate money, so it's always puzzled me that money isn't actually a first class data type in any mainstream programming language. The lack of a type causes problems, the most obvious surrounding currencies. If all your calculations are done in a single currency, this isn't a huge problem, but once you involve multiple currencies you want to avoid adding your dollars to your yen without taking the currency differences into account. The more subtle problem is with rounding. Monetary calculations are often rounded to the smallest currency unit. When you do this it's easy to lose pennies (or your local equivalent) because of rounding errors.
The good thing about object-oriented programming is that you can fix these problems by creating a Money class that handles them. Of course, it's still surprising that none of the mainstream base class libraries actually do this.
https://martinfowler.com/eaaCatalog/money.html
https://martinfowler.com/bliki/CurrencyAsValue.html
The text was updated successfully, but these errors were encountered: