nushell/crates/nu-command/src/dataframe
JT 13515c5eb0
Limited mutable variables (#7089)
This adds support for (limited) mutable variables. Mutable variables are created with mut much the same way immutable variables are made with let.

Mutable variables allow mutation via the assignment operator (=).

❯ mut x = 100
❯ $x = 200
❯ print $x
200

Mutable variables are limited in that they're only tended to be used in the local code block. Trying to capture a local variable will result in an error:

❯ mut x = 123; {|| $x }
Error: nu::parser::expected_keyword (link)

  × Capture of mutable variable.

The intent of this limitation is to reduce some of the issues with mutable variables in general: namely they make code that's harder to reason about. By reducing the scope that a mutable variable can be used it, we can help create local reasoning about them.

Mutation can occur with fields as well, as in this case:

❯ mut y = {abc: 123}
❯ $y.abc = 456
❯ $y

On a historical note: mutable variables are something that we resisted for quite a long time, leaning as much as we could on the functional style of pipelines and dataflow. That said, we've watched folks struggle to work with reduce as an approximation for patterns that would be trivial to express with local mutation. With that in mind, we're leaning towards the happy path.
2022-11-11 19:51:08 +13:00
..
eager update polar to 0.25 (#6988) 2022-11-10 11:07:38 +13:00
expressions update polar to 0.25 (#6988) 2022-11-10 11:07:38 +13:00
lazy update polar to 0.25 (#6988) 2022-11-10 11:07:38 +13:00
series update polar to 0.25 (#6988) 2022-11-10 11:07:38 +13:00
values Limited mutable variables (#7089) 2022-11-11 19:51:08 +13:00
mod.rs Lazy dataframes (#5546) 2022-05-16 08:27:43 +01:00
README.md Update the Readme for the dataframe directory (#4757) 2022-03-06 11:05:55 -08:00
test_dataframe.rs Split merging of parser delta and stack environment (#6005) 2022-07-14 17:09:27 +03:00
utils.rs Lazy dataframes (#5546) 2022-05-16 08:27:43 +01:00

Dataframe

This dataframe directory holds all of the definitions of the dataframe data structures and commands.

There are three sections of commands:

For more details see the Nushell book section on dataframes