Adding the ?. null verification

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 24 12:54:38 PDT 2014


On Tue, Jun 24, 2014 at 09:43:21PM +0200, Jacob Carlborg via Digitalmars-d wrote:
> On 2014-06-24 18:52, Yota wrote:
> >On Sunday, 22 June 2014 at 08:15:45 UTC, Andrei Alexandrescu wrote:
> >>On 6/21/14, 3:38 PM, H. S. Teoh via Digitalmars-d wrote:
> >>>On Sat, Jun 21, 2014 at 03:26:45PM -0700, Andrei Alexandrescu via
> >>>Digitalmars-d wrote:
> >>>>On 6/19/14, 1:29 PM, Etienne wrote:
> >>>>>writeln(currAssignment.safeDeref.typeInfo.ident.or("meh"));
> >>>>
> >>>>"or" is really nice and terse. I think we should add that to std.
> >>>>safeDeref isn't the best choice of name.
> >>>[...]
> >>>
> >>>What's your suggestion?
> >>
> >>That we add "or" to std and find a name for safeDeref that doesn't use
> >>the word "safe" in a confusing manner. -- Andrei
> >
> >C# calls the ?? operator the "null-coalescing" operator.  I have
> >absolutely no idea why, but that does give precedence for calling it
> >"coalesce".
> 
> In CoffeeScript it's called The Existential Operator. It's also known as The
> Elvis Operator.
[...]

So D code is going to start looking like this now?!

	if (myobj.elvis.subobj.memb.isAlive.or(false)) {
		...
	}


T

-- 
"How are you doing?" "Doing what?"


More information about the Digitalmars-d mailing list