Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absent variable on left side of boolean OR (||) expression makes it absent #1434

Merged
merged 6 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ build:
@echo "Build complete. The Miller executable is ./mlr (or .\mlr.exe on Windows)."
@echo "You can use 'make check' to run tests".

quiet:
@go build github.com/johnkerl/miller/cmd/mlr

# For interactive use, 'mlr regtest' offers more options and transparency.
check: unit-test regression-test
@echo "Tests complete. You can use 'make install' if you like, optionally preceded"
Expand Down
2 changes: 2 additions & 0 deletions docs/src/data/filenames.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
data/a.csv
data/b.csv
3 changes: 2 additions & 1 deletion docs/src/manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ MILLER(1) MILLER(1)
mlr help mlrrc
mlr help output-colorization
mlr help type-arithmetic-info
mlr help type-arithmetic-info-extended
Shorthands:
mlr -g = mlr help flags
mlr -l = mlr help list-verbs
Expand Down Expand Up @@ -3648,5 +3649,5 @@ MILLER(1) MILLER(1)



2023-11-12 MILLER(1)
2023-12-02 MILLER(1)
</pre>
3 changes: 2 additions & 1 deletion docs/src/manpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ MILLER(1) MILLER(1)
mlr help mlrrc
mlr help output-colorization
mlr help type-arithmetic-info
mlr help type-arithmetic-info-extended
Shorthands:
mlr -g = mlr help flags
mlr -l = mlr help list-verbs
Expand Down Expand Up @@ -3627,4 +3628,4 @@ MILLER(1) MILLER(1)



2023-11-12 MILLER(1)
2023-12-02 MILLER(1)
1 change: 1 addition & 0 deletions docs/src/online-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Other:
mlr help mlrrc
mlr help output-colorization
mlr help type-arithmetic-info
mlr help type-arithmetic-info-extended
Shorthands:
mlr -g = mlr help flags
mlr -l = mlr help list-verbs
Expand Down
7 changes: 4 additions & 3 deletions docs/src/record-heterogeneity.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ with 1) for too-long rows:
},
{
"a": 4,
"b": 5,
"c": ""
"b": 5
},
{
"a": 7,
Expand Down Expand Up @@ -455,7 +454,9 @@ Miller handles explicit header changes as just shown. If your CSV input contains
<pre class="pre-non-highlight-in-pair">
a,b,c
1,2,3
4,5,

a,b
4,5

a,b,c,4
7,8,9,10
Expand Down
45 changes: 36 additions & 9 deletions docs/src/reference-main-null-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,44 @@ resource=/some/other/path,loadsec=0.97,ok=false,loadmillis=970

## Arithmetic rules

If you're interested in a formal description of how empty and absent fields participate in arithmetic, here's a table for plus (other arithmetic/boolean/bitwise operators are similar):
If you're interested in a formal description of how empty and absent fields participate in arithmetic, here's a table for `+`, `&&, and `||`. Notes:

* Other arithmetic, boolean, and bitwise operators besides `&&` and `||` are similar to `+`.
* The `&&` and `||` obey _short-circuiting semantics_. That is:
* `false && X` is `false` and `X` is not evaluated even if it is a complex expression (maybe including function calls)
* `true || X` is `true` and `X` is not evaluated even if it is a complex expression (maybe including function calls)
* This means in particular that:
* `false && X` is false even if `X` is an error, a non-boolean type, etc.
* `true || X` is true even if `X` is an error, a non-boolean type, etc.

<pre class="pre-highlight-in-pair">
<b>mlr help type-arithmetic-info</b>
<b>mlr help type-arithmetic-info-extended</b>
</pre>
<pre class="pre-non-highlight-in-pair">
(+) | 1 2.5 (empty) (absent) (error)
------ + ------ ------ ------ ------ ------
1 | 2 3.5 1 1 (error)
2.5 | 3.5 5 2.5 2.5 (error)
(empty) | 1 2.5 (empty) (absent) (error)
(absent) | 1 2.5 (absent) (absent) (error)
(error) | (error) (error) (error) (error) (error)
(+) | 1 2.5 true (empty) (absent) (error)
------ + ------ ------ ------ ------ ------ ------
1 | 2 3.5 (error) 1 1 (error)
2.5 | 3.5 5 (error) 2.5 2.5 (error)
true | (error) (error) (error) (error) (error) (error)
(empty) | 1 2.5 (error) (empty) (absent) (error)
(absent) | 1 2.5 (error) (absent) (absent) (error)
(error) | (error) (error) (error) (error) (error) (error)

(&&) | true false 3 (empty) (absent) (error)
------ + ------ ------ ------ ------ ------ ------
true | true false (error) (error) (absent) (error)
false | false false false false false false
3 | (error) (error) (error) (error) (absent) (error)
(empty) | true false (error) (error) (absent) (error)
(absent) | true false (error) (absent) (absent) (error)
(error) | (error) (error) (error) (error) (error) (error)

(||) | true false 3 (empty) (absent) (error)
------ + ------ ------ ------ ------ ------ ------
true | true true true true true true
false | true false (error) (error) (absent) (error)
3 | (error) (error) (error) (error) (absent) (error)
(empty) | true false (error) (error) (absent) (error)
(absent) | true false (error) (absent) (absent) (error)
(error) | (error) (error) (error) (error) (error) (error)
</pre>
12 changes: 10 additions & 2 deletions docs/src/reference-main-null-data.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,16 @@ GENMD-EOF

## Arithmetic rules

If you're interested in a formal description of how empty and absent fields participate in arithmetic, here's a table for plus (other arithmetic/boolean/bitwise operators are similar):
If you're interested in a formal description of how empty and absent fields participate in arithmetic, here's a table for `+`, `&&, and `||`. Notes:

* Other arithmetic, boolean, and bitwise operators besides `&&` and `||` are similar to `+`.
* The `&&` and `||` obey _short-circuiting semantics_. That is:
* `false && X` is `false` and `X` is not evaluated even if it is a complex expression (maybe including function calls)
* `true || X` is `true` and `X` is not evaluated even if it is a complex expression (maybe including function calls)
* This means in particular that:
* `false && X` is false even if `X` is an error, a non-boolean type, etc.
* `true || X` is true even if `X` is an error, a non-boolean type, etc.

GENMD-RUN-COMMAND
mlr help type-arithmetic-info
mlr help type-arithmetic-info-extended
GENMD-EOF
3 changes: 2 additions & 1 deletion man/manpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ MILLER(1) MILLER(1)
mlr help mlrrc
mlr help output-colorization
mlr help type-arithmetic-info
mlr help type-arithmetic-info-extended
Shorthands:
mlr -g = mlr help flags
mlr -l = mlr help list-verbs
Expand Down Expand Up @@ -3627,4 +3628,4 @@ MILLER(1) MILLER(1)



2023-11-12 MILLER(1)
2023-12-02 MILLER(1)
5 changes: 3 additions & 2 deletions man/mlr.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: mlr
.\" Author: [see the "AUTHOR" section]
.\" Generator: ./mkman.rb
.\" Date: 2023-11-11
.\" Date: 2023-12-02
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "MILLER" "1" "2023-11-11" "\ \&" "\ \&"
.TH "MILLER" "1" "2023-12-02" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Portability definitions
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -192,6 +192,7 @@ Other:
mlr help mlrrc
mlr help output-colorization
mlr help type-arithmetic-info
mlr help type-arithmetic-info-extended
Shorthands:
mlr -g = mlr help flags
mlr -l = mlr help list-verbs
Expand Down
Loading
Loading