June 22, 2014
On Sun, Jun 22, 2014 at 01:15:46AM -0700, Andrei Alexandrescu via Digitalmars-d 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

Yes I got that. I was asking what you thought was a better name for safeDeref.


T

-- 
Fact is stranger than fiction.
June 22, 2014
On 6/22/14, 7:26 AM, H. S. Teoh via Digitalmars-d wrote:
> On Sun, Jun 22, 2014 at 01:15:46AM -0700, Andrei Alexandrescu via Digitalmars-d 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
>
> Yes I got that. I was asking what you thought was a better name for
> safeDeref.

I'd gotten your point too, and I jokingly answered in the subtext that I don't have a better name. -- Andrei

June 23, 2014
On 6/21/14, 4:32 PM, deadalnix wrote:
> On Saturday, 21 June 2014 at 22:40:32 UTC, 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?
>>
>>
>> T
>
> maybe is fine. Last time I checked, it isn't only a monad in haskell,
> but also vastly used by these peoples who speak english.

I like "maybe" too. "nullSafe" might also be a reasonable bikeshed color.
June 24, 2014
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".  Then again, who wants to memorize how that's spelled?  They also have "GetValueOrDefault()" on Nullable<>, but that is kinda long.  How about just "orDefault" or "ifNull"?
June 24, 2014
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.

-- 
/Jacob Carlborg
June 24, 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?"
June 24, 2014
On 6/24/14, 4:43 PM, Jacob Carlborg 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.
>

And in Ruby it's just "||=". How more intuitive can it get?

a = nil
a ||= 1

The "or" that you are discussing here is just an "||" in Ruby:

b = nil || 1


June 24, 2014
On Tuesday, 24 June 2014 at 19:56:14 UTC, H. S. Teoh via Digitalmars-d wrote:
> So D code is going to start looking like this now?!
>
> 	if (myobj.elvis.subobj.memb.isAlive.or(false)) {
> 		...
> 	}

What about ifExists?

if (myObj.ifExists.subobj.member.isAlive.or(false))
{
    //...
}
June 25, 2014
On 2014-06-24 22:52, Ary Borenszweig wrote:

> And in Ruby it's just "||=". How more intuitive can it get?
>
> a = nil
> a ||= 1
>
> The "or" that you are discussing here is just an "||" in Ruby:
>
> b = nil || 1

Yeah, but that behaves a bit different in D.

-- 
/Jacob Carlborg
October 21, 2014
Did you ever get around to making a pull request for this? It'd be nice to have this in Phobos, so I can make one for you (all attribution to you, of course) if you don't have time to push it through.