Skip to content
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

Calculator example bugs and improvements #2576

Open
ghost opened this issue Nov 9, 2017 · 1 comment
Open

Calculator example bugs and improvements #2576

ghost opened this issue Nov 9, 2017 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 9, 2017

This may be the first example many people will look at so imho it deserves some love. Do you prefer very small grained PRs or dumping smaller things into this thread?

Anyway, the first issue that hit me is that "ln" and "log" do nothing. "ln" should be unary and adding it to the uops is straightforward and works as expected. "log" appears to be intended as binary and I can not see why it does not work.

Also the whole logic of the calculator suffers a bit from the problem that "basic" and "scientific" calculators almost always use different logic of evaluation: "basic" won't honour arithmetic precedence rules, scientific will. So it may be an idea to concentrate on the scientific branch and make it real good.

@xymus
Copy link
Contributor

xymus commented Nov 14, 2017

I agree, the calculator needs love. I've addressed a few issues you raised in #2579, but there is still work to do. I welcome small grained PRs and we can keep general discussions here.

The calculator project was more of an excuse to test/showcase the UI system, I spent less time on the underlying logic and it has badly evolved. The scientific ops were added quickly and may very well have issues. Feel free to improve the logic or rewrite it, separating the scientific logic could be a good idea to preserve a simple behavior in the classic variant.

My priority with the calculator is to keep the UI code simple and clean, but the logic can get more complex.

I have a suggestion to implement the precedence rules (and support keyboard input as a bonus), you could use and extend the calc example of nitcc (the Nit Compiler Compiler). The calc example is basically a calculator interpreting a string: https://github.com/nitlang/nit/tree/master/contrib/nitcc/examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant