Commit graph

6 commits

Author SHA1 Message Date
Darren Schroeder
ef32e1ce1a
reset stack size to 10mb vs 2gb (#7103) 2022-11-11 15:22:26 -06:00
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
Darren Schroeder
f1118020a1
add commented out mold linker usage (#7081) 2022-11-10 08:41:06 -06:00
Reilly Wood
17a5aa3052
Statically link the CRT on Windows (#5717) 2022-06-05 17:01:01 -07:00
Darren Schroeder
352cf31db2
update comments, add other targets (#4891)
keep these other targets in case we need them in the future
2022-03-22 08:27:48 -05:00
Darren Schroeder
75f8247af1
added .cargo/config.toml to build with bigger stack on windows (#2594)
* added .cargo/config.toml to build with bigger stack on windows

* updated comments
2020-09-24 15:55:33 +12:00