l4l / yofi

yofi is a minimalistic menu for wayland
https://crates.io/crates/yofi
MIT License
332 stars 22 forks source link

Support for evaluating mathematical expressions #37

Open gbaranski opened 3 years ago

gbaranski commented 3 years ago

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 commented 3 years ago

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:

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 commented 3 years ago

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

Or just advanced app launcher :laughing:

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 commented 3 years ago

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 commented 2 months ago

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!