optional 1.0.0 beta with "or/frontOr/Throw" range utilities

aliak something at something.com
Mon Jul 29 22:17:20 UTC 2019


Hi,

After some feedback from the community [0], I'm happy to finally 
get the optional package to a 1.0.0 version. There is one 
breaking change with how pointer semantics behave, in that the 
previous version treated some!(int*)(null) as a non-empty 
optional, and some!Class(null) as an empty optional. These are 
both now treated as empty optionals.

Compilation changes include:
* orElse has been split in to "or" and "frontOr"
* dispatch() has been renamed to oc(); "optional chain"
* NotNull has been removed
* unwrap has been removed

Additions include:
* frontOrThrow: if there's no front of range then it will throw.
* or/frontOr work with any range, and Nullable!T.
* match will resolve to void if any of the handlers return void.

Added a whole bunch of "safety" checks, so CI runs with dip1000 
and dip25 enabled, and uses LLVM's address sanitizer. I still 
don't know how to deal with auto ref return values [1] so if 
anyone has any tips...

I'll remove the beta status after a few weeks if there're no 
issues.

Cheers,
- ali

[0] 
https://forum.dlang.org/thread/borsieulsqyzrfaysiqu@forum.dlang.org
[1] https://issues.dlang.org/show_bug.cgi?id=20084


More information about the Digitalmars-d-announce mailing list