calc issueshttps://gitlab.redox-os.org/redox-os/calc/-/issues2021-02-14T12:55:24Zhttps://gitlab.redox-os.org/redox-os/calc/-/issues/31Unable to install with cargo2021-02-14T12:55:24ZDaniel del CastilloUnable to install with cargoWhen trying to `cargo install calculate` I got the following error:
```
error[E0503]: cannot use `self.key_bindings` because it was mutably borrowed
--> /home/daniel/.cargo/registry/src/github.com-1ecc6299db9ec823/liner-0.4.4/src/conte...When trying to `cargo install calculate` I got the following error:
```
error[E0503]: cannot use `self.key_bindings` because it was mutably borrowed
--> /home/daniel/.cargo/registry/src/github.com-1ecc6299db9ec823/liner-0.4.4/src/context.rs:98:17
|
96 | let ed = try!(Editor::new_with_init_buffer(stdout, prompt, self, buffer));
| ---- borrow of `*self` occurs here
97 | match self.key_bindings {
98 | KeyBindings::Emacs => Self::handle_keys(keymap::Emacs::new(ed), handler),
| ^^^^^^^^^^^^^^^^^^ use of borrowed `*self`
99 | KeyBindings::Vi => Self::handle_keys(keymap::Vi::new(ed), handler),
| -- borrow later used here
error: aborting due to previous error
```
This happens because the crate still depends on liner v0.4.4, and it works on master (which uses 0.5).https://gitlab.redox-os.org/redox-os/calc/-/issues/30Unable to build on windows 72020-07-13T12:52:55ZPhilip RidoutUnable to build on windows 7Windows 7
```
>rustc --version
rustc 1.46.0-nightly (8aa18cbdc 2020-07-08)
```
I tried to build the example from README.md and got the following:
``` Updating crates.io index
Downloaded bytecount v0.1.7
Downloaded ord_subset v3....Windows 7
```
>rustc --version
rustc 1.46.0-nightly (8aa18cbdc 2020-07-08)
```
I tried to build the example from README.md and got the following:
``` Updating crates.io index
Downloaded bytecount v0.1.7
Downloaded ord_subset v3.1.1
Downloaded rustc-serialize v0.3.24
Downloaded calculate v0.5.1
Downloaded decimal v2.0.4
Downloaded liner v0.4.4
Downloaded 6 crates (1021.2 KB) in 3.61s
Compiling libc v0.2.72
Compiling winapi v0.3.9
Compiling serde v1.0.114
Compiling ord_subset v3.1.1
Compiling bytecount v0.1.7
Compiling rustc-serialize v0.3.24
Compiling decimal v2.0.4
Compiling termion v1.5.5
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\lib.rs:24:9
|
24 | pub use sys::size::terminal_size;
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\lib.rs:27:9
|
27 | pub use sys::tty::{is_tty, get_tty};
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1.
5.5\src\async.rs:5:5
|
5 | use sys::tty::get_tty;
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0433]: failed to resolve: unresolved import
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:29:5
|
29 | use sys::attr::{get_terminal_attr, raw_terminal_attr, set_terminal_attr};
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0432]: unresolved import `sys`
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:28:5
|
28 | use sys::Termios;
| ^^^
| |
| unresolved import
| help: a similar path exists: `color::env::sys`
error[E0425]: cannot find function `get_tty` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\async.rs:14:36
|
14 | thread::spawn(move || for i in get_tty().unwrap().bytes() {
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `get_tty` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\async.rs:43:36
|
43 | thread::spawn(move || for i in get_tty().unwrap().bytes() {
| ^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:45:9
|
45 | set_terminal_attr(&self.prev_ios).unwrap();
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `get_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:90:23
|
90 | let mut ios = get_terminal_attr()?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `raw_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:93:9
|
93 | raw_terminal_attr(&mut ios);
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-1
.5.5\src\raw.rs:95:9
|
95 | set_terminal_attr(&ios)?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:107:9
|
107 | set_terminal_attr(&self.prev_ios)?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `get_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:113:23
|
113 | let mut ios = get_terminal_attr()?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `raw_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:114:9
|
114 | raw_terminal_attr(&mut ios);
| ^^^^^^^^^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `set_terminal_attr` in this scope
--> .cargo\registry\src\github.com-1ecc6299db9ec823\termion-
1.5.5\src\raw.rs:115:9
|
115 | set_terminal_attr(&ios)?;
| ^^^^^^^^^^^^^^^^^ not found in this scope
error: aborting due to 15 previous errors
Some errors have detailed explanations: E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `termion`.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
```https://gitlab.redox-os.org/redox-os/calc/-/issues/28Support wasm-targets2020-07-12T15:35:13ZBafDyceSupport wasm-targetsCurrently, the library, unfortunately, does not support `wasm` (Web Assembly) targets for the following issues:
1) For building the library it is also necessary to compile `atty`, `clap`, and `liner` (which cannot be compiled for wasm r...Currently, the library, unfortunately, does not support `wasm` (Web Assembly) targets for the following issues:
1) For building the library it is also necessary to compile `atty`, `clap`, and `liner` (which cannot be compiled for wasm rn) and which are not actually required for the library
2) The `decimal` and `num` dependencies both depend on `rustc-serialize` which cannot be built for wasm targets
**Possible solutions**
1) This one is trivial: Just declare `atty`, `clap`, and `liner` as optional dependencies required only for the binary. I implemented this in the following patch:
https://gitlab.redox-os.org/BafDyce/calc/commit/c93cabb050f6aad680ec553225321a09e7363268#1b290eb385892bfd4870c08a785598e98c8691b7
(Note that this now requires one to run `cargo build --bin calc --features=binary` to build the cli application)
2) This is a bit harder, especially since `calc` relies quite heavily on BigInts.
For now, I based my work on a relatively old commit (right before calc switched to BigInts) and applied a patch to only use stdlib data types (removing the `decimal` and `num` dependencies).
You can see that patch here:
https://gitlab.redox-os.org/BafDyce/calc/commit/45e2e587167dd09a3d331959328e331ef2aa8bfc
(Note that this is quite an ugly (imo) hack, is almost untested, and probably only works for "small" numbers)
If you're interested, I would be more than happy to provide a MR (against the latest master) for number **1** and also for the second patch (maybe you are interested in supporting a `wasm`-branch?). Maybe it would be even possible to support wasm-targets without using an outdated + hacked version of `calc`?
PS: I applied both of my patches in a wasm-branch on my fork: https://gitlab.redox-os.org/BafDyce/calc/commits/wasmhttps://gitlab.redox-os.org/redox-os/calc/-/issues/27Support `eval_with_vars()`2018-09-10T18:02:27ZBafDyceSupport `eval_with_vars()`It would be great if the library could support variables in the expression and evaluate them at runtime.
See the following example:
```rust
eval_with_vars("2 + {nn}", { xx = 3 }) // I know that this code won't work/compile.
```
Ideall...It would be great if the library could support variables in the expression and evaluate them at runtime.
See the following example:
```rust
eval_with_vars("2 + {nn}", { xx = 3 }) // I know that this code won't work/compile.
```
Ideally, this would support a data structure which can hold arbitrary variable names (a Hashmap?) without limiting the type of the values.
Maybe something like:
```rust
trait GetValue {
fn get_value(&self) -> Value;
}
fn eval_with_vars<T>(expression: &str, vars: &HashMap<&str, T>) -> Value
where T: GetValue
{
// stuff
}
```https://gitlab.redox-os.org/redox-os/calc/-/issues/25Integer Divide2018-06-10T16:52:21ZMichael Aaron Murphymmstick@pm.meInteger DivideWould be nice to have, so that
96 // 10 = 9
96 % 10 = 6Would be nice to have, so that
96 // 10 = 9
96 % 10 = 6https://gitlab.redox-os.org/redox-os/calc/-/issues/22Overflow panics on multiplication and exponentiation2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meOverflow panics on multiplication and exponentiation*Created by: xTibor*
**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("2 ** 63"));
println!("{:?}", eval("3040000000 * 3040000000"));
```
**Expected behavior**:
Getting a `CalcError::WouldOverflow` result...*Created by: xTibor*
**Reproduction**:
```rust
use calc::eval;
// ...
println!("{:?}", eval("2 ** 63"));
println!("{:?}", eval("3040000000 * 3040000000"));
```
**Expected behavior**:
Getting a `CalcError::WouldOverflow` result.
**Actual behavior**:
A panic with an `'attempt to multiply with overflow'` message.
**Build information**:
* `calc`: Latest version from crates.io (`0.5.*`)
* `rustc -V`: `rustc 1.23.0-nightly (e340996ff 2017-11-02)`
* System: KDE neon 5.11 (Ubuntu 16.04 LTS)
**Misc**:
I encountered this issue via Ion's [arithmetic expansions](https://doc.redox-os.org/ion-manual/ch05-04-arithmetic.html).
https://gitlab.redox-os.org/redox-os/calc/-/issues/21Conversion for f32 / f64 into Value2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meConversion for f32 / f64 into Value*Created by: Refefer*
Any thoughts of ways to convert f32 / f64 (as well as other native data types) into Value objects? *Created by: Refefer*
Any thoughts of ways to convert f32 / f64 (as well as other native data types) into Value objects? https://gitlab.redox-os.org/redox-os/calc/-/issues/20Add `examples` subprojects2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meAdd `examples` subprojects*Created by: huntergoldstein*
# Problem
#19 shouldn't have happened. It was the intent that users could construct their own `Environment`s and pass them into `parse::eval` et al.
# Solution
Create examples sub-projects that are int...*Created by: huntergoldstein*
# Problem
#19 shouldn't have happened. It was the intent that users could construct their own `Environment`s and pass them into `parse::eval` et al.
# Solution
Create examples sub-projects that are integrated with `cargo test` that serve as example libraries / applications. These would serve as regression tests for API changes. https://gitlab.redox-os.org/redox-os/calc/-/issues/9Long Term Goals / Features2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meLong Term Goals / Features*Created by: mgmoens*
A couple of things I'd like:
- variables: the symbolic and the substituted kind. I.e. y = x + 1 and y² would result in (x² +2x +1)
- differential calculus: symbolic and numeric integration and differentiati...*Created by: mgmoens*
A couple of things I'd like:
- variables: the symbolic and the substituted kind. I.e. y = x + 1 and y² would result in (x² +2x +1)
- differential calculus: symbolic and numeric integration and differentiation. It doesn't really have to go all that far, but it's something I've been craving for some time. If I need to calculate an integral I forgot (or that's too hard or when I'm too lazy) I'd need to google it, hope Wolfram has it or get a license from school to open Maple and calculate it that way...
I think I'm not the only user in want of something like this. But it's probably pretty hard.https://gitlab.redox-os.org/redox-os/calc/-/issues/5Step-by-Step Arithmetic Resolver2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meStep-by-Step Arithmetic ResolverPerhaps also offer an option to display each step in the process of resolving an expression?Perhaps also offer an option to display each step in the process of resolving an expression?https://gitlab.redox-os.org/redox-os/calc/-/issues/3Vector Operations2018-06-10T06:47:01ZMichael Aaron Murphymmstick@pm.meVector Operations*Created by: huntergoldstein*
Could we support vector operations? For example:
```
[1 0 0] x [0 1 0] => [0 0 1]
```
or
```
[1 7] * [3 2] => 17
```
Having `x` as an infix operator might conflict with some of the ideas in #2.*Created by: huntergoldstein*
Could we support vector operations? For example:
```
[1 0 0] x [0 1 0] => [0 0 1]
```
or
```
[1 7] * [3 2] => 17
```
Having `x` as an infix operator might conflict with some of the ideas in #2.