Adding the ?. null verification

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 18 23:09:12 PDT 2014


On 6/18/14, 12:26 PM, Etienne wrote:
>> Use a maybe monad :
>> Maybe(obj).memeber.nested.val
>>
>> This doesn't require a language construct. Also, if null check are
>> pervasive in your code, you probably have a problem somewhere.
>
> There seems to be an implementation here:
>
> https://bitbucket.org/qznc/d-monad/src/5b9d41c611093db74485b017a72473447f8d5595/generic.d?at=master
>
>
> It doesn't look as good as what you're suggesting,
>
> auto rht = Applicative!Maybe.right(r1, r2);
>
> auto ii42 = Maybe!(Maybe!int).just(i42);
>
> Any idea how that maybe monad would cascade through into the pointer
> accessors?

opDispatch?


More information about the Digitalmars-d mailing list