Adding the ?. null verification

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 19 08:04:00 PDT 2014


On Thu, Jun 19, 2014 at 09:15:47AM -0400, Etienne via Digitalmars-d wrote:
> On 2014-06-19 7:31 AM, Nick Treleaven wrote:
> >Perhaps Maybe could implement opCast!bool, then we could do:
> >
> >if (auto v = ...)
> 
> That would be amazing, but maybe is used in haskell for a different
> purpose, so failsafe could be a more appropriate name I think:
[...]

I've been thinking about the name. I realize that it's not a true monad
in the Haskell sense, even though the implementation *was* inspired by
deadalnix's mentioning of the Maybe monad, so we really should call it
something else.  "failsafe" sounds a bit too generic. What about
"safeDeref" or just "deref"?

OTOH, I wonder how easy it would be to refine the current implementation
to become a true monad?


T

-- 
What is Matter, what is Mind? Never Mind, it doesn't Matter.


More information about the Digitalmars-d mailing list