Skip to content

use only null as the value and the type for "nothing"#9918

Closed
amtoine wants to merge 18 commits intonushell:mainfrom
amtoine:remove-nothing-type-and-value
Closed

use only null as the value and the type for "nothing"#9918
amtoine wants to merge 18 commits intonushell:mainfrom
amtoine:remove-nothing-type-and-value

Conversation

@amtoine
Copy link
Copy Markdown
Member

@amtoine amtoine commented Aug 4, 2023

⚠️ breaking change ⚠️

Description

in the Discord server, there has been a discussion about null and $nothing
being confusing.
i thought i would give this a try 😏

Note
the changes in this PR are quite big and touch almost the whole source base 😱
but bare with me, most of it has been writen though automatic replacement either with

  • IDE renaming
  • find/replace calls to sd

Note
i invite reviewers to check the commit messages

  • the first commits mentioning "renaming" enums have been made with my IDE
  • the commits mentioning "commands used" are automatic
  • the rest is manual

This PR

  • renames the nothing type into null
  • removes the $nothing variable, leaving only null as before

👍👍 pros:

  • makes the language simpler without null and $nothing doing the same thing
  • unifies null as the type and null as the value

👎👎 cons:

  • pretty big breaking change
  • need to use "null" as the key in $env.config.color_config because
> {null: "foo"}
Error: nu::shell::cant_convert

  × Can't convert to string.
   ╭─[entry #1:1:1]
 1 │ {null: "foo"}
   ·  ──┬─
   ·    ╰── can't convert nothing to string
   ╰────

conclusion

i think removing $nothing is the important thing in this PR.
i think it makes the language simpler by removing this redundant variable as we
already have null 😋

the renaming of nothing type into null can be discussed and, i think, reverted
if we decide to keep (1) null as the value and (2) nothing as the type 😉

User-Facing Changes

  • the nothing type becomes null
  • the $nothing variable is removed and null as a value should be used

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • 🟢 toolkit test
  • 🟢 toolkit test stdlib

After Submitting

mention in the release notes!!

amtoine added 18 commits August 4, 2023 13:08
commands used
```nushell
sd "nothing" "null" **/*.rs
sd "nothing" "null" **/*.nu
```

replacements manually left because it's just english sentences using the
word "nothing":
- src/terminal.rs:            // Common case, nothing to do
- crates/nu-engine/src/env.rs:        None => { /* not preset, do nothing */ }
- crates/nu-glob/LICENSE-APACHE:   Notwithstanding the above, nothing herein shall supersede or modify
- crates/nu-glob/src/lib.rs:    /// match the input string and nothing else.
- crates/nu-glob/src/lib.rs:            // not a directory, nothing more to find
- crates/nu-system/src/foreground.rs:/// It does nothing special on windows system, `spawn` is the same as [std::process::Command::spawn](std::process::Command::spawn)
- crates/nu-table/src/types/expanded.rs:                // We consider showing something better then nothing,
- crates/nu-protocol/src/engine/stack.rs:                                // nothing has been hidden in this overlay
- crates/nu-protocol/src/engine/stack.rs:                                // nothing has been hidden in this overlay
command used
```nushell
sd "Value::Nothing" "Value::Null" **/*.rs
```
command used
```nushell
sd "Type::Nothing" "Type::Null" **/*.rs
```
the rest are ony comments and the LICENSE.
commands used
```nushell
sd --string-mode "$nothing" "null" **/*.rs
sd --string-mode "$nothing" "null" **/*.nu
sd --string-mode "$null" "null" **/*.rs
sd --string-mode "$null" "null" **/*.nu
```

format
@amtoine amtoine added A:type-system Problems or features related to nushell's type system semantics Places where we should define/clarify nushell's semantics notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes status:needs-core-team-attention An issue than needs the attention of other core-team members language notes:mention Include the release notes summary in the "Hall of Fame" section labels Aug 4, 2023
@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented Aug 4, 2023

and it was fun to play a bit with the language 😉

@amtoine
Copy link
Copy Markdown
Member Author

amtoine commented Aug 10, 2023

closing in favor of #9973 which only renames the type

@amtoine amtoine closed this Aug 10, 2023
@amtoine amtoine deleted the remove-nothing-type-and-value branch August 10, 2023 11:23
amtoine added a commit that referenced this pull request Sep 26, 2023
related to 
- #9973
- #9918

thanks to @jntrnr and their super useful tips on this PR, i learned
about the parser + evaluation, so 🙏

# Description
because we already have `null` as the value of the type `nothing` and as
a followup to the two other attempts of mine, i propose to remove the
redundant `$nothing` built-in variable 😋

this PR is the first step, deprecating `$nothing`.
a followup PR will remove it altogether and wait for 0.87 👍 

⚙️ **details**: a new `NOTHING_VARIABLE_ID = 3` has been added,
parsing `$nothing` will create it, finally a `Value::Nothing` will be
produced and a warning will be reported.

this PR already fixes the `toolkit.nu` module so that it does not throw
a bunch of warnings each time 👌

# User-Facing Changes
`$nothing` is now deprecated and will be removed in 0.87
```nushell
> $nothing
Error:   × Deprecated variable
   ╭─[entry #1:1:1]
 1 │ $nothing
   · ────┬───
   ·     ╰── `$nothing` is deprecated and will be removed in 0.87.
   ╰────
  help: Use `null` instead
```

# Tests + Formatting
tests have been updated, especially
- `nothing_fails_string`
- `nothing_fails_int`
which use a variable called `nil` now to make sure `nothing` does not
support cell paths 👍

# After Submitting
classic deprecation mention 👍
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
related to 
- nushell#9973
- nushell#9918

thanks to @jntrnr and their super useful tips on this PR, i learned
about the parser + evaluation, so 🙏

# Description
because we already have `null` as the value of the type `nothing` and as
a followup to the two other attempts of mine, i propose to remove the
redundant `$nothing` built-in variable 😋

this PR is the first step, deprecating `$nothing`.
a followup PR will remove it altogether and wait for 0.87 👍 

⚙️ **details**: a new `NOTHING_VARIABLE_ID = 3` has been added,
parsing `$nothing` will create it, finally a `Value::Nothing` will be
produced and a warning will be reported.

this PR already fixes the `toolkit.nu` module so that it does not throw
a bunch of warnings each time 👌

# User-Facing Changes
`$nothing` is now deprecated and will be removed in 0.87
```nushell
> $nothing
Error:   × Deprecated variable
   ╭─[entry #1:1:1]
 1 │ $nothing
   · ────┬───
   ·     ╰── `$nothing` is deprecated and will be removed in 0.87.
   ╰────
  help: Use `null` instead
```

# Tests + Formatting
tests have been updated, especially
- `nothing_fails_string`
- `nothing_fails_int`
which use a variable called `nil` now to make sure `nothing` does not
support cell paths 👍

# After Submitting
classic deprecation mention 👍
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:type-system Problems or features related to nushell's type system notes:breaking-changes This PR implies a change affecting users and has to be noted in the release notes notes:mention Include the release notes summary in the "Hall of Fame" section semantics Places where we should define/clarify nushell's semantics status:needs-core-team-attention An issue than needs the attention of other core-team members

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant