Adding the ?. null verification

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 18 12:53:41 PDT 2014


On Wednesday, 18 June 2014 at 19:26:21 UTC, 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?

With opDispatch. That is how it is supposed to work.


More information about the Digitalmars-d mailing list