maybe: allows optional chaining of field access and indexing when LHS i snil (#13023)

* maybe: allows optional chaining
* fix tools/kochdocs.nim
* improve semantics to distinguish valid from invalid values
* for now, wrapnil, isValid, unwrap are not exported
This commit is contained in:
Timothee Cour 2020-01-18 03:24:56 -08:00 • committed by Andreas Rumpf
commit f6ba4e81b0
4 changed files with 196 additions and 0 deletions

View file

@ -55,6 +55,10 @@
- Added `times.fromUnixFloat,toUnixFloat`, subsecond resolution versions of `fromUnix`,`toUnixFloat`.
- Added `wrapnils` module for chains of field-access and indexing where the LHS can be nil.
This simplifies code by reducing need for if-else branches around intermediate maybe nil values.
Eg: `echo ?.n.typ.kind`
## Library changes
- `asyncdispatch.drain` now properly takes into account `selector.hasPendingOperations`