New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instance or static methods for non-operator calculations? #37
Comments
When the order of the operands doesn’t matter then static makes more sense to me; when they do, I’d personally lean towards instance methods. |
If we add methods for arithmetic operations to give rounding parameters, I think it'd be confusing to make |
I think we should stick with the "principle of least surprise" and follow the current ES pattern. This means not all methods would be static or instance. But we should only choose this option if there's no consensus. If we can settle on a consensus that does things in a different way, we should try it, we shouldn't stick to the past just because "it has always been this way". My personal opinion is that frequently used methods should be on the prototype, while "more special" methods are static, this reduces the need for minification in some cases, and saves time for the devs and users |
Fabrice Bellard's BigDecimal implementation in QuickJS (2020-01-05 release) uses static methods like
BigDecimal.div
rather than instance methods likeBigDecimal.prototype.div
, as the current README suggests. In personal communication, Fabrice said,BigDecimal.round
is also a static method in QuickJS, and an instance method in the current README.I could go either way on this ergonomics question. I thought instance methods would be easier to type, but I don't have strong feelings.
The text was updated successfully, but these errors were encountered: