www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - optional 1.0.0 beta with "or/frontOr/Throw" range utilities

reply aliak <something something.com> writes:
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
Jul 29 2019
next sibling parent Aliak <something something.com> writes:
On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
 Hi

 
Link: https://code.dlang.org/packages/optional
Jul 29 2019
prev sibling next sibling parent reply Les De Ridder <les lesderid.net> writes:
On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
 [...]

 * dispatch() has been renamed to oc(); "optional chain"
Why not 'chain()' or 'optionalChain()'?
Jul 29 2019
parent reply aliak <something something.com> writes:
On Tuesday, 30 July 2019 at 04:18:28 UTC, Les De Ridder wrote:
 On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
 [...]

 * dispatch() has been renamed to oc(); "optional chain"
Why not 'chain()' or 'optionalChain()'?
Only because chain is in range and optionalChain is too long 🤷‍♂️.
Jul 30 2019
parent Andrea Fontana <nospam example.com> writes:
On Tuesday, 30 July 2019 at 10:04:03 UTC, aliak wrote:
 On Tuesday, 30 July 2019 at 04:18:28 UTC, Les De Ridder wrote:
 On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
 [...]

 * dispatch() has been renamed to oc(); "optional chain"
Why not 'chain()' or 'optionalChain()'?
Only because chain is in range and optionalChain is too long 🤷‍♂️.
I would have voted for "optChain()"
Jul 31 2019
prev sibling parent reply Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
 * NotNull has been removed
Why was it removed. It seems like this would be nice to have for class and pointers.
Jul 30 2019
parent reply aliak <something something.com> writes:
On Tuesday, 30 July 2019 at 12:58:08 UTC, Jesse Phillips wrote:
 On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
 * NotNull has been removed
Why was it removed. It seems like this would be nice to have for class and pointers.
I personally didn't find use for it, too much friction to use. I have not gotten the impression that it's useful form others either? If people were using it I'll gladly put it back in as a subpackage or something (or just make another package).
Jul 30 2019
parent Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
On Tuesday, 30 July 2019 at 14:34:19 UTC, aliak wrote:
 On Tuesday, 30 July 2019 at 12:58:08 UTC, Jesse Phillips wrote:
 On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
 * NotNull has been removed
Why was it removed. It seems like this would be nice to have for class and pointers.
I personally didn't find use for it, too much friction to use. I have not gotten the impression that it's useful form others either? If people were using it I'll gladly put it back in as a subpackage or something (or just make another package).
Don't worry at this point. I still need to try out this library with my own code, appears much nicer than nullible.
Jul 31 2019