nushell / nushell/nushell.github.io

Are Boolean operators lazy?

オープン
#2,072 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
TypeScript
スター
258
フォーク
561
平均マージ
3時間 20分
マージ済み PR(30日)
15

説明

Hello,

TL;DR: Are the and and or Boolean operators guaranteed to be lazy, so we can document it?


I encountered this bug https://github.com/nushell/nushell/issues/10237 which makes last error out on an empty input instead of returning a null if I understand correctly.

So I have written this workaround:

  let filler = if ($text != "") and ($text | split chars | last) == "%" { "%" } else { " " }

This code works without errors for me, so the RHS of the and Boolean operator must not be evaluated / be lazily evaluated.
To put it short, the and operator seems lazy (nu version 0.108.0)

I cannot find it documented in Boolean | Nushell and looking for "lazy" in the documentation does not yield anything related to Booleans.

Is and guaranteed to be lazy in future versions? What about or?
Should we document this behavior?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされている Boolean のドキュメントページと、参照されている Nushell の issue 10237 から始めてください。andor が遅延評価されることが保証されているかを確認し、その後、確認できた動作と、適切な Boolean のドキュメントページにある示された例への影響を文書化してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
shell
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。