Skip to content

Remove math eval command#7284

Merged
sholderbach merged 6 commits intonushell:mainfrom
sholderbach:remove-math-eval
Jan 4, 2023
Merged

Remove math eval command#7284
sholderbach merged 6 commits intonushell:mainfrom
sholderbach:remove-math-eval

Conversation

@sholderbach
Copy link
Copy Markdown
Member

@sholderbach sholderbach commented Nov 29, 2022

Description

Reasoning:

Most missing math commands are implemented with #7258.
The meval crate itself declares that it doesn't strive to stringent
standards (https://docs.rs/meval/latest/meval/#related-projects).
For example no particular special casing or transformations are
performed to ensure numerical stability. It uses the same rust std
library functions we use or have access to (and f64).
While the command call syntax in nushell may be a bit more verbose,
having a single source of truth and common commands is beneficial.
Furthermore the math commands can themselves implement broadcasting
over lists (or table columns).

Closes #7073

Removed dependencies:

  • meval
  • nom 1.2.4 (duplicate)

User-Facing Changes

Scripts using math eval will break.
We remove a further eval like behavior to get results through runtime evaluation (albeit limited in scope)

Tests

  • Updated tests that internally used math eval.
  • Removed one test that primarily used math eval to obtain a result from str join

@sholderbach sholderbach added the notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes label Nov 29, 2022
- [ ] Requires sign off from the team

Reasoning:

Most missing math commands are implemented with nushell#7258.
The `meval` crate itself declares that it doesn't strive to stringent
standards (https://docs.rs/meval/latest/meval/#related-projects).
For example no particular special casing or transformations are
performed to ensure numerical stability. It uses the same rust `std`
library functions we use or have access to (and `f64`).
While the command call syntax in nushell may be a bit more verbose,
having a single source of truth and common commands is beneficial.
Furthermore the `math` commands can themselves implement broadcasting
over lists (or table columns).

Closes nushell#7073

Removed dependencies:
- `meval`
- `nom 1.2.4` (duplicate)
@rgwood
Copy link
Copy Markdown
Contributor

rgwood commented Nov 29, 2022

Sounds good to me. Better to evaluate these kinds of expressions in native Nu code.

@sholderbach
Copy link
Copy Markdown
Member Author

Making a deprecation note for a subcommand currently kind of sucks:
https://github.com/sholderbach/nushell/blob/29fdfeee433c3bbf31667971cc4f3166faa3ac92/crates/nu-command/src/deprecated/deprecated_commands.rs#L3
We would need to carry the command around returning an error as long as the math base help command exists. (Same applies for url parse where we only have it left)

`math eval` now under `nu-command/src/deprecated`
This gives a deprecation warning when opening the help and guides you if
you use the bare command. But in original usage the deprecation warning
is useless as you get an error about the number of arguments.

We should do better
@sholderbach
Copy link
Copy Markdown
Member Author

Not happy with the state of deprecation yet #7530
Else the removal could go ahead as soon as we are happy. Will have to update a few scripts that still rely on math eval

@sholderbach sholderbach marked this pull request as ready for review January 4, 2023 22:10
@sholderbach sholderbach merged commit 9bc4e67 into nushell:main Jan 4, 2023
@sholderbach sholderbach deleted the remove-math-eval branch January 4, 2023 22:50
@rgwood
Copy link
Copy Markdown
Contributor

rgwood commented Jan 5, 2023

Nice, thanks for getting this over the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove math eval and fully replace it with pure nushell implementation

2 participants