Closed standarddeviant closed 1 year ago
The sources with rhai-repl
is included. So you can just clone it, load SciPackage
into engine
, and Bob's your uncle!
Will close this issue for now but please let us know if you run into issues loading rhai-sci
in rhai-repl
!
I appreciate the responses. And that makes sense regarding cloning and modifying. Closing the issue also makes sense to me.
I'm interested in using rust more in scientific contexts. I think rhai-repl
with rhai-sci
could be make rust more accessible to people more familiar with MATLAB.
Would there be long term interest in adding a command line option to rhai-repl
to automatically load rhai-sci
to the engine when it starts?
Interesting idea! I'll defer to @schungx on that one though.
I can potentially add a number of new feature flags that will load different packages, such as bin-sci
to load rhai-sci
into rhai-repl
and rhai-run
...
And the main bin-features
feature will automatically load all of them ...
I think that would be interesting to prototype and see how it works.
Regarding loading rhai-sci
into rhai-repl
on my local machine, I ran into what seems like a simple issue.
When I add the line rhai-sci = { version = "0.2.0" }
to Cargo.toml and the following lines to rhai_repl.rs
use rhai_sci::SciPackage;
...
// right after let mut engine = Engine::new();
engine.register_global_module(SciPackage::new().as_shared_module());
And then I run: cargo install --path . --bins --features bin-features
I see this output:
$ cargo install --path . --bins --features bin-features
Installing rhai v1.16.0 (C:\Users\davec\rust\rhai)
Updating git repository `https://github.com/schungx/rustyline`
Updating crates.io index
Blocking waiting for file lock on package cache
error: failed to compile `rhai v1.16.0 (C:\Users\davec\rust\rhai)`, intermediate artifacts can be found at `C:\Users\davec\rust\rhai\target`
Caused by:
There are multiple `rhai` packages in your project, and the specification `rhai` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
rhai@1.15.1
rhai@1.16.0
I tried adding the -p rhai@1.15.1
after cargo install, but that didn't work. Is it clear what I'm missing or need to reconfigure?
Well, since you are actually compiling Rhai itself ( rhai-repl
is a part of it), you cannot use crates that also depend on Rhai unless you specifically patch it in your cargo.toml
.
I suggest making a new repo, just copy rhai-repl
into it as a standalone project.
That makes sense - I'll try that. Thank you for the reply!
@schungx @cmccomb I have a prototype that I've put here for now: https://github.com/standarddeviant/rhai-sci-repl/tree/main
I'm relatively new to rust and cargo, so I still have a lot to learn. I welcome any suggestions - especially things I may have overlooked as a rust/cargo novice.
Is there a natural place to change how multi-dimensional arrays (i.e. arrays of arrays) are printed? I'd like to print 2D matrices in a pretty way.
I'm trying out reedline
instead of rustyline
because reedline
seems 'fancier out of the box' and I'm interested in fancy features (like hints, tab-complete, highlighting) longer term to have an experience somewhat similar to the IPython REPL. I plan to add various features there over time such as
ls
, pwd
, cd
, etc.Yes, when repl
was written, reedline
was not yet for production and the API was still in flux, so I stayed with rustyline
instead.
You're welcome to move it to reedline
and then contribute a PR back!
BTW, see if reedline
enables bracketed-paste on Windows by default... rustyline
doesn't so I had to spin my own...
This library looks great! I was using rhai-repl and would really like to use rhai-repl with rhai-sci loaded.
Is there an easy way to do that?