Optional and NotNull version 0.5.0 - swift optional like and scala option like

jmh530 john.michael.hall at gmail.com
Thu Aug 16 18:10:38 UTC 2018


On Thursday, 16 August 2018 at 12:25:14 UTC, aliak wrote:
> Hi
>
> See: https://optional.dub.pm
>
> I've totally revamped the Optional type and am now quite happy 
> with. It has a range interface and safe dispatching and can be 
> used to 1) avoid null dereferencing, 2) have non-null 
> guarantees, and 3) show clear intent where there may or may not 
> be a value. It's also @nogc and @safe and mutation of the 
> original object during safe dispatching works as well.
>

The readme.md page looks great. You might mention that it works 
with @nogc and @safe (I presume Optional and NotNull).

One question: Suppose there was a @weaksafe that has all the same 
features @safe except that it relaxed the requirement of "No 
taking the address of a local variable or function parameter." so 
that you could take the address of a NotNull variable. Are there 
any reasons why this would be unsafe? I imagine NotNull requires 
some type of run-time checking, but other than that I don't see 
why not.


More information about the Digitalmars-d-announce mailing list