nushell / nushell/nushell.github.io
Are Boolean operators lazy?
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 258
- Fork
- 561
- Merge medio
- 3h 20m
- PR unite (30g)
- 15
Descrizione
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?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalla pagina della documentazione Boolean collegata e dalla issue 10237 di Nushell a cui si fa riferimento. Verifica se and e or hanno la garanzia di essere valutati lazy, quindi documenta il comportamento confermato e le sue implicazioni per l'esempio mostrato nella pagina della documentazione Boolean appropriata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- shell
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100