fasteval icon indicating copy to clipboard operation
fasteval copied to clipboard

Add REPL binary target

Open Stupremee opened this issue 5 years ago • 8 comments

It would be great if you could provide a binary target which is a REPL to quickly perform calculations in the command line.

I would work on this issue if you accpet it

Stupremee avatar Jan 17 '20 21:01 Stupremee

I already have a REPL in the 'examples' directory: https://github.com/likebike/fasteval/blob/master/examples/repl.rs

It can be run like this: rlwrap cargo run --release --example repl

Were you thinking of something different? I'd be happy to consider your ideas.

likebike avatar Jan 20 '20 05:01 likebike

One constraint is that I don't want to add too many dependencies to 'fasteval'. But a REPL really needs a good 'readline' user interface. That's why I structured this to be wrapped with 'rlwrap'.

One possible solution would be to make another 'fasteval-repl' crate which uses the 'fasteval' library, but produces a repl binary. This way, dependencies like readline can be isolated from 'fasteval'.

Do you have other ideas?

likebike avatar Jan 20 '20 05:01 likebike

That’s exactly what I thought of. I saw the example and created my own binary but it’s much easier if you provide a fasteval REPL crate.

Stupremee avatar Jan 20 '20 10:01 Stupremee

If you want to create a REPL crate, that's fine with me. I personally don't want to create an official REPL right now because it would actually take a lot of work to create a really really good REPL. You see, fasteval is actually a very capable library; The REPL that I provide as an example barely "scratches the surface" of fasteval's abilities. If I made a REPL, I would want to include advanced functionality, like the ability to create user-defined functions at run-time, and I would probably want to implement additional number types besides f64 (I'd probably want BitInteger support, along with cryptography functions, and I'd probably want Rational numbers too. Oh! and definitely complex numbers!)...

In other words, creating a great REPL is really a lot of work. If we just create a very-simple REPL (like the example), then I don't think it's actually useful for anything -- it's not an interesting product. Python and bc are already better. That's why I feel it deserves an example, but not an official crate at this point.

likebike avatar Jan 21 '20 07:01 likebike

I'll create an official REPL after we have Advanced Numeric Types:

  • Complex Numbers
  • Rational Numbers
  • Arbitrary Precision Numbers
  • Big Integers + Crypto

Update: I created #7 to track this goal.

likebike avatar Jan 21 '20 07:01 likebike

Okay. Thanks for the information.

Stupremee avatar Jan 21 '20 10:01 Stupremee

@likebike I'm sharing my fasteval-repl with my friends (cargo install conveniency). I will take it down if you do mind or when you implemented Advanced Numeric Types or when the official REPL is going to be published.

I will understand if you mind for the name and thank you @likebike for your great library :pray:

Ujang360 avatar Feb 29 '20 12:02 Ujang360

@Ujang360 I don't mind at all. Thanks for doing this!

In the future, once fasteval is more mature, I think we can make and even better REPL. But for now, this is a good solution.

likebike avatar Mar 01 '20 00:03 likebike