Topic: Safe Navigation Operator


Author: saiifdean@gmail.com
Date: Wed, 20 Jun 2018 03:01:57 -0700 (PDT)
Raw View
------=_Part_29140_107011085.1529488917572
Content-Type: multipart/alternative;
 boundary="----=_Part_29141_1227684691.1529488917572"

------=_Part_29141_1227684691.1529488917572
Content-Type: text/plain; charset="UTF-8"

Hi,

a Safe Navigation Operator like in C#, Ruby or Kotlin would make the code
so much simpler and easier to read. As example

*Current implementation:*

Foo* foo = GetFoo();
if (!foo)
    return;

Bar* bar = foo->GetBar();
if (!bar)
    return;

Foo* foo1 = bar->GetFoo();
if (!foo1)
    return;

Bar* bar1 = foo1->GetBar();
if (!bar1)
    return;


*Implementation i propose:*
Foo* foo = GetFoo();
Bar* bar = foo?->GetBar();

Foo* foo1 = bar?->GetFoo();
Bar* bar1 = foo1?->GetBar();

if (!foo || !foo1 || !bar || !bar1)
    return;


Best regards
Saif-Dean


--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d50833cb%40isocpp.org.

------=_Part_29141_1227684691.1529488917572
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>a=C2=A0Safe Navigation Operator lik=
e in C#, Ruby or Kotlin would make the code so much simpler and easier to r=
ead. As example</div><div><br></div><div><b><font size=3D"4">Current implem=
entation:</font></b></div><div><br></div><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
 border-style: solid; border-width: 1px; word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Foo</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> foo </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">GetFoo=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(!</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">foo</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">return</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br></span><span style=3D"color: #606;" class=3D"styled-by-pretti=
fy">Bar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> bar </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">GetBar</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
bar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Foo</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> foo1 </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> bar</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">-&gt;</span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">GetFoo</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">i=
f</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(!</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">foo1</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">Bar</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> bar1 </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 foo1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-&gt;=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">GetBar</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(!</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">bar1</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">return</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span></div></code></div><div><br><br></div><div><b><font size=3D"=
4">Implementation i propose:</font></b></div><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187=
); border-style: solid; border-width: 1px; word-wrap: break-word;"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">Foo</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> foo </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">GetF=
oo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Bar</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> bar </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">?-&gt;</span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">GetBar</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br></span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo1 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> bar</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">?-&gt;</span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">GetFoo</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">Bar</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">*</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> bar1 </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
foo1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">?-&gt;=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">GetBar</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(!</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">foo </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">||</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">!</span><span style=3D"color: #000;" class=3D"styled-by-prettify">foo1 =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">||</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">!</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">bar </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">||</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">!</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">bar1</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>return</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</=
span></div></code></div><div><font size=3D"2"><br></font></div><div><font s=
tyle=3D""><br><font size=3D"2">Best regards</font></font></div><div><font s=
tyle=3D""><font size=3D"2">Saif-Dean</font></font></div><div><b><font size=
=3D"4"><br><br></font></b></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d50833cb%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d50833cb=
%40isocpp.org</a>.<br />

------=_Part_29141_1227684691.1529488917572--

------=_Part_29140_107011085.1529488917572--

.


Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Wed, 20 Jun 2018 11:14:43 +0100
Raw View
--0000000000003b5b07056f10195a
Content-Type: text/plain; charset="UTF-8"

So std::optional with syntactic sugar?

On Wed, 20 Jun 2018, 11:02 , <saiifdean@gmail.com> wrote:

> Hi,
>
> a Safe Navigation Operator like in C#, Ruby or Kotlin would make the code
> so much simpler and easier to read. As example
>
> *Current implementation:*
>
> Foo* foo = GetFoo();
> if (!foo)
>     return;
>
> Bar* bar = foo->GetBar();
> if (!bar)
>     return;
>
> Foo* foo1 = bar->GetFoo();
> if (!foo1)
>     return;
>
> Bar* bar1 = foo1->GetBar();
> if (!bar1)
>     return;
>
>
> *Implementation i propose:*
> Foo* foo = GetFoo();
> Bar* bar = foo?->GetBar();
>
> Foo* foo1 = bar?->GetFoo();
> Bar* bar1 = foo1?->GetBar();
>
> if (!foo || !foo1 || !bar || !bar1)
>     return;
>
>
> Best regards
> Saif-Dean
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d50833cb%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d50833cb%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMOjR47BPxf8JD8hMc0bok8cyr%3Db1FDw-tb_uuf%3DLcHbg%40mail.gmail.com.

--0000000000003b5b07056f10195a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">So std::optional with syntactic sugar?</div><br><div clas=
s=3D"gmail_quote"><div dir=3D"ltr">On Wed, 20 Jun 2018, 11:02 , &lt;<a href=
=3D"mailto:saiifdean@gmail.com">saiifdean@gmail.com</a>&gt; wrote:<br></div=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hi,<div><br></div><div>a=
=C2=A0Safe Navigation Operator like in C#, Ruby or Kotlin would make the co=
de so much simpler and easier to read. As example</div><div><br></div><div>=
<b><font size=3D"4">Current implementation:</font></b></div><div><br></div>=
<div class=3D"m_-222052559546795998prettyprint" style=3D"background-color:r=
gb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-wid=
th:1px;word-wrap:break-word"><code class=3D"m_-222052559546795998prettyprin=
t"><div class=3D"m_-222052559546795998subprettyprint"><span style=3D"color:=
#606" class=3D"m_-222052559546795998styled-by-prettify">Foo</span><span sty=
le=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">*</span=
><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettif=
y"> foo </span><span style=3D"color:#660" class=3D"m_-222052559546795998sty=
led-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m_-222052559=
546795998styled-by-prettify"> </span><span style=3D"color:#606" class=3D"m_=
-222052559546795998styled-by-prettify">GetFoo</span><span style=3D"color:#6=
60" class=3D"m_-222052559546795998styled-by-prettify">();</span><span style=
=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify"><br></spa=
n><span style=3D"color:#008" class=3D"m_-222052559546795998styled-by-pretti=
fy">if</span><span style=3D"color:#000" class=3D"m_-222052559546795998style=
d-by-prettify"> </span><span style=3D"color:#660" class=3D"m_-2220525595467=
95998styled-by-prettify">(!</span><span style=3D"color:#000" class=3D"m_-22=
2052559546795998styled-by-prettify">foo</span><span style=3D"color:#660" cl=
ass=3D"m_-222052559546795998styled-by-prettify">)</span><span style=3D"colo=
r:#000" class=3D"m_-222052559546795998styled-by-prettify"><br>=C2=A0 =C2=A0=
 </span><span style=3D"color:#008" class=3D"m_-222052559546795998styled-by-=
prettify">return</span><span style=3D"color:#660" class=3D"m_-2220525595467=
95998styled-by-prettify">;</span><span style=3D"color:#000" class=3D"m_-222=
052559546795998styled-by-prettify"><br><br></span><span style=3D"color:#606=
" class=3D"m_-222052559546795998styled-by-prettify">Bar</span><span style=
=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">*</span><=
span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify"=
> bar </span><span style=3D"color:#660" class=3D"m_-222052559546795998style=
d-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m_-22205255954=
6795998styled-by-prettify"> foo</span><span style=3D"color:#660" class=3D"m=
_-222052559546795998styled-by-prettify">-&gt;</span><span style=3D"color:#6=
06" class=3D"m_-222052559546795998styled-by-prettify">GetBar</span><span st=
yle=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">();</s=
pan><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-pret=
tify"><br></span><span style=3D"color:#008" class=3D"m_-222052559546795998s=
tyled-by-prettify">if</span><span style=3D"color:#000" class=3D"m_-22205255=
9546795998styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m=
_-222052559546795998styled-by-prettify">(!</span><span style=3D"color:#000"=
 class=3D"m_-222052559546795998styled-by-prettify">bar</span><span style=3D=
"color:#660" class=3D"m_-222052559546795998styled-by-prettify">)</span><spa=
n style=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify"><b=
r>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_-2220525595467=
95998styled-by-prettify">return</span><span style=3D"color:#660" class=3D"m=
_-222052559546795998styled-by-prettify">;</span><span style=3D"color:#000" =
class=3D"m_-222052559546795998styled-by-prettify"><br><br></span><span styl=
e=3D"color:#606" class=3D"m_-222052559546795998styled-by-prettify">Foo</spa=
n><span style=3D"color:#660" class=3D"m_-222052559546795998styled-by-pretti=
fy">*</span><span style=3D"color:#000" class=3D"m_-222052559546795998styled=
-by-prettify"> foo1 </span><span style=3D"color:#660" class=3D"m_-222052559=
546795998styled-by-prettify">=3D</span><span style=3D"color:#000" class=3D"=
m_-222052559546795998styled-by-prettify"> bar</span><span style=3D"color:#6=
60" class=3D"m_-222052559546795998styled-by-prettify">-&gt;</span><span sty=
le=3D"color:#606" class=3D"m_-222052559546795998styled-by-prettify">GetFoo<=
/span><span style=3D"color:#660" class=3D"m_-222052559546795998styled-by-pr=
ettify">();</span><span style=3D"color:#000" class=3D"m_-222052559546795998=
styled-by-prettify"><br></span><span style=3D"color:#008" class=3D"m_-22205=
2559546795998styled-by-prettify">if</span><span style=3D"color:#000" class=
=3D"m_-222052559546795998styled-by-prettify"> </span><span style=3D"color:#=
660" class=3D"m_-222052559546795998styled-by-prettify">(!</span><span style=
=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify">foo1</spa=
n><span style=3D"color:#660" class=3D"m_-222052559546795998styled-by-pretti=
fy">)</span><span style=3D"color:#000" class=3D"m_-222052559546795998styled=
-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"=
m_-222052559546795998styled-by-prettify">return</span><span style=3D"color:=
#660" class=3D"m_-222052559546795998styled-by-prettify">;</span><span style=
=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify"><br><br><=
/span><span style=3D"color:#606" class=3D"m_-222052559546795998styled-by-pr=
ettify">Bar</span><span style=3D"color:#660" class=3D"m_-222052559546795998=
styled-by-prettify">*</span><span style=3D"color:#000" class=3D"m_-22205255=
9546795998styled-by-prettify"> bar1 </span><span style=3D"color:#660" class=
=3D"m_-222052559546795998styled-by-prettify">=3D</span><span style=3D"color=
:#000" class=3D"m_-222052559546795998styled-by-prettify"> foo1</span><span =
style=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">-&gt=
;</span><span style=3D"color:#606" class=3D"m_-222052559546795998styled-by-=
prettify">GetBar</span><span style=3D"color:#660" class=3D"m_-2220525595467=
95998styled-by-prettify">();</span><span style=3D"color:#000" class=3D"m_-2=
22052559546795998styled-by-prettify"><br></span><span style=3D"color:#008" =
class=3D"m_-222052559546795998styled-by-prettify">if</span><span style=3D"c=
olor:#000" class=3D"m_-222052559546795998styled-by-prettify"> </span><span =
style=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">(!</=
span><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-pre=
ttify">bar1</span><span style=3D"color:#660" class=3D"m_-222052559546795998=
styled-by-prettify">)</span><span style=3D"color:#000" class=3D"m_-22205255=
9546795998styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color=
:#008" class=3D"m_-222052559546795998styled-by-prettify">return</span><span=
 style=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">;</=
span><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-pre=
ttify"><br></span></div></code></div><div><br><br></div><div><b><font size=
=3D"4">Implementation i propose:</font></b></div><div class=3D"m_-222052559=
546795998prettyprint" style=3D"background-color:rgb(250,250,250);border-col=
or:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-wor=
d"><code class=3D"m_-222052559546795998prettyprint"><div class=3D"m_-222052=
559546795998subprettyprint"><span style=3D"color:#606" class=3D"m_-22205255=
9546795998styled-by-prettify">Foo</span><span style=3D"color:#660" class=3D=
"m_-222052559546795998styled-by-prettify">*</span><span style=3D"color:#000=
" class=3D"m_-222052559546795998styled-by-prettify"> foo </span><span style=
=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">=3D</span=
><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettif=
y"> </span><span style=3D"color:#606" class=3D"m_-222052559546795998styled-=
by-prettify">GetFoo</span><span style=3D"color:#660" class=3D"m_-2220525595=
46795998styled-by-prettify">();</span><span style=3D"color:#000" class=3D"m=
_-222052559546795998styled-by-prettify"><br></span><span style=3D"color:#60=
6" class=3D"m_-222052559546795998styled-by-prettify">Bar</span><span style=
=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">*</span><=
span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify"=
> bar </span><span style=3D"color:#660" class=3D"m_-222052559546795998style=
d-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m_-22205255954=
6795998styled-by-prettify"> foo</span><span style=3D"color:#660" class=3D"m=
_-222052559546795998styled-by-prettify">?-&gt;</span><span style=3D"color:#=
606" class=3D"m_-222052559546795998styled-by-prettify">GetBar</span><span s=
tyle=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">();</=
span><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-pre=
ttify"><br><br></span><span style=3D"color:#606" class=3D"m_-22205255954679=
5998styled-by-prettify">Foo</span><span style=3D"color:#660" class=3D"m_-22=
2052559546795998styled-by-prettify">*</span><span style=3D"color:#000" clas=
s=3D"m_-222052559546795998styled-by-prettify"> foo1 </span><span style=3D"c=
olor:#660" class=3D"m_-222052559546795998styled-by-prettify">=3D</span><spa=
n style=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify"> b=
ar</span><span style=3D"color:#660" class=3D"m_-222052559546795998styled-by=
-prettify">?-&gt;</span><span style=3D"color:#606" class=3D"m_-222052559546=
795998styled-by-prettify">GetFoo</span><span style=3D"color:#660" class=3D"=
m_-222052559546795998styled-by-prettify">();</span><span style=3D"color:#00=
0" class=3D"m_-222052559546795998styled-by-prettify"><br></span><span style=
=3D"color:#606" class=3D"m_-222052559546795998styled-by-prettify">Bar</span=
><span style=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettif=
y">*</span><span style=3D"color:#000" class=3D"m_-222052559546795998styled-=
by-prettify"> bar1 </span><span style=3D"color:#660" class=3D"m_-2220525595=
46795998styled-by-prettify">=3D</span><span style=3D"color:#000" class=3D"m=
_-222052559546795998styled-by-prettify"> foo1</span><span style=3D"color:#6=
60" class=3D"m_-222052559546795998styled-by-prettify">?-&gt;</span><span st=
yle=3D"color:#606" class=3D"m_-222052559546795998styled-by-prettify">GetBar=
</span><span style=3D"color:#660" class=3D"m_-222052559546795998styled-by-p=
rettify">();</span><span style=3D"color:#000" class=3D"m_-22205255954679599=
8styled-by-prettify"><br><br></span><span style=3D"color:#008" class=3D"m_-=
222052559546795998styled-by-prettify">if</span><span style=3D"color:#000" c=
lass=3D"m_-222052559546795998styled-by-prettify"> </span><span style=3D"col=
or:#660" class=3D"m_-222052559546795998styled-by-prettify">(!</span><span s=
tyle=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify">foo <=
/span><span style=3D"color:#660" class=3D"m_-222052559546795998styled-by-pr=
ettify">||</span><span style=3D"color:#000" class=3D"m_-222052559546795998s=
tyled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_-222052559=
546795998styled-by-prettify">!</span><span style=3D"color:#000" class=3D"m_=
-222052559546795998styled-by-prettify">foo1 </span><span style=3D"color:#66=
0" class=3D"m_-222052559546795998styled-by-prettify">||</span><span style=
=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettify"> </span><=
span style=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify"=
>!</span><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by=
-prettify">bar </span><span style=3D"color:#660" class=3D"m_-22205255954679=
5998styled-by-prettify">||</span><span style=3D"color:#000" class=3D"m_-222=
052559546795998styled-by-prettify"> </span><span style=3D"color:#660" class=
=3D"m_-222052559546795998styled-by-prettify">!</span><span style=3D"color:#=
000" class=3D"m_-222052559546795998styled-by-prettify">bar1</span><span sty=
le=3D"color:#660" class=3D"m_-222052559546795998styled-by-prettify">)</span=
><span style=3D"color:#000" class=3D"m_-222052559546795998styled-by-prettif=
y"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_-22205255=
9546795998styled-by-prettify">return</span><span style=3D"color:#660" class=
=3D"m_-222052559546795998styled-by-prettify">;</span></div></code></div><di=
v><font size=3D"2"><br></font></div><div><font><br><font size=3D"2">Best re=
gards</font></font></div><div><font><font size=3D"2">Saif-Dean</font></font=
></div><div><b><font size=3D"4"><br><br></font></b></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank" rel=3D"noreferrer">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank" rel=3D"noreferrer">std-proposals@isocpp.org</a>.<br=
>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d50833cb%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"noreferrer">https://groups.google.com/a/isocpp.org/d/msgid/std-propo=
sals/e57c6f00-96d1-4453-b31e-7e97d50833cb%40isocpp.org</a>.<br>
</blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMOjR47BPxf8JD8hMc0bok8cyr%3D=
b1FDw-tb_uuf%3DLcHbg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMO=
jR47BPxf8JD8hMc0bok8cyr%3Db1FDw-tb_uuf%3DLcHbg%40mail.gmail.com</a>.<br />

--0000000000003b5b07056f10195a--

.


Author: mihailnajdenov@gmail.com
Date: Wed, 20 Jun 2018 03:24:37 -0700 (PDT)
Raw View
------=_Part_29273_1175587886.1529490277691
Content-Type: multipart/alternative;
 boundary="----=_Part_29274_821567774.1529490277692"

------=_Part_29274_821567774.1529490277692
Content-Type: text/plain; charset="UTF-8"

One major problem with this is - it will stimulate repeated checking.
Instead of one check on the first access only, the user will feel
comfortable (or be forced) to have checks on every access.

In your first example you can freely use foo after the second line at zero
cost.


On Wednesday, June 20, 2018 at 1:01:57 PM UTC+3, saii...@gmail.com wrote:
>
> Hi,
>
> a Safe Navigation Operator like in C#, Ruby or Kotlin would make the code
> so much simpler and easier to read. As example
>
> *Current implementation:*
>
> Foo* foo = GetFoo();
> if (!foo)
>     return;
>
> Bar* bar = foo->GetBar();
> if (!bar)
>     return;
>
> Foo* foo1 = bar->GetFoo();
> if (!foo1)
>     return;
>
> Bar* bar1 = foo1->GetBar();
> if (!bar1)
>     return;
>
>
> *Implementation i propose:*
> Foo* foo = GetFoo();
> Bar* bar = foo?->GetBar();
>
> Foo* foo1 = bar?->GetFoo();
> Bar* bar1 = foo1?->GetBar();
>
> if (!foo || !foo1 || !bar || !bar1)
>     return;
>
>
> Best regards
> Saif-Dean
>
>
>

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6aacdc66-e030-4f6a-ab8d-693479d398c7%40isocpp.org.

------=_Part_29274_821567774.1529490277692
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div style=3D"background-color: transparent; border-bottom=
-color: rgb(34, 34, 34); border-bottom-style: none; border-bottom-width: 0p=
x; border-image-outset: 0; border-image-repeat: stretch; border-image-slice=
: 100%; border-image-source: none; border-image-width: 1; border-left-color=
: rgb(34, 34, 34); border-left-style: none; border-left-width: 0px; border-=
right-color: rgb(34, 34, 34); border-right-style: none; border-right-width:=
 0px; border-top-color: rgb(34, 34, 34); border-top-style: none; border-top=
-width: 0px; color: rgb(34, 34, 34); font-family: &amp;quot;Arial&amp;quot;=
,&amp;quot;Helvetica&amp;quot;,sans-serif; font-size: 13px; font-style: nor=
mal; font-variant: normal; font-weight: 400; letter-spacing: normal; margin=
-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; orphans=
: 2; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-to=
p: 0px; text-align: left; text-decoration: none; text-indent: 0px; text-tra=
nsform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spa=
cing: 0px;">One major problem with this is - it will stimulate repeated che=
cking. Instead of one check on the first access only, the user will feel co=
mfortable (or be forced) to have checks on every access.=C2=A0</div><div st=
yle=3D"background-color: transparent; border-bottom-color: rgb(34, 34, 34);=
 border-bottom-style: none; border-bottom-width: 0px; border-image-outset: =
0; border-image-repeat: stretch; border-image-slice: 100%; border-image-sou=
rce: none; border-image-width: 1; border-left-color: rgb(34, 34, 34); borde=
r-left-style: none; border-left-width: 0px; border-right-color: rgb(34, 34,=
 34); border-right-style: none; border-right-width: 0px; border-top-color: =
rgb(34, 34, 34); border-top-style: none; border-top-width: 0px; color: rgb(=
34, 34, 34); font-family: &amp;quot;Arial&amp;quot;,&amp;quot;Helvetica&amp=
;quot;,sans-serif; font-size: 13px; font-style: normal; font-variant: norma=
l; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margin-lef=
t: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom: 0px=
; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left=
; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-te=
xt-stroke-width: 0px; white-space: normal; word-spacing: 0px;"><br></div><d=
iv style=3D"background-color: transparent; border-bottom-color: rgb(34, 34,=
 34); border-bottom-style: none; border-bottom-width: 0px; border-image-out=
set: 0; border-image-repeat: stretch; border-image-slice: 100%; border-imag=
e-source: none; border-image-width: 1; border-left-color: rgb(34, 34, 34); =
border-left-style: none; border-left-width: 0px; border-right-color: rgb(34=
, 34, 34); border-right-style: none; border-right-width: 0px; border-top-co=
lor: rgb(34, 34, 34); border-top-style: none; border-top-width: 0px; color:=
 rgb(34, 34, 34); font-family: &amp;quot;Arial&amp;quot;,&amp;quot;Helvetic=
a&amp;quot;,sans-serif; font-size: 13px; font-style: normal; font-variant: =
normal; font-weight: 400; letter-spacing: normal; margin-bottom: 0px; margi=
n-left: 0px; margin-right: 0px; margin-top: 0px; orphans: 2; padding-bottom=
: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align:=
 left; text-decoration: none; text-indent: 0px; text-transform: none; -webk=
it-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">In your=
 first example you can freely use foo after the second line at zero cost.=
=C2=A0</div><br><br>On Wednesday, June 20, 2018 at 1:01:57 PM UTC+3, saii..=
..@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">Hi,<div><br></div><div>a=C2=A0Safe Navigation Operator like in C#, Rub=
y or Kotlin would make the code so much simpler and easier to read. As exam=
ple</div><div><br></div><div><b><font size=3D"4">Current implementation:</f=
ont></b></div><div><br></div><div style=3D"background-color:rgb(250,250,250=
);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wr=
ap:break-word"><code><div><span style=3D"color:#606">Foo</span><span style=
=3D"color:#660">*</span><span style=3D"color:#000"> foo </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">GetFoo</span><span style=3D"color:#660">();</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#008">if</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">(!</span><span style=3D"=
color:#000">foo</span><span style=3D"color:#660">)</span><span style=3D"col=
or:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"><br><br></span=
><span style=3D"color:#606">Bar</span><span style=3D"color:#660">*</span><s=
pan style=3D"color:#000"> bar </span><span style=3D"color:#660">=3D</span><=
span style=3D"color:#000"> foo</span><span style=3D"color:#660">-&gt;</span=
><span style=3D"color:#606">GetBar</span><span style=3D"color:#660">();</sp=
an><span style=3D"color:#000"><br></span><span style=3D"color:#008">if</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">(!</span><s=
pan style=3D"color:#000">bar</span><span style=3D"color:#660">)</span><span=
 style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">r=
eturn</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><=
br><br></span><span style=3D"color:#606">Foo</span><span style=3D"color:#66=
0">*</span><span style=3D"color:#000"> foo1 </span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#000"> bar</span><span style=3D"color:#66=
0">-&gt;</span><span style=3D"color:#606">GetFoo</span><span style=3D"color=
:#660">();</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#008">if</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">(!</span><span style=3D"color:#000">foo1</span><span style=3D"color:#660=
">)</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color:#008">return</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br><br></span><span style=3D"color:#606">Bar</span><span s=
tyle=3D"color:#660">*</span><span style=3D"color:#000"> bar1 </span><span s=
tyle=3D"color:#660">=3D</span><span style=3D"color:#000"> foo1</span><span =
style=3D"color:#660">-&gt;</span><span style=3D"color:#606">GetBar</span><s=
pan style=3D"color:#660">();</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#008">if</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">(!</span><span style=3D"color:#000">bar1</span><span s=
tyle=3D"color:#660">)</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </=
span><span style=3D"color:#008">return</span><span style=3D"color:#660">;</=
span><span style=3D"color:#000"><br></span></div></code></div><div><br><br>=
</div><div><b><font size=3D"4">Implementation i propose:</font></b></div><d=
iv style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187)=
;border-style:solid;border-width:1px;word-wrap:break-word"><code><div><span=
 style=3D"color:#606">Foo</span><span style=3D"color:#660">*</span><span st=
yle=3D"color:#000"> foo </span><span style=3D"color:#660">=3D</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#606">GetFoo</span><span s=
tyle=3D"color:#660">();</span><span style=3D"color:#000"><br></span><span s=
tyle=3D"color:#606">Bar</span><span style=3D"color:#660">*</span><span styl=
e=3D"color:#000"> bar </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> foo</span><span style=3D"color:#660">?-&gt;</span><span =
style=3D"color:#606">GetBar</span><span style=3D"color:#660">();</span><spa=
n style=3D"color:#000"><br><br></span><span style=3D"color:#606">Foo</span>=
<span style=3D"color:#660">*</span><span style=3D"color:#000"> foo1 </span>=
<span style=3D"color:#660">=3D</span><span style=3D"color:#000"> bar</span>=
<span style=3D"color:#660">?-&gt;</span><span style=3D"color:#606">GetFoo</=
span><span style=3D"color:#660">();</span><span style=3D"color:#000"><br></=
span><span style=3D"color:#606">Bar</span><span style=3D"color:#660">*</spa=
n><span style=3D"color:#000"> bar1 </span><span style=3D"color:#660">=3D</s=
pan><span style=3D"color:#000"> foo1</span><span style=3D"color:#660">?-&gt=
;</span><span style=3D"color:#606">GetBar</span><span style=3D"color:#660">=
();</span><span style=3D"color:#000"><br><br></span><span style=3D"color:#0=
08">if</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
(!</span><span style=3D"color:#000">foo </span><span style=3D"color:#660">|=
|</span><span style=3D"color:#000"> </span><span style=3D"color:#660">!</sp=
an><span style=3D"color:#000">foo1 </span><span style=3D"color:#660">||</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">!</span><s=
pan style=3D"color:#000">bar </span><span style=3D"color:#660">||</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660">!</span><span st=
yle=3D"color:#000">bar1</span><span style=3D"color:#660">)</span><span styl=
e=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008">return=
</span><span style=3D"color:#660">;</span></div></code></div><div><font siz=
e=3D"2"><br></font></div><div><font><br><font size=3D"2">Best regards</font=
></font></div><div><font><font size=3D"2">Saif-Dean</font></font></div><div=
><b><font size=3D"4"><br><br></font></b></div></div></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6aacdc66-e030-4f6a-ab8d-693479d398c7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6aacdc66-e030-4f6a-ab8d-693479d398c7=
%40isocpp.org</a>.<br />

------=_Part_29274_821567774.1529490277692--

------=_Part_29273_1175587886.1529490277691--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Wed, 20 Jun 2018 12:09:24 +0100
Raw View
--=-yoHwrd22D8DuxorMfYKN
Content-Type: multipart/alternative; boundary="=-A7sX7YR5OAQ3epP9w2gj"


--=-A7sX7YR5OAQ3epP9w2gj
Content-Type: text/plain; charset="UTF-8"

On Wed, 2018-06-20 at 03:01 -0700, saiifdean@gmail.com wrote:
> Hi,
> a Safe Navigation Operator like in C#, Ruby or Kotlin would make the
> code so much simpler and easier to read. As example

I think the first thing to say is that allowing null refrences in
higher level languages such as C#, Java and Swift was an obvious design
error, which developers are now paying for in shovels with ghastly
syntax additions.
If we must allow null references in a program at all, c++ provides many
ways to conditionally handle them - wrappers, free functions, optional,
etc.
Here's one way that springs to mind, using free functions:
struct Bar;struct Foo {    Bar* GetBar();};struct Bar {    Foo*
GetFoo();};
Foo* GetFoo();
template<class...Ptrs>void somethingElse(Ptrs...ptrs);
template<class...Ptrs>bool allTrue(Ptrs...ptrs){    return (ptrs &&
....);}
Bar* getBar(Foo* fp){    return fp ? fp->GetBar() : nullptr;}
Foo* getFoo(Bar* bp){    return bp ? bp->GetFoo() : nullptr;}
void test(){    Foo* foo = GetFoo();    auto bar = getBar(foo);    auto
foo1 = getFoo(bar);    auto bar1 = getBar(foo1);
    if (allTrue(foo, bar, foo1, bar1))        somethingElse(foo, bar,
foo1, bar1);}
I think this provides the succinctness you're after, and GCC makes a
very good job of optimising it.
You can see an example of the assembler output of this here:
https://godbolt.org/g/snpd8b

> Current implementation:
>
> Foo* foo = GetFoo();
> if (!foo)
>     return;
>
> Bar* bar = foo->GetBar();
> if (!bar)
>     return;
>
> Foo* foo1 = bar->GetFoo();
> if (!foo1)
>     return;
>
> Bar* bar1 = foo1->GetBar();
> if (!bar1)
>     return;
>
>
>
> Implementation i propose:
> Foo* foo = GetFoo();
> Bar* bar = foo?->GetBar();
>
> Foo* foo1 = bar?->GetFoo();
> Bar* bar1 = foo1?->GetBar();
>
> if (!foo || !foo1 || !bar || !bar1)
>     return;
>
>
>
> Best regards
> Saif-Dean
>
>
>
>
>
>
> --
>
> You received this message because you are subscribed to the Google
> Groups "ISO C++ Standard - Future Proposals" group.
>
> To unsubscribe from this group and stop receiving emails from it,
> send an email to std-proposals+unsubscribe@isocpp.org.
>
> To post to this group, send email to std-proposals@isocpp.org.
>
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-
> 7e97d50833cb%40isocpp.org.
>

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1529492964.2340.43.camel%40gmail.com.

--=-A7sX7YR5OAQ3epP9w2gj
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div>On Wed, 2018-06-20 at 03:01 -0700, saiifdean@=
gmail.com wrote:</div><blockquote type=3D"cite" style=3D"margin:0 0 0 .8ex;=
 border-left:2px #729fcf solid;padding-left:1ex"><div dir=3D"ltr">Hi,<div><=
br></div><div>a&nbsp;Safe Navigation Operator like in C#, Ruby or Kotlin wo=
uld make the code so much simpler and easier to read. As example</div></div=
></blockquote><div><br></div><div><br></div><div>I think the first thing to=
 say is that allowing null refrences in higher level languages such as C#, =
Java and Swift was an obvious design error, which developers are now paying=
 for in shovels with ghastly syntax additions.</div><div><br></div><div>If =
we must allow null references in a program at all, c++ provides many ways t=
o conditionally handle them - wrappers, free functions, optional, etc.</div=
><div><br></div><div>Here's one way that springs to mind, using free functi=
ons:</div><div><br></div><div><font face=3D"monospace" size=3D"3">struct Ba=
r;</font></div><div><font face=3D"monospace" size=3D"3">struct Foo {</font>=
</div><div><font face=3D"monospace" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;Bar*=
 GetBar();</font></div><div><font face=3D"monospace" size=3D"3">};</font></=
div><div><font face=3D"monospace" size=3D"3">struct Bar {</font></div><div>=
<font face=3D"monospace" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;Foo* GetFoo();<=
/font></div><div><font face=3D"monospace" size=3D"3">};</font></div><div><f=
ont face=3D"monospace" size=3D"3"><br></font></div><div><font face=3D"monos=
pace" size=3D"3">Foo* GetFoo();</font></div><div><font face=3D"monospace" s=
ize=3D"3"><br></font></div><div><font face=3D"monospace" size=3D"3">templat=
e&lt;class...Ptrs&gt;</font></div><div><font face=3D"monospace" size=3D"3">=
void somethingElse(Ptrs...ptrs);</font></div><div><font face=3D"monospace" =
size=3D"3"><br></font></div><div><font face=3D"monospace" size=3D"3">templa=
te&lt;class...Ptrs&gt;</font></div><div><font face=3D"monospace" size=3D"3"=
>bool allTrue(Ptrs...ptrs)</font></div><div><font face=3D"monospace" size=
=3D"3">{</font></div><div><font face=3D"monospace" size=3D"3">&nbsp;&nbsp;&=
nbsp;&nbsp;return (ptrs &amp;&amp; ...);</font></div><div><font face=3D"mon=
ospace" size=3D"3">}</font></div><div><font face=3D"monospace" size=3D"3"><=
br></font></div><div><font face=3D"monospace" size=3D"3">Bar* getBar(Foo* f=
p)</font></div><div><font face=3D"monospace" size=3D"3">{</font></div><div>=
<font face=3D"monospace" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;return fp ? fp-=
&gt;GetBar() : nullptr;</font></div><div><font face=3D"monospace" size=3D"3=
">}</font></div><div><font face=3D"monospace" size=3D"3"><br></font></div><=
div><font face=3D"monospace" size=3D"3">Foo* getFoo(Bar* bp)</font></div><d=
iv><font face=3D"monospace" size=3D"3">{</font></div><div><font face=3D"mon=
ospace" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;return bp ? bp-&gt;GetFoo() : nu=
llptr;</font></div><div><font face=3D"monospace" size=3D"3">}</font></div><=
div><font face=3D"monospace" size=3D"3"><br></font></div><div><font face=3D=
"monospace" size=3D"3">void test()</font></div><div><font face=3D"monospace=
" size=3D"3">{</font></div><div><font face=3D"monospace" size=3D"3">&nbsp;&=
nbsp;&nbsp;&nbsp;Foo* foo =3D GetFoo();</font></div><div><font face=3D"mono=
space" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;auto bar =3D getBar(foo);</font><=
/div><div><font face=3D"monospace" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;auto =
foo1 =3D getFoo(bar);</font></div><div><font face=3D"monospace" size=3D"3">=
&nbsp;&nbsp;&nbsp;&nbsp;auto bar1 =3D getBar(foo1);</font></div><div><font =
face=3D"monospace" size=3D"3"><br></font></div><div><font face=3D"monospace=
" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;if (allTrue(foo, bar, foo1, bar1))</fo=
nt></div><div><font face=3D"monospace" size=3D"3">&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;somethingElse(foo, bar, foo1, bar1);</font></div><di=
v><font face=3D"monospace" size=3D"3">}</font></div><div><font face=3D"mono=
space" size=3D"3"><br></font></div><div><font face=3D"monospace" size=3D"3"=
>I think this provides the succinctness you're after, and GCC makes a very =
good job of optimising it.</font></div><div><font face=3D"monospace" size=
=3D"3"><br></font></div><div><font face=3D"monospace" size=3D"3">You can se=
e an example of the assembler output of this here:</font></div><div><font f=
ace=3D"monospace" size=3D"3"><br></font></div><div><a href=3D"https://godbo=
lt.org/g/snpd8b">https://godbolt.org/g/snpd8b</a></div><div><br></div><div>=
<font face=3D"monospace" size=3D"3"></font></div><div><font face=3D"monospa=
ce" size=3D"3"></font><br></div><blockquote type=3D"cite" style=3D"margin:0=
 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir=3D"ltr"=
><div><br></div><div><b><font size=3D"4">Current implementation:</font></b>=
</div><div><br></div><div class=3D"prettyprint" style=3D"background-color: =
rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; =
border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div=
 class=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">GetFoo</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp=
; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">r=
eturn</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span=
><span style=3D"color: #606;" class=3D"styled-by-prettify">Bar</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> bar </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">-&gt;</span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">GetBar</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">if</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(!</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">bar</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Foo</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> foo1 </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> bar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-=
&gt;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">GetFoo=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(!</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">foo1</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">return</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br><br></span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Bar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> bar1 </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> foo1</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">-&gt;</span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">GetBar</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>bar1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></=
code></div><div><br><br></div><div><b><font size=3D"4">Implementation i pro=
pose:</font></b></div><div class=3D"prettyprint" style=3D"background-color:=
 rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid;=
 border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Foo</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">*</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">GetFoo</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">Bar</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">*</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> bar </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">?-&=
gt;</span><span style=3D"color: #606;" class=3D"styled-by-prettify">GetBar<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><sp=
an style=3D"color: #606;" class=3D"styled-by-prettify">Foo</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> foo1 </span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> bar</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">?-&gt;</span><span style=3D"color: #606;" class=3D"=
styled-by-prettify">GetFoo</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Bar</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> bar1 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> foo1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">?-&gt;</span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">GetBar</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(!</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">foo </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>||</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">!</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">foo1 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">||</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">!</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">bar </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">||</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">!<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">bar1</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">;</span></div></code><=
/div><div><font size=3D"2"><br></font></div><div><font style=3D""><br><font=
 size=3D"2">Best regards</font></font></div><div><font style=3D""><font siz=
e=3D"2">Saif-Dean</font></font></div><div><b><font size=3D"4"><br><br></fon=
t></b></div></div>



-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d50833cb%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/e57c6f00-96d1-4453-b31e-7e97d508=
33cb%40isocpp.org</a>.<br>
</blockquote></body></html>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1529492964.2340.43.camel%40gmail.com?=
utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/a/isocpp.=
org/d/msgid/std-proposals/1529492964.2340.43.camel%40gmail.com</a>.<br />

--=-A7sX7YR5OAQ3epP9w2gj--

--=-yoHwrd22D8DuxorMfYKN
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEE3RJb20ryY2ALx0Tw6HZ1IvK3CgsFAlsqNeQACgkQ6HZ1IvK3
CgsN5Q/9GQcI1SKPaRTkBK/KaFrP1OcWBgaQegky+DSBbzu/84YlRX1QCLEyL4yZ
3hZnO6rwO0BEwfemilVzOfqCGjcOqW01UaX+/VZsbdlkc8K4N/PspqIWYGenO9gi
/0K5thq5roEmDiufVezNtp6F0Zx9PnmUuEgwfcqCo85wwCPA/wzHstkxGDsHckg6
trWMboPrdz5puMdNReYifi9FOSnQuw6Z8lpBG3HMao+pb8kxas2JbwrJ4GHW9lIM
plIlJvAtzZleh5NZgblK2NggCFJP4KD/Q/lgZTEcMYlNphd182Jzttkl816uGOMB
G0FwqXa02ennp1QehVlGL8ElWZfx0HZA1qWR3s/I3qM0Tf6McrNF/j5n44L/JdpN
G2R5lPibd78PJzAFhVzQkB49/BkvN0C8m7JYEoapvxZn0hfO/O0696sb5r0GMtuX
NBRSy26PZ9yCdCJP0ZeHqIm8iHD2uPH8EtMzETmaY/IdBzKIlsORZQqf4rNz64HK
sOMvHG7llrLto0yjMnOfP0c66rGrMGB6oB5w4NGnbeAe9PWU8VcmWPtEnQdS0Q1U
TOZeXkdC4IrBxaz2fZXd2soysv6B8oKlb+hbz5qnRYms1W8PWNfCGSNE4mC7nCOv
C5K2OC+/tYy9oi+EPytLFM7rExk6uHdaY/FAyevogAEh34Qn7Hk=
=czjJ
-----END PGP SIGNATURE-----

--=-yoHwrd22D8DuxorMfYKN--


.


Author: Bo Persson <bop@gmb.dk>
Date: Wed, 20 Jun 2018 14:47:05 +0200
Raw View
On 2018-06-20 12:01, saiifdean@gmail.com wrote:
> Hi,
>=20
> a=C2=A0Safe Navigation Operator like in C#, Ruby or Kotlin would make the=
=20
> code so much simpler and easier to read. As example
>=20
> *Current implementation:*
>=20
> |
> Foo*foo =3DGetFoo();
> if(!foo)
> return;
>=20
> Bar*bar =3Dfoo->GetBar();
> if(!bar)
> return;
>=20
> Foo*foo1 =3Dbar->GetFoo();
> if(!foo1)
> return;
>=20
> Bar*bar1 =3Dfoo1->GetBar();
> if(!bar1)
> return;
> |
>=20
>=20
> *Implementation i propose:*
> |
> Foo*foo =3DGetFoo();
> Bar*bar =3Dfoo?->GetBar();
>=20
> Foo*foo1 =3Dbar?->GetFoo();
> Bar*bar1 =3Dfoo1?->GetBar();
>=20
> if(!foo ||!foo1 ||!bar ||!bar1)
> return;
> |
>=20
>=20

An existing option, without changing the language:

if (Foo* foo =3D GetFoo())
   if (Bar* bar =3D foo->GetBar())
     if (Foo* foo1 =3D bar->GetFoo())
       if (Bar* bar1 =3D foo1->GetBar())
          do_something(foo, bar, foo1, bar1);

return;




     Bo Persson



--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/pgdi86%24162%241%40blaine.gmane.org.

.


Author: Barry Revzin <barry.revzin@gmail.com>
Date: Wed, 20 Jun 2018 07:20:38 -0700 (PDT)
Raw View
------=_Part_30441_122018197.1529504438249
Content-Type: multipart/alternative;
 boundary="----=_Part_30442_48535720.1529504438250"

------=_Part_30442_48535720.1529504438250
Content-Type: text/plain; charset="UTF-8"



On Wednesday, June 20, 2018 at 5:01:57 AM UTC-5, saii...@gmail.com wrote:
>
> *Implementation i propose:*
> Foo* foo = GetFoo();
> Bar* bar = foo?->GetBar();
>
>
What happens if the member function I want to call doesn't return a
pointer. Say:

struct X {
    int get_int() const;
};

X* getX();
auto i = getX()?->get_int(); // ???

Should this work? If yes, what would the type of i be? It can't really be
int*, but if it's optional<int>, how do we square the two different returns?

Swift has an option chaining feature which is highly reminiscent of
this: https://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b77d5328-4074-4fd3-9cb1-4d2025fa80f0%40isocpp.org.

------=_Part_30442_48535720.1529504438250
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, June 20, 2018 at 5:01:57 AM UTC-5, s=
aii...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr"><div><b><font size=3D"4">Implementation i propose:</font></b><br>=
</div><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,=
187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><s=
pan style=3D"color:#606">Foo</span><span style=3D"color:#660">*</span><span=
 style=3D"color:#000"> foo </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#606">GetFoo</span><spa=
n style=3D"color:#660">();</span><span style=3D"color:#000"><br></span><spa=
n style=3D"color:#606">Bar</span><span style=3D"color:#660">*</span><span s=
tyle=3D"color:#000"> bar </span><span style=3D"color:#660">=3D</span><span =
style=3D"color:#000"> foo</span><span style=3D"color:#660">?-&gt;</span><sp=
an style=3D"color:#606">GetBar</span><span style=3D"color:#660">();</span><=
span style=3D"color:#000"><br></span></code></div><div><br></div></div></bl=
ockquote><div><br></div><div>What happens if the member function I want to =
call doesn&#39;t return a pointer. Say:</div><div><br></div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> X </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> get_int</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">const</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>X</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> getX</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> i </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> getX</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">()?-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">get_int</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">// ???</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div=
></code></div><div><br></div>Should this work? If yes, what would the type =
of i be? It can&#39;t really be int*, but if it&#39;s optional&lt;int&gt;, =
how do we square the two different returns?</div><div><br></div><div>Swift =
has an option chaining feature which is highly reminiscent of this:=C2=A0ht=
tps://docs.swift.org/swift-book/LanguageGuide/OptionalChaining.html</div><d=
iv><br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b77d5328-4074-4fd3-9cb1-4d2025fa80f0%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b77d5328-4074-4fd3-9cb1-4d2025fa80f0=
%40isocpp.org</a>.<br />

------=_Part_30442_48535720.1529504438250--

------=_Part_30441_122018197.1529504438249--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 20 Jun 2018 07:36:43 -0700 (PDT)
Raw View
------=_Part_30658_1404441100.1529505403895
Content-Type: multipart/alternative;
 boundary="----=_Part_30659_478485804.1529505403896"

------=_Part_30659_478485804.1529505403896
Content-Type: text/plain; charset="UTF-8"

On Wednesday, June 20, 2018 at 6:01:57 AM UTC-4, saii...@gmail.com wrote:
>
> Hi,
>
> a Safe Navigation Operator like in C#, Ruby or Kotlin would make the code
> so much simpler and easier to read.
>

This is only true because those languages do not have non-nullable
references. Or if they have them, they aren't the common case.

I haven't written a lot of code that does so many chained accesses of
nullable references like verifying them becomes a syntactic burden of a
kind worthy of added syntax. We have the option to have functions return a
non-nullable reference, so in many cases, we don't return pointers.

Having this many NULL checks suggests that maybe the system in question is
just poorly designed.

Also, what happens if the function needs to return something? What you're
talking about can only be used in functions with no return values. That
seems decidedly limiting.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9f6e5511-efcd-4e4f-8776-0b869ed54a69%40isocpp.org.

------=_Part_30659_478485804.1529505403896
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, June 20, 2018 at 6:01:57 AM UTC-4, saii...@g=
mail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-=
left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr=
">Hi,<div><br></div><div>a=C2=A0Safe Navigation Operator like in C#, Ruby o=
r Kotlin would make the code so much simpler and easier to read.</div></div=
></blockquote><div><br></div><div>This is only true because those languages=
 do not have non-nullable references. Or if they have them, they aren&#39;t=
 the common case.</div><div><br></div><div>I haven&#39;t written a lot of c=
ode that does so many chained accesses of nullable references like verifyin=
g them becomes a syntactic burden of a kind worthy of added syntax. We have=
 the option to have functions return a non-nullable reference, so in many c=
ases, we don&#39;t return pointers.</div><div><br></div><div>Having this ma=
ny NULL checks suggests that maybe the system in question is just poorly de=
signed.</div><div><br></div><div>Also, what happens if the function needs t=
o return something? What you&#39;re talking about can only be used in funct=
ions with no return values. That seems decidedly limiting.</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9f6e5511-efcd-4e4f-8776-0b869ed54a69%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9f6e5511-efcd-4e4f-8776-0b869ed54a69=
%40isocpp.org</a>.<br />

------=_Part_30659_478485804.1529505403896--

------=_Part_30658_1404441100.1529505403895--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Wed, 20 Jun 2018 16:45:10 +0200
Raw View
--00000000000022fec1056f13d9f3
Content-Type: text/plain; charset="UTF-8"

On Wed, 20 Jun 2018 at 16:36, Nicol Bolas <jmckesson@gmail.com> wrote:

> On Wednesday, June 20, 2018 at 6:01:57 AM UTC-4, saii...@gmail.com wrote:
>>
>> Hi,
>>
>> a Safe Navigation Operator like in C#, Ruby or Kotlin would make the code
>> so much simpler and easier to read.
>>
>
> This is only true because those languages do not have non-nullable
> references. Or if they have them, they aren't the common case.
>
> I haven't written a lot of code that does so many chained accesses of
> nullable references like verifying them becomes a syntactic burden of a
> kind worthy of added syntax. We have the option to have functions return a
> non-nullable reference, so in many cases, we don't return pointers.
>
> Having this many NULL checks suggests that maybe the system in question is
> just poorly designed.
>

^^ this ^^


>
> Also, what happens if the function needs to return something? What you're
> talking about can only be used in functions with no return values. That
> seems decidedly limiting.
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9f6e5511-efcd-4e4f-8776-0b869ed54a69%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9f6e5511-efcd-4e4f-8776-0b869ed54a69%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hZU8ZTfbumn7%2B5-mmphSWMOasohaXp%3DpdJRkHbOMsnoSQ%40mail.gmail.com.

--00000000000022fec1056f13d9f3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Wed=
, 20 Jun 2018 at 16:36, Nicol Bolas &lt;<a href=3D"mailto:jmckesson@gmail.c=
om">jmckesson@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr">On Wednesday, June 20, 2018 at 6:01:57 AM UTC-4, <a hr=
ef=3D"mailto:saii...@gmail.com" target=3D"_blank">saii...@gmail.com</a> wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hi,<div><br></d=
iv><div>a=C2=A0Safe Navigation Operator like in C#, Ruby or Kotlin would ma=
ke the code so much simpler and easier to read.</div></div></blockquote><di=
v><br></div><div>This is only true because those languages do not have non-=
nullable references. Or if they have them, they aren&#39;t the common case.=
</div><div><br></div><div>I haven&#39;t written a lot of code that does so =
many chained accesses of nullable references like verifying them becomes a =
syntactic burden of a kind worthy of added syntax. We have the option to ha=
ve functions return a non-nullable reference, so in many cases, we don&#39;=
t return pointers.</div><div><br></div><div>Having this many NULL checks su=
ggests that maybe the system in question is just poorly designed.</div></di=
v></blockquote><div><br></div><div>^^ this ^^</div><div>=C2=A0</div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr"><div><br></div><div>Also, what hap=
pens if the function needs to return something? What you&#39;re talking abo=
ut can only be used in functions with no return values. That seems decidedl=
y limiting.</div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9f6e5511-efcd-4e4f-8776-0b869ed54a69%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9f6e5511-efcd-=
4e4f-8776-0b869ed54a69%40isocpp.org</a>.<br>
</blockquote></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hZU8ZTfbumn7%2B5-mmphSWMOasohaX=
p%3DpdJRkHbOMsnoSQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hZU8ZTf=
bumn7%2B5-mmphSWMOasohaXp%3DpdJRkHbOMsnoSQ%40mail.gmail.com</a>.<br />

--00000000000022fec1056f13d9f3--

.