Thread overview
optional 1.0.0 beta with "or/frontOr/Throw" range utilities
Jul 29, 2019
aliak
Jul 29, 2019
Aliak
Jul 30, 2019
Les De Ridder
Jul 30, 2019
aliak
Jul 31, 2019
Andrea Fontana
Jul 30, 2019
Jesse Phillips
Jul 30, 2019
aliak
Jul 31, 2019
Jesse Phillips
July 29, 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
July 29, 2019
On Monday, 29 July 2019 at 22:17:20 UTC, aliak wrote:
> Hi
>
> 

Link: https://code.dlang.org/packages/optional
July 30, 2019
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()'?
July 30, 2019
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 🤷‍♂️.
July 30, 2019
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.
July 30, 2019
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).

July 31, 2019
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()"
July 31, 2019
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.