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

Support for evaluating mathematical expressions #37

Open
gbaranski opened this issue Mar 24, 2021 · 4 comments
Open

Support for evaluating mathematical expressions #37

gbaranski opened this issue Mar 24, 2021 · 4 comments

Comments

@gbaranski
Copy link

Hello, Spotlight search from MacOS had this feature and in my opinion it was great and useful. What do you think about adding this feature?

image

@l4l
Copy link
Owner

l4l commented Mar 26, 2021

Hi there, thank you for a proposal and sorry for a long response!
To be honest this proposal sounds quite a strange feature request for me, hah. While it may seem like a useful feature to you I'd like to note some downsides:

  • Broken single responsibility principle (i.e. it's no longer just a app launcher, but also a calculator);
  • Potential code complexity (code for parsing, evaluating and additional code for rendering may take up to +30-40% of current codebase size);
  • Current version supports several "magical" separators (Implement magic separators #19), which may increase parsing complexity.

Personally I use a python interpreter for that case (any other interpreted language also should work fine). Is there any problem with that solution for you? What kind of complexity from these expressions do you expect, only a basic arithmetic (i.e. +/-/*//) or something else as well? Do you need/expect an arbitrary precision calculation? What behavior do you expect when the expression and the result does not fit a single line? Do you have any other examples where the similar feature is integrated besides Spotlight?

@gbaranski
Copy link
Author

Broken single responsibility principle (i.e. it's no longer just a app launcher, but also a calculator);

Or just advanced app launcher 😆

Potential code complexity (code for parsing, evaluating and additional code for rendering may take up to +30-40% of current codebase size);

We can just use fastval crate or something like that.

Personally I use a python interpreter for that case (any other interpreted language also should work fine). Is there any problem with that solution for you?

I also use python for that, but it takes some time to launch and it's easier to just use $mod+d and write expression.

What kind of complexity from these expressions do you expect, only a basic arithmetic (i.e. +/-/*//) or something else as well?

Basic arithmetic would be great, however functions like sqrt() or cos() would be great to add.

Do you need/expect an arbitrary precision calculation?

Yeah that would be great.

What behavior do you expect when the expression and the result does not fit a single line?

Not sure about that, Spotlight solves that by expanding search view.

Do you have any other examples where the similar feature is integrated besides Spotlight?

Yeah, Ulauncher and Albert.

If you don't find this feature useful, it's completely fine.

Thanks for response

@l4l
Copy link
Owner

l4l commented Mar 27, 2021

Cool, thanks for detailed answers!
I don't consider the feature useless, just felt it slightly outside of project scope. But potentially it's indeed might be very handy. Unfortunately I have no time for that, but still I would like to accept a PR (and help with the code if needed).

What behavior do you expect when the expression and the result does not fit a single line?

Not sure about that, Spotlight solves that by expanding search view.

So far, it's easier implement it without handling that case. For now there's no handling for overflowed input value.

@RichardFevrier
Copy link

Math expr evaluations is something that I miss the most from OSX too (paste & copy the result also).
Thank you for pointing Albert @gbaranski I will have to try it!

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

3 participants