Topic: Variable declaration in a ternary conditional


Author: hamza_sood@me.com
Date: Mon, 2 Apr 2018 11:02:16 -0700 (PDT)
Raw View
------=_Part_17531_1610927250.1522692136595
Content-Type: multipart/alternative;
 boundary="----=_Part_17532_1995253147.1522692136596"

------=_Part_17532_1995253147.1522692136596
Content-Type: text/plain; charset="UTF-8"

I propose allowing variable declarations in the condition of a ternary
expression, which would allow code such as:
const int i = (const MyType* x = something())
                ? x->get_int()
                : 1234;
In this case the "something" function may have side effects, so you can't
repeat it multiple times in the expression without changing its meaning.

The condition in an if statement can contain a variable declaration, so it
isn't unreasonable to think that the same could be true for the ternary
operator. The semantics would be very much the same: the variable will be
usable in both branches and then destroyed at the end of the expression.

This proposal would also allow for writing code similar to that of this GCC
extension <https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html>:
// GCC Extension.
return get_int() ?: 1234;

// This proposal.
// It's a bit more verbose in comparison, but also more powerful because it
can be used for more than just null coalescing.
return (int i = get_int()) ? i : 1234;

--
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/8a755089-c146-47ab-8250-c2b3e705cacd%40isocpp.org.

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

<div dir=3D"ltr">I propose allowing variable declarations in the condition =
of a ternary expression, which would allow code such as:<div><div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px sol=
id rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><font><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">int</span><font color=3D"#000000"><span style=3D"caret-color: rgb(102,=
 0, 102);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> i </s=
pan></span></font><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">MyType</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> x </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> something</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">())</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">?</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">-&gt;</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"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </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: #066;" class=3D"styled-by-prettify">1234</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">;</span></font></div></=
code></div>In this case the &quot;something&quot; function may have side ef=
fects, so you can&#39;t repeat it multiple times in the expression without =
changing its meaning.</div><div><br></div><div>The condition in an if state=
ment can contain a variable declaration, so it isn&#39;t unreasonable to th=
ink that the same could be true for the ternary operator. The semantics wou=
ld be very much the same: the variable will be usable in both branches and =
then destroyed at the end of the expression.</div><div><br></div><div>This =
proposal would also allow for writing code similar to that of <a href=3D"ht=
tps://gcc.gnu.org/onlinedocs/gcc/Conditionals.html">this GCC extension</a>:=
</div><div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 2=
50, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><co=
de class=3D"prettyprint"><div class=3D"subprettyprint"><font><span style=3D=
"color: #800;" class=3D"styled-by-prettify">// GCC Extension.</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><font color=
=3D"#000088"><span style=3D"color: #008;" class=3D"styled-by-prettify">retu=
rn</span></font><span style=3D"color: #000;" 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><sp=
an 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=
: #066;" class=3D"styled-by-prettify">1234</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: #800;" class=
=3D"styled-by-prettify">// This proposal.</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" clas=
s=3D"styled-by-prettify">// It&#39;s a bit more verbose in comparison, but =
also more powerful because it can be used for more than just null coalescin=
g.</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">return</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: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> i </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> get_int</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">())</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
?</span><font color=3D"#000000"><span style=3D"caret-color: rgb(102, 0, 102=
);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> i </span><sp=
an 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=
: #066;" class=3D"styled-by-prettify">1234</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span></span></font><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br></span></font></div></code></div><=
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/8a755089-c146-47ab-8250-c2b3e705cacd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8a755089-c146-47ab-8250-c2b3e705cacd=
%40isocpp.org</a>.<br />

------=_Part_17532_1995253147.1522692136596--

------=_Part_17531_1610927250.1522692136595--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Mon, 02 Apr 2018 14:38:48 -0400
Raw View
This is a multi-part message in MIME format.

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

auto I = [&] {

if (auto x = something())

  return x->get_int();

else

  return 1234;

}();

--

Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

From: hamza_sood@me.com <hamza_sood@me.com>
Sent: Monday, April 2, 2018 1:02 PM

I propose allowing variable declarations in the condition of a ternary expression, which would allow code such as:

constint i =(constMyType* x = something())
                ? x->get_int()
                :1234;

In this case the "something" function may have side effects, so you can't repeat it multiple times in the expression without changing its meaning.

--
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/HayhuYBDuyAEh15N8sBKgh2-1yZsNQ43kbPFwb5tFXZGfNsR6LJNDl6YnmC6scpv2JSgvr-SBOp8lteU_uVfy1Ck6ETX347kh-9KDhIzld4%3D%40miator.net.

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

<html><head></head><body><div class=3D"WordSection1"><p class=3D"MsoNormal"=
>=C2=A0 auto I =3D [&amp;] {<o:p></o:p></p><p class=3D"MsoNormal" style=3D"=
text-indent:10.15pt">if (auto x =3D something())<o:p></o:p></p><p class=3D"=
MsoNormal" style=3D"text-indent:10.15pt">=C2=A0 return x-&gt;get_int();<o:p=
></o:p></p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">else<o:p></=
o:p></p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">=C2=A0 return =
1234;<o:p></o:p></p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">}(=
);<o:p></o:p></p><p class=3D"MsoNormal"><o:p>=C2=A0</o:p></p><p class=3D"Ms=
oNormal">--<o:p></o:p></p><p class=3D"MsoNormal">Zhihao Yuan, ID lichray<br=
/>The best way to predict the future is to invent it.<br/>_________________=
______________________________<o:p></o:p></p><p class=3D"MsoNormal"><o:p>=
=C2=A0</o:p></p><div style=3D"border:none;border-left:solid blue 1.5pt;padd=
ing:0in 0in 0in 4.0pt"><div><div style=3D"border:none;border-top:solid #E1E=
1E1 1.0pt;padding:3.0pt 0in 0in 0in"><p class=3D"MsoNormal"><b>From:</b> ha=
mza_sood@me.com &lt;hamza_sood@me.com&gt; <br/><b>Sent:</b> Monday, April 2=
, 2018 1:02 PM<o:p></o:p></p></div></div><p class=3D"MsoNormal"><o:p>=C2=A0=
</o:p></p><div><p class=3D"MsoNormal">I propose allowing variable declarati=
ons in the condition of a ternary expression, which would allow code such a=
s:<o:p></o:p></p><div><div style=3D"border:solid #BBBBBB 1.0pt;padding:0in =
0in 0in 0in;word-wrap: break-word"><div><p class=3D"MsoNormal" style=3D"bac=
kground:#FAFAFA"><span class=3D"styled-by-prettify"><span style=3D"font-siz=
e:10.0pt;font-family:&#34;Courier New&#34;;color:#000088">const</span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&#34;Courier New&#34;;color:black"> </span></span><span class=3D"styl=
ed-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier Ne=
w&#34;;color:#000088">int</span></span><span class=3D"styled-by-prettify"><=
span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:blac=
k"> i </span></span><span class=3D"styled-by-prettify"><span style=3D"font-=
size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">=3D</span></sp=
an><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-=
family:&#34;Courier New&#34;;color:black"> </span></span><span class=3D"sty=
led-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier N=
ew&#34;;color:#666600">(</span></span><span class=3D"styled-by-prettify"><s=
pan style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#0000=
88">const</span></span><span class=3D"styled-by-prettify"><span style=3D"fo=
nt-size:10.0pt;font-family:&#34;Courier New&#34;;color:black"> </span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&#34;Courier New&#34;;color:#660066">MyType</span></span><span class=
=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Co=
urier New&#34;;color:#666600">*</span></span><span class=3D"styled-by-prett=
ify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;colo=
r:black"> x </span></span><span class=3D"styled-by-prettify"><span style=3D=
"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">=3D</spa=
n></span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt=
;font-family:&#34;Courier New&#34;;color:black"> something</span></span><sp=
an class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family=
:&#34;Courier New&#34;;color:#666600">())</span></span><span style=3D"font-=
size:10.0pt;font-family:&#34;Courier New&#34;;color:black"><br/><span class=
=3D"styled-by-prettify">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span></span><span class=3D"styled-by-prettify"><span style=3D"font=
-size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">?</span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&#34;Courier New&#34;;color:black"> x</span></span><span class=3D"sty=
led-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier N=
ew&#34;;color:#666600">-&gt;</span></span><span class=3D"styled-by-prettify=
"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:b=
lack">get_int</span></span><span class=3D"styled-by-prettify"><span style=
=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:#666600">()</s=
pan></span><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34=
;;color:black"><br/><span class=3D"styled-by-prettify">=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></span><span class=3D"styled-by-=
prettify"><span style=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;=
;color:#666600">:</span></span><span class=3D"styled-by-prettify"><span sty=
le=3D"font-size:10.0pt;font-family:&#34;Courier New&#34;;color:black"> </sp=
an></span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0p=
t;font-family:&#34;Courier New&#34;;color:#006666">1234</span></span><span =
class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&#=
34;Courier New&#34;;color:#666600">;</span></span><span style=3D"font-size:=
10.0pt;font-family:&#34;Courier New&#34;"><o:p></o:p></span></p></div></div=
><p class=3D"MsoNormal">In this case the &#34;something&#34; function may h=
ave side effects, so you can&#39;t repeat it multiple times in the expressi=
on without changing its meaning.<o:p></o:p></p></div></div><p class=3D"MsoN=
ormal"><o:p>=C2=A0</o:p></p></div></div></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/HayhuYBDuyAEh15N8sBKgh2-1yZsNQ43kbPFw=
b5tFXZGfNsR6LJNDl6YnmC6scpv2JSgvr-SBOp8lteU_uVfy1Ck6ETX347kh-9KDhIzld4%3D%4=
0miator.net?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/HayhuYBDuyAEh15N8sBKgh2-1yZsNQ43kbPFw=
b5tFXZGfNsR6LJNDl6YnmC6scpv2JSgvr-SBOp8lteU_uVfy1Ck6ETX347kh-9KDhIzld4%3D%4=
0miator.net</a>.<br />

--b1_4a7675bd3b7e3620d06864c2d9e6d089--


.


Author: hamza_sood@me.com
Date: Mon, 2 Apr 2018 11:52:44 -0700 (PDT)
Raw View
------=_Part_17585_1177268808.1522695164334
Content-Type: multipart/alternative;
 boundary="----=_Part_17586_1308619729.1522695164334"

------=_Part_17586_1308619729.1522695164334
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I don=E2=80=99t quite follow your argument here. Are you trying to say that=
 we=20
don=E2=80=99t need ternaries anymore because we have lambdas? If so then I=
=20
completely disagree. Ternaries are a direct expression of intent: set a=20
value based on a condition. A lambda could be anything and is much less=20
clear, especially since the actual invoking of it happens right at the end=
=20
and so is easily missed (at a glance, that looks like you=E2=80=99re assign=
ing a=20
lambda and not an int).

On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:
>
>   auto I =3D [&] {
>
> if (auto x =3D something())
>
>   return x->get_int();
>
> else
>
>   return 1234;
>
> }();
>
> =20
>
> --
>
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> _______________________________________________
>
> =20
>
> *From:* hamza...@me.com <javascript:> <hamza...@me.com <javascript:>>=20
> *Sent:* Monday, April 2, 2018 1:02 PM
>
> =20
>
> I propose allowing variable declarations in the condition of a ternary=20
> expression, which would allow code such as:
>
> const int i =3D (const MyType* x =3D something())
>                 ? x->get_int()
>                 : 1234;
>
> In this case the "something" function may have side effects, so you can't=
=20
> repeat it multiple times in the expression without changing its meaning.
>
> =20
>

--=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/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%40isocpp.or=
g.

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

<div dir=3D"ltr">I don=E2=80=99t quite follow your argument here. Are you t=
rying to say that we don=E2=80=99t need ternaries anymore because we have l=
ambdas? If so then I completely disagree. Ternaries are a direct expression=
 of intent: set a value based on a condition. A lambda could be anything an=
d is much less clear, especially since the actual invoking of it happens ri=
ght at the end and so is easily missed (at a glance, that looks like you=E2=
=80=99re assigning a lambda and not an int).<br><br>On Monday, April 2, 201=
8 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div><div><p class=3D"MsoNormal">=C2=A0 auto I =3D [&amp;] {</p>=
<p class=3D"MsoNormal" style=3D"text-indent:10.15pt">if (auto x =3D somethi=
ng())</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">=C2=A0 return=
 x-&gt;get_int();</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">e=
lse</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">=C2=A0 return 1=
234;</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">}();</p><p cla=
ss=3D"MsoNormal">=C2=A0</p><p class=3D"MsoNormal">--</p><p class=3D"MsoNorm=
al">Zhihao Yuan, ID lichray<br>The best way to predict the future is to inv=
ent it.<br>______________________________<wbr>_________________</p><p class=
=3D"MsoNormal">=C2=A0</p><div style=3D"border:none;border-left:solid blue 1=
..5pt;padding:0in 0in 0in 4.0pt"><div><div style=3D"border:none;border-top:s=
olid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in"><p class=3D"MsoNormal"><b>Fro=
m:</b> <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"l=
2A9bThGBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#=
39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;=
">hamza...@me.com</a> &lt;<a href=3D"javascript:" target=3D"_blank" gdf-obf=
uscated-mailto=3D"l2A9bThGBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascri=
pt:&#39;;return true;">hamza...@me.com</a>&gt; <br><b>Sent:</b> Monday, Apr=
il 2, 2018 1:02 PM</p></div></div><p class=3D"MsoNormal">=C2=A0</p><div><p =
class=3D"MsoNormal">I propose allowing variable declarations in the conditi=
on of a ternary expression, which would allow code such as:</p><div><div st=
yle=3D"border:solid #bbbbbb 1.0pt;padding:0in 0in 0in 0in;word-wrap:break-w=
ord"><div><p class=3D"MsoNormal" style=3D"background:#fafafa"><span><span s=
tyle=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#000088"=
>const</span></span><span><span style=3D"font-size:10.0pt;font-family:&quot=
;Courier New&quot;;color:black"> </span></span><span><span style=3D"font-si=
ze:10.0pt;font-family:&quot;Courier New&quot;;color:#000088">int</span></sp=
an><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot=
;;color:black"> i </span></span><span><span style=3D"font-size:10.0pt;font-=
family:&quot;Courier New&quot;;color:#666600">=3D</span></span><span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">=
 </span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Cour=
ier New&quot;;color:#666600">(</span></span><span><span style=3D"font-size:=
10.0pt;font-family:&quot;Courier New&quot;;color:#000088">const</span></spa=
n><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;=
;color:black"> </span></span><span><span style=3D"font-size:10.0pt;font-fam=
ily:&quot;Courier New&quot;;color:#660066">MyType</span></span><span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#666600=
">*</span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Co=
urier New&quot;;color:black"> x </span></span><span><span style=3D"font-siz=
e:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">=3D</span></spa=
n><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;=
;color:black"> something</span></span><span><span style=3D"font-size:10.0pt=
;font-family:&quot;Courier New&quot;;color:#666600">())</span></span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">=
<br><span>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></=
span><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&qu=
ot;;color:#666600">?</span></span><span><span style=3D"font-size:10.0pt;fon=
t-family:&quot;Courier New&quot;;color:black"> x</span></span><span><span s=
tyle=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#666600"=
>-&gt;</span></span><span><span style=3D"font-size:10.0pt;font-family:&quot=
;Courier New&quot;;color:black">get_int</span></span><span><span style=3D"f=
ont-size:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">()</span=
></span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;=
;color:black"><br><span>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span></span><span><span style=3D"font-size:10.0pt;font-family:&quo=
t;Courier New&quot;;color:#666600">:</span></span><span><span style=3D"font=
-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></spa=
n><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;=
;color:#006666">1234</span></span><span><span style=3D"font-size:10.0pt;fon=
t-family:&quot;Courier New&quot;;color:#666600">;</span></span><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"></span></p></div>=
</div><p class=3D"MsoNormal">In this case the &quot;something&quot; functio=
n may have side effects, so you can&#39;t repeat it multiple times in the e=
xpression without changing its meaning.</p></div></div><p class=3D"MsoNorma=
l">=C2=A0</p></div></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/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22=
%40isocpp.org</a>.<br />

------=_Part_17586_1308619729.1522695164334--

------=_Part_17585_1177268808.1522695164334--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Mon, 2 Apr 2018 21:09:55 +0200
Raw View
--94eb2c064646e7bc4d0568e2555d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Here's another way to express the intent:

    auto i =3D either(something()->get_int())
            .otherwise(1234);



And here's some trivial boilerplate:


#include <utility>

struct MyType {
    int get_int();
};

extern MyType* something();

struct not_zero
{
    template<class T>
    bool operator()(T&& x) const { return x !=3D T(0); }
};

template<class T, class Pred =3D not_zero>
struct either
{
    either(T x, Pred p =3D Pred()) : value(x), pred(p) {}

    T otherwise(T y) const {
        return pred(value) ? value : y;
    }

    T value;
    Pred pred;
};

//template<class T> either(T x) -> either<T, is_zero>;

int main()
{

    auto i =3D either(something()->get_int())
            .otherwise(1234);
    return i;
}


On 2 April 2018 at 20:52, <hamza_sood@me.com> wrote:

> I don=E2=80=99t quite follow your argument here. Are you trying to say th=
at we
> don=E2=80=99t need ternaries anymore because we have lambdas? If so then =
I
> completely disagree. Ternaries are a direct expression of intent: set a
> value based on a condition. A lambda could be anything and is much less
> clear, especially since the actual invoking of it happens right at the en=
d
> and so is easily missed (at a glance, that looks like you=E2=80=99re assi=
gning a
> lambda and not an int).
>
> On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:
>>
>>   auto I =3D [&] {
>>
>> if (auto x =3D something())
>>
>>   return x->get_int();
>>
>> else
>>
>>   return 1234;
>>
>> }();
>>
>>
>>
>> --
>>
>> Zhihao Yuan, ID lichray
>> The best way to predict the future is to invent it.
>> _______________________________________________
>>
>>
>>
>> *From:* hamza...@me.com <hamza...@me.com>
>> *Sent:* Monday, April 2, 2018 1:02 PM
>>
>>
>>
>> I propose allowing variable declarations in the condition of a ternary
>> expression, which would allow code such as:
>>
>> const int i =3D (const MyType* x =3D something())
>>                 ? x->get_int()
>>                 : 1234;
>>
>> In this case the "something" function may have side effects, so you can'=
t
>> repeat it multiple times in the expression without changing its meaning.
>>
>>
>>
> --
> 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/3cdd7b2c-3716-4a58-
> 8a13-3f65fb2eae22%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-37=
16-4a58-8a13-3f65fb2eae22%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=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/CALvx3hYWiya5qW1dVXGc7dc1V9KKLgLcdV%3DYyqFuUDUHs=
WxcgQ%40mail.gmail.com.

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

<div dir=3D"ltr">Here&#39;s another way to express the intent:<div><br></di=
v><div><div style=3D"color:rgb(34,34,34);font-family:arial,sans-serif;font-=
size:small;font-style:normal;font-variant-ligatures:normal;font-variant-cap=
s:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent=
:0px;text-transform:none;white-space:normal;word-spacing:0px;background-col=
or:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:ini=
tial"><font face=3D"monospace, monospace">=C2=A0 =C2=A0 auto i =3D either(s=
omething()-&gt;get_int())</font></div><div style=3D"color:rgb(34,34,34);fon=
t-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-li=
gatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:norm=
al;text-align:start;text-indent:0px;text-transform:none;white-space:normal;=
word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:in=
itial;text-decoration-color:initial"><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .otherwise(1234);</font></div><br=
 class=3D"gmail-Apple-interchange-newline"><br></div><div><br></div><div>An=
d here&#39;s some trivial boilerplate:</div><div><br><div><br></div><div><d=
iv><font face=3D"monospace, monospace">#include &lt;utility&gt;</font></div=
><div><font face=3D"monospace, monospace"><br></font></div><div><font face=
=3D"monospace, monospace">struct MyType {</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 =C2=A0 int get_int();</font></div><div><font fac=
e=3D"monospace, monospace">};</font></div><div><font face=3D"monospace, mon=
ospace"><br></font></div><div><font face=3D"monospace, monospace">extern My=
Type* something();</font></div><div><font face=3D"monospace, monospace"><br=
></font></div><div><font face=3D"monospace, monospace">struct not_zero</fon=
t></div><div><font face=3D"monospace, monospace">{</font></div><div><font f=
ace=3D"monospace, monospace">=C2=A0 =C2=A0 template&lt;class T&gt;</font></=
div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 bool operator()(=
T&amp;&amp; x) const { return x !=3D T(0); }</font></div><div><font face=3D=
"monospace, monospace">};</font></div><div><font face=3D"monospace, monospa=
ce"><br></font></div><div><font face=3D"monospace, monospace">template&lt;c=
lass T, class Pred =3D not_zero&gt;</font></div><div><font face=3D"monospac=
e, monospace">struct either</font></div><div><font face=3D"monospace, monos=
pace">{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =
either(T x, Pred p =3D Pred()) : value(x), pred(p) {}</font></div><div><fon=
t face=3D"monospace, monospace"><br></font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 =C2=A0 T otherwise(T y) const {</font></div><div><fon=
t face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return pred(val=
ue) ? value : y;</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 }</font></div><div><font face=3D"monospace, monospace"><br></fon=
t></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 T value;</fo=
nt></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 Pred pred;<=
/font></div><div><font face=3D"monospace, monospace">};</font></div><div><f=
ont face=3D"monospace, monospace"><br></font></div><div><font face=3D"monos=
pace, monospace">//template&lt;class T&gt; either(T x) -&gt; either&lt;T, i=
s_zero&gt;;</font></div><div><font face=3D"monospace, monospace"><br></font=
></div><div><font face=3D"monospace, monospace">int main()</font></div><div=
><font face=3D"monospace, monospace">{</font></div><div><font face=3D"monos=
pace, monospace"><br></font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0 auto i =3D either(something()-&gt;get_int())</font></div><div=
><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 .otherwise(1234);</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0 return i;</font></div><div><font face=3D"monospace, monospace=
">}</font></div></div><div><br></div></div></div><div class=3D"gmail_extra"=
><br><div class=3D"gmail_quote">On 2 April 2018 at 20:52,  <span dir=3D"ltr=
">&lt;<a href=3D"mailto:hamza_sood@me.com" target=3D"_blank">hamza_sood@me.=
com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
">I don=E2=80=99t quite follow your argument here. Are you trying to say th=
at we don=E2=80=99t need ternaries anymore because we have lambdas? If so t=
hen I completely disagree. Ternaries are a direct expression of intent: set=
 a value based on a condition. A lambda could be anything and is much less =
clear, especially since the actual invoking of it happens right at the end =
and so is easily missed (at a glance, that looks like you=E2=80=99re assign=
ing a lambda and not an int).<span class=3D""><br><br>On Monday, April 2, 2=
018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:</span><blockquote class=3D"gmai=
l_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div><div><span class=3D""><p class=3D"MsoNormal">=C2=A0 aut=
o I =3D [&amp;] {</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">i=
f (auto x =3D something())</p><p class=3D"MsoNormal" style=3D"text-indent:1=
0.15pt">=C2=A0 return x-&gt;get_int();</p><p class=3D"MsoNormal" style=3D"t=
ext-indent:10.15pt">else</p><p class=3D"MsoNormal" style=3D"text-indent:10.=
15pt">=C2=A0 return 1234;</p><p class=3D"MsoNormal" style=3D"text-indent:10=
..15pt">}();</p><p class=3D"MsoNormal">=C2=A0</p><p class=3D"MsoNormal">--</=
p><p class=3D"MsoNormal">Zhihao Yuan, ID lichray<br>The best way to predict=
 the future is to invent it.<br>______________________________<wbr>________=
_________</p><p class=3D"MsoNormal">=C2=A0</p></span><div style=3D"border:n=
one;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style=
=3D"border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in"><=
p class=3D"MsoNormal"><b>From:</b> <a rel=3D"nofollow">hamza...@me.com</a> =
&lt;<a rel=3D"nofollow">hamza...@me.com</a>&gt; <br><span class=3D""><b>Sen=
t:</b> Monday, April 2, 2018 1:02 PM</span></p></div></div><span class=3D""=
><p class=3D"MsoNormal">=C2=A0</p><div><p class=3D"MsoNormal">I propose all=
owing variable declarations in the condition of a ternary expression, which=
 would allow code such as:</p><div><div style=3D"border:solid #bbbbbb 1.0pt=
;padding:0in 0in 0in 0in;word-wrap:break-word"><div><p class=3D"MsoNormal" =
style=3D"background:#fafafa"><span><span style=3D"font-size:10.0pt;font-fam=
ily:&quot;Courier New&quot;;color:#000088">const</span></span><span><span s=
tyle=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> =
</span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Couri=
er New&quot;;color:#000088">int</span></span><span><span style=3D"font-size=
:10.0pt;font-family:&quot;Courier New&quot;;color:black"> i </span></span><=
span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;co=
lor:#666600">=3D</span></span><span><span style=3D"font-size:10.0pt;font-fa=
mily:&quot;Courier New&quot;;color:black"> </span></span><span><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">(</=
span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier=
 New&quot;;color:#000088">const</span></span><span><span style=3D"font-size=
:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><sp=
an><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;colo=
r:#660066">MyType</span></span><span><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:#666600">*</span></span><span><span sty=
le=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> x =
</span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Couri=
er New&quot;;color:#666600">=3D</span></span><span><span style=3D"font-size=
:10.0pt;font-family:&quot;Courier New&quot;;color:black"> something</span><=
/span><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;;color:#666600">())</span></span><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:black"><br><span>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></span><span><span style=3D"font-=
size:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">?</span></sp=
an><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot=
;;color:black"> x</span></span><span><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:#666600">-&gt;</span></span><span><span=
 style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"=
>get_int</span></span><span><span style=3D"font-size:10.0pt;font-family:&qu=
ot;Courier New&quot;;color:#666600">()</span></span><span style=3D"font-siz=
e:10.0pt;font-family:&quot;Courier New&quot;;color:black"><br><span>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></span><span><span =
style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#666600=
">:</span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Co=
urier New&quot;;color:black"> </span></span><span><span style=3D"font-size:=
10.0pt;font-family:&quot;Courier New&quot;;color:#006666">1234</span></span=
><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;=
color:#666600">;</span></span><span style=3D"font-size:10.0pt;font-family:&=
quot;Courier New&quot;"></span></p></div></div><p class=3D"MsoNormal">In th=
is case the &quot;something&quot; function may have side effects, so you ca=
n&#39;t repeat it multiple times in the expression without changing its mea=
ning.</p></div></div><p class=3D"MsoNormal">=C2=A0</p></span></div></div></=
div></blockquote></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/3cdd=
7b2c-3716-4a58-<wbr>8a13-3f65fb2eae22%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></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/CALvx3hYWiya5qW1dVXGc7dc1V9KKLgLcdV%3=
DYyqFuUDUHsWxcgQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYWiya5qW=
1dVXGc7dc1V9KKLgLcdV%3DYyqFuUDUHsWxcgQ%40mail.gmail.com</a>.<br />

--94eb2c064646e7bc4d0568e2555d--

.


Author: hamza_sood@me.com
Date: Mon, 2 Apr 2018 12:20:28 -0700 (PDT)
Raw View
------=_Part_18011_1634068892.1522696828561
Content-Type: multipart/alternative;
 boundary="----=_Part_18012_2052526399.1522696828562"

------=_Part_18012_2052526399.1522696828562
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Nice solution, but that doesn=E2=80=99t work in the first case where =E2=80=
=9Csomething=E2=80=9D=20
might return a nullptr.

On Monday, April 2, 2018 at 8:09:59 PM UTC+1, Richard Hodges wrote:
>
> Here's another way to express the intent:
>
>     auto i =3D either(something()->get_int())
>             .otherwise(1234);
>
>
>
> And here's some trivial boilerplate:
>
>
> #include <utility>
>
> struct MyType {
>     int get_int();
> };
>
> extern MyType* something();
>
> struct not_zero
> {
>     template<class T>
>     bool operator()(T&& x) const { return x !=3D T(0); }
> };
>
> template<class T, class Pred =3D not_zero>
> struct either
> {
>     either(T x, Pred p =3D Pred()) : value(x), pred(p) {}
>
>     T otherwise(T y) const {
>         return pred(value) ? value : y;
>     }
>
>     T value;
>     Pred pred;
> };
>
> //template<class T> either(T x) -> either<T, is_zero>;
>
> int main()
> {
>
>     auto i =3D either(something()->get_int())
>             .otherwise(1234);
>     return i;
> }
>
>
> On 2 April 2018 at 20:52, <hamza...@me.com <javascript:>> wrote:
>
>> I don=E2=80=99t quite follow your argument here. Are you trying to say t=
hat we=20
>> don=E2=80=99t need ternaries anymore because we have lambdas? If so then=
 I=20
>> completely disagree. Ternaries are a direct expression of intent: set a=
=20
>> value based on a condition. A lambda could be anything and is much less=
=20
>> clear, especially since the actual invoking of it happens right at the e=
nd=20
>> and so is easily missed (at a glance, that looks like you=E2=80=99re ass=
igning a=20
>> lambda and not an int).
>>
>> On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:
>>>
>>>   auto I =3D [&] {
>>>
>>> if (auto x =3D something())
>>>
>>>   return x->get_int();
>>>
>>> else
>>>
>>>   return 1234;
>>>
>>> }();
>>>
>>> =20
>>>
>>> --
>>>
>>> Zhihao Yuan, ID lichray
>>> The best way to predict the future is to invent it.
>>> _______________________________________________
>>>
>>> =20
>>>
>>> *From:* hamza...@me.com <hamza...@me.com>=20
>>> *Sent:* Monday, April 2, 2018 1:02 PM
>>>
>>> =20
>>>
>>> I propose allowing variable declarations in the condition of a ternary=
=20
>>> expression, which would allow code such as:
>>>
>>> const int i =3D (const MyType* x =3D something())
>>>                 ? x->get_int()
>>>                 : 1234;
>>>
>>> In this case the "something" function may have side effects, so you=20
>>> can't repeat it multiple times in the expression without changing its=
=20
>>> meaning.
>>>
>>> =20
>>>
>> --=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-37=
16-4a58-8a13-3f65fb2eae22%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-3=
716-4a58-8a13-3f65fb2eae22%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
>

--=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/9fabc312-9500-4b34-9a4a-a2793891c585%40isocpp.or=
g.

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

<div dir=3D"ltr">Nice solution, but that doesn=E2=80=99t work in the first =
case where =E2=80=9Csomething=E2=80=9D might return a nullptr.<br><br>On Mo=
nday, April 2, 2018 at 8:09:59 PM UTC+1, Richard Hodges wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Here&#39;s another way to =
express the intent:<div><br></div><div><div style=3D"color:rgb(34,34,34);fo=
nt-family:arial,sans-serif;font-size:small;font-style:normal;font-weight:40=
0;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:non=
e;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255)"><f=
ont face=3D"monospace, monospace">=C2=A0 =C2=A0 auto i =3D either(something=
()-&gt;get_int())</font></div><div style=3D"color:rgb(34,34,34);font-family=
:arial,sans-serif;font-size:small;font-style:normal;font-weight:400;letter-=
spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-s=
pace:normal;word-spacing:0px;background-color:rgb(255,255,255)"><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .otherw=
ise(1234);</font></div><br><br></div><div><br></div><div>And here&#39;s som=
e trivial boilerplate:</div><div><br><div><br></div><div><div><font face=3D=
"monospace, monospace">#include &lt;utility&gt;</font></div><div><font face=
=3D"monospace, monospace"><br></font></div><div><font face=3D"monospace, mo=
nospace">struct MyType {</font></div><div><font face=3D"monospace, monospac=
e">=C2=A0 =C2=A0 int get_int();</font></div><div><font face=3D"monospace, m=
onospace">};</font></div><div><font face=3D"monospace, monospace"><br></fon=
t></div><div><font face=3D"monospace, monospace">extern MyType* something()=
;</font></div><div><font face=3D"monospace, monospace"><br></font></div><di=
v><font face=3D"monospace, monospace">struct not_zero</font></div><div><fon=
t face=3D"monospace, monospace">{</font></div><div><font face=3D"monospace,=
 monospace">=C2=A0 =C2=A0 template&lt;class T&gt;</font></div><div><font fa=
ce=3D"monospace, monospace">=C2=A0 =C2=A0 bool operator()(T&amp;&amp; x) co=
nst { return x !=3D T(0); }</font></div><div><font face=3D"monospace, monos=
pace">};</font></div><div><font face=3D"monospace, monospace"><br></font></=
div><div><font face=3D"monospace, monospace">template&lt;class T, class Pre=
d =3D not_zero&gt;</font></div><div><font face=3D"monospace, monospace">str=
uct either</font></div><div><font face=3D"monospace, monospace">{</font></d=
iv><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 either(T x, Pred =
p =3D Pred()) : value(x), pred(p) {}</font></div><div><font face=3D"monospa=
ce, monospace"><br></font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0 T otherwise(T y) const {</font></div><div><font face=3D"monos=
pace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return pred(value) ? value : y=
;</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 }</fon=
t></div><div><font face=3D"monospace, monospace"><br></font></div><div><fon=
t face=3D"monospace, monospace">=C2=A0 =C2=A0 T value;</font></div><div><fo=
nt face=3D"monospace, monospace">=C2=A0 =C2=A0 Pred pred;</font></div><div>=
<font face=3D"monospace, monospace">};</font></div><div><font face=3D"monos=
pace, monospace"><br></font></div><div><font face=3D"monospace, monospace">=
//template&lt;class T&gt; either(T x) -&gt; either&lt;T, is_zero&gt;;</font=
></div><div><font face=3D"monospace, monospace"><br></font></div><div><font=
 face=3D"monospace, monospace">int main()</font></div><div><font face=3D"mo=
nospace, monospace">{</font></div><div><font face=3D"monospace, monospace">=
<br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 aut=
o i =3D either(something()-&gt;get_int())</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 .otherwise(12=
34);</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 ret=
urn i;</font></div><div><font face=3D"monospace, monospace">}</font></div><=
/div><div><br></div></div></div><div><br><div class=3D"gmail_quote">On 2 Ap=
ril 2018 at 20:52,  <span dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D=
"_blank" gdf-obfuscated-mailto=3D"vJ65s-hHBQAJ" rel=3D"nofollow" onmousedow=
n=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=
=3D&#39;javascript:&#39;;return true;">hamza...@me.com</a>&gt;</span> wrote=
:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-le=
ft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I don=E2=80=99t quite =
follow your argument here. Are you trying to say that we don=E2=80=99t need=
 ternaries anymore because we have lambdas? If so then I completely disagre=
e. Ternaries are a direct expression of intent: set a value based on a cond=
ition. A lambda could be anything and is much less clear, especially since =
the actual invoking of it happens right at the end and so is easily missed =
(at a glance, that looks like you=E2=80=99re assigning a lambda and not an =
int).<span><br><br>On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yua=
n wrote:</span><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-l=
eft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><span><p c=
lass=3D"MsoNormal">=C2=A0 auto I =3D [&amp;] {</p><p class=3D"MsoNormal" st=
yle=3D"text-indent:10.15pt">if (auto x =3D something())</p><p class=3D"MsoN=
ormal" style=3D"text-indent:10.15pt">=C2=A0 return x-&gt;get_int();</p><p c=
lass=3D"MsoNormal" style=3D"text-indent:10.15pt">else</p><p class=3D"MsoNor=
mal" style=3D"text-indent:10.15pt">=C2=A0 return 1234;</p><p class=3D"MsoNo=
rmal" style=3D"text-indent:10.15pt">}();</p><p class=3D"MsoNormal">=C2=A0</=
p><p class=3D"MsoNormal">--</p><p class=3D"MsoNormal">Zhihao Yuan, ID lichr=
ay<br>The best way to predict the future is to invent it.<br>______________=
________________<wbr>_________________</p><p class=3D"MsoNormal">=C2=A0</p>=
</span><div style=3D"border:none;border-left:solid blue 1.5pt;padding:0in 0=
in 0in 4.0pt"><div><div style=3D"border:none;border-top:solid #e1e1e1 1.0pt=
;padding:3.0pt 0in 0in 0in"><p class=3D"MsoNormal"><b>From:</b> <a rel=3D"n=
ofollow">hamza...@me.com</a> &lt;<a rel=3D"nofollow">hamza...@me.com</a>&gt=
; <br><span><b>Sent:</b> Monday, April 2, 2018 1:02 PM</span></p></div></di=
v><span><p class=3D"MsoNormal">=C2=A0</p><div><p class=3D"MsoNormal">I prop=
ose allowing variable declarations in the condition of a ternary expression=
, which would allow code such as:</p><div><div style=3D"border:solid #bbbbb=
b 1.0pt;padding:0in 0in 0in 0in;word-wrap:break-word"><div><p class=3D"MsoN=
ormal" style=3D"background:#fafafa"><span><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#000088">const</span></span><span>=
<span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:b=
lack"> </span></span><span><span style=3D"font-size:10.0pt;font-family:&quo=
t;Courier New&quot;;color:#000088">int</span></span><span><span style=3D"fo=
nt-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> i </span><=
/span><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;;color:#666600">=3D</span></span><span><span style=3D"font-size:10.0pt;=
font-family:&quot;Courier New&quot;;color:black"> </span></span><span><span=
 style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#66660=
0">(</span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;C=
ourier New&quot;;color:#000088">const</span></span><span><span style=3D"fon=
t-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> </span></sp=
an><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot=
;;color:#660066">MyType</span></span><span><span style=3D"font-size:10.0pt;=
font-family:&quot;Courier New&quot;;color:#666600">*</span></span><span><sp=
an style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:blac=
k"> x </span></span><span><span style=3D"font-size:10.0pt;font-family:&quot=
;Courier New&quot;;color:#666600">=3D</span></span><span><span style=3D"fon=
t-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"> something</=
span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier=
 New&quot;;color:#666600">())</span></span><span style=3D"font-size:10.0pt;=
font-family:&quot;Courier New&quot;;color:black"><br><span>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></span><span><span style=
=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">?</=
span></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier=
 New&quot;;color:black"> x</span></span><span><span style=3D"font-size:10.0=
pt;font-family:&quot;Courier New&quot;;color:#666600">-&gt;</span></span><s=
pan><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;col=
or:black">get_int</span></span><span><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:#666600">()</span></span><span style=3D=
"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><br><spa=
n>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></span><sp=
an><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;colo=
r:#666600">:</span></span><span><span style=3D"font-size:10.0pt;font-family=
:&quot;Courier New&quot;;color:black"> </span></span><span><span style=3D"f=
ont-size:10.0pt;font-family:&quot;Courier New&quot;;color:#006666">1234</sp=
an></span><span><span style=3D"font-size:10.0pt;font-family:&quot;Courier N=
ew&quot;;color:#666600">;</span></span><span style=3D"font-size:10.0pt;font=
-family:&quot;Courier New&quot;"></span></p></div></div><p class=3D"MsoNorm=
al">In this case the &quot;something&quot; function may have side effects, =
so you can&#39;t repeat it multiple times in the expression without changin=
g its meaning.</p></div></div><p class=3D"MsoNormal">=C2=A0</p></span></div=
></div></div></blockquote></div><span>

<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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
vJ65s-hHBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"vJ65s-hHBQAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" on=
click=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/3cdd7b2c-3716-4a58-<wbr>8a13-=
3f65fb2eae22%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></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/9fabc312-9500-4b34-9a4a-a2793891c585%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9fabc312-9500-4b34-9a4a-a2793891c585=
%40isocpp.org</a>.<br />

------=_Part_18012_2052526399.1522696828562--

------=_Part_18011_1634068892.1522696828561--

.


Author: Bo Persson <bop@gmb.dk>
Date: Mon, 2 Apr 2018 21:31:13 +0200
Raw View
On 2018-04-02 20:52, hamza_sood@me.com wrote:
> I don=E2=80=99t quite follow your argument here. Are you trying to say th=
at we=20
> don=E2=80=99t need ternaries anymore because we have lambdas? If so then =
I=20
> completely disagree. Ternaries are a direct expression of intent: set a=
=20
> value based on a condition. A lambda could be anything and is much less=
=20
> clear, especially since the actual invoking of it happens right at the=20
> end and so is easily missed (at a glance, that looks like you=E2=80=99re=
=20
> assigning a lambda and not an int).

I believe that the argument is that if you can already do something in=20
the current language, the reason for adding another way to do the same=20
thing needs to be a lot more convincing.

It's not that C++ is too small as it is.


     Bo Persson



>=20
> On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:
>=20
>      =C2=A0 auto I =3D [&] {
>=20
>     if (auto x =3D something())
>=20
>      =C2=A0 return x->get_int();
>=20
>     else
>=20
>      =C2=A0 return 1234;
>=20
>     }();
>=20
>     --
>=20
>     Zhihao Yuan, ID lichray
>     The best way to predict the future is to invent it.
>     _______________________________________________
>=20
>     *From:* hamza...@me.com <javascript:> <hamza...@me.com <javascript:>>
>     *Sent:* Monday, April 2, 2018 1:02 PM
>=20
>     I propose allowing variable declarations in the condition of a
>     ternary expression, which would allow code such as:
>=20
>     constinti =3D(constMyType*x =3Dsomething())
>     ?x->get_int()
>     :1234;
>=20
>     In this case the "something" function may have side effects, so you
>     can't repeat it multiple times in the expression without changing
>     its meaning.
>=20

--=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/p9u0a1%24rcq%241%40blaine.gmane.org.

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Mon, 2 Apr 2018 23:28:58 +0200
Raw View
--0000000000002406030568e4476a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

> Nice solution, but that doesn=E2=80=99t work in the first case where =E2=
=80=9Csomething=E2=80=9D
might return a nullptr.

You are right, but I am sure you would have no problem writing a wrapper
function for the pointer access.

For example:

#include <utility>

struct MyType {
    int get_int();
};

extern MyType* something();

struct from_type {};
constexpr auto from =3D from_type();

struct get_int
{
    template<class T>
    auto operator()(T* p) const
    {
        return p->get_int();
    }

};

template<class F, class T>
struct either
{
    using result_type =3D decltype(std::declval<F>()(std::declval<T*>()));

    constexpr either(F f, from_type, T* ptr) : f(f) , ptr(ptr)
    {}

    auto otherwise(result_type y) const -> result_type {
        return ptr ? f(ptr) : y;
    }
    F f;
    T* ptr;
};

int main()
{

    auto i =3D either(get_int(), from, something()).otherwise(1234);

    return i;
}


On 2 April 2018 at 21:20, <hamza_sood@me.com> wrote:

> Nice solution, but that doesn=E2=80=99t work in the first case where =E2=
=80=9Csomething=E2=80=9D
> might return a nullptr.
>
> On Monday, April 2, 2018 at 8:09:59 PM UTC+1, Richard Hodges wrote:
>>
>> Here's another way to express the intent:
>>
>>     auto i =3D either(something()->get_int())
>>             .otherwise(1234);
>>
>>
>>
>> And here's some trivial boilerplate:
>>
>>
>> #include <utility>
>>
>> struct MyType {
>>     int get_int();
>> };
>>
>> extern MyType* something();
>>
>> struct not_zero
>> {
>>     template<class T>
>>     bool operator()(T&& x) const { return x !=3D T(0); }
>> };
>>
>> template<class T, class Pred =3D not_zero>
>> struct either
>> {
>>     either(T x, Pred p =3D Pred()) : value(x), pred(p) {}
>>
>>     T otherwise(T y) const {
>>         return pred(value) ? value : y;
>>     }
>>
>>     T value;
>>     Pred pred;
>> };
>>
>> //template<class T> either(T x) -> either<T, is_zero>;
>>
>> int main()
>> {
>>
>>     auto i =3D either(something()->get_int())
>>             .otherwise(1234);
>>     return i;
>> }
>>
>>
>> On 2 April 2018 at 20:52, <hamza...@me.com> wrote:
>>
>>> I don=E2=80=99t quite follow your argument here. Are you trying to say =
that we
>>> don=E2=80=99t need ternaries anymore because we have lambdas? If so the=
n I
>>> completely disagree. Ternaries are a direct expression of intent: set a
>>> value based on a condition. A lambda could be anything and is much less
>>> clear, especially since the actual invoking of it happens right at the =
end
>>> and so is easily missed (at a glance, that looks like you=E2=80=99re as=
signing a
>>> lambda and not an int).
>>>
>>> On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:
>>>>
>>>>   auto I =3D [&] {
>>>>
>>>> if (auto x =3D something())
>>>>
>>>>   return x->get_int();
>>>>
>>>> else
>>>>
>>>>   return 1234;
>>>>
>>>> }();
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Zhihao Yuan, ID lichray
>>>> The best way to predict the future is to invent it.
>>>> _______________________________________________
>>>>
>>>>
>>>>
>>>> *From:* hamza...@me.com <hamza...@me.com>
>>>> *Sent:* Monday, April 2, 2018 1:02 PM
>>>>
>>>>
>>>>
>>>> I propose allowing variable declarations in the condition of a ternary
>>>> expression, which would allow code such as:
>>>>
>>>> const int i =3D (const MyType* x =3D something())
>>>>                 ? x->get_int()
>>>>                 : 1234;
>>>>
>>>> In this case the "something" function may have side effects, so you
>>>> can't repeat it multiple times in the expression without changing its
>>>> meaning.
>>>>
>>>>
>>>>
>>> --
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit https://groups.google.com/a/is
>>> ocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-
>>> 3f65fb2eae22%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-=
3716-4a58-8a13-3f65fb2eae22%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
>>> .
>>>
>>
>> --
> 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/9fabc312-9500-4b34-
> 9a4a-a2793891c585%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9fabc312-95=
00-4b34-9a4a-a2793891c585%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=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/CALvx3hbdffFk56rX5AdDPZA18PjpyUdKjpZX84C9JN5kaiB=
kRg%40mail.gmail.com.

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

<div dir=3D"ltr">&gt; Nice solution, but that doesn=E2=80=99t work in the f=
irst case where =E2=80=9Csomething=E2=80=9D might return a nullptr.<div><br=
></div><div>You are right, but I am sure you would have no problem writing =
a wrapper function for the pointer access.=C2=A0</div><div><br></div><div>F=
or example:<br></div><div><br></div><div><div><font face=3D"monospace, mono=
space">#include &lt;utility&gt;</font></div><div><font face=3D"monospace, m=
onospace"><br></font></div><div><font face=3D"monospace, monospace">struct =
MyType {</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0=
 int get_int();</font></div><div><font face=3D"monospace, monospace">};</fo=
nt></div><div><font face=3D"monospace, monospace"><br></font></div><div><fo=
nt face=3D"monospace, monospace">extern MyType* something();</font></div><d=
iv><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"=
monospace, monospace">struct from_type {};</font></div><div><font face=3D"m=
onospace, monospace">constexpr auto from =3D from_type();</font></div><div>=
<font face=3D"monospace, monospace"><br></font></div><div><font face=3D"mon=
ospace, monospace">struct get_int</font></div><div><font face=3D"monospace,=
 monospace">{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 template&lt;class T&gt;</font></div><div><font face=3D"monospace, mo=
nospace">=C2=A0 =C2=A0 auto operator()(T* p) const</font></div><div><font f=
ace=3D"monospace, monospace">=C2=A0 =C2=A0 {</font></div><div><font face=3D=
"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return p-&gt;get_int();<=
/font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 }</font>=
</div><div><font face=3D"monospace, monospace"><br></font></div><div><font =
face=3D"monospace, monospace">};</font></div><div><font face=3D"monospace, =
monospace"><br></font></div><div><font face=3D"monospace, monospace">templa=
te&lt;class F, class T&gt;=C2=A0</font></div><div><font face=3D"monospace, =
monospace">struct either</font></div><div><font face=3D"monospace, monospac=
e">{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 usi=
ng result_type =3D decltype(std::declval&lt;F&gt;()(std::declval&lt;T*&gt;(=
)));</font></div><div><font face=3D"monospace, monospace"><br></font></div>=
<div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 constexpr either(F f=
, from_type, T* ptr) : f(f) , ptr(ptr)</font></div><div><font face=3D"monos=
pace, monospace">=C2=A0 =C2=A0 {}</font></div><div><font face=3D"monospace,=
 monospace"><br></font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 auto otherwise(result_type y) const -&gt; result_type {</font></=
div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 re=
turn ptr ? f(ptr) : y;</font></div><div><font face=3D"monospace, monospace"=
>=C2=A0 =C2=A0 }</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 F f;</font></div><div><font face=3D"monospace, monospace">=C2=A0=
 =C2=A0 T* ptr;</font></div><div><font face=3D"monospace, monospace">};</fo=
nt></div><div><font face=3D"monospace, monospace"><br></font></div><div><fo=
nt face=3D"monospace, monospace">int main()</font></div><div><font face=3D"=
monospace, monospace">{</font></div><div><font face=3D"monospace, monospace=
"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 a=
uto i =3D either(get_int(), from, something()).otherwise(1234);</font></div=
><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0=C2=A0</font></div><=
div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 return i;</font></div=
><div><font face=3D"monospace, monospace">}</font></div></div><div><br></di=
v><div><br></div><div><div class=3D"gmail_extra"><div class=3D"gmail_quote"=
>On 2 April 2018 at 21:20,  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_s=
ood@me.com" target=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrote:<br><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Nice solut=
ion, but that doesn=E2=80=99t work in the first case where =E2=80=9Csomethi=
ng=E2=80=9D might return a nullptr.<span class=3D"gmail-"><br><br>On Monday=
, April 2, 2018 at 8:09:59 PM UTC+1, Richard Hodges wrote:</span><blockquot=
e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px s=
olid rgb(204,204,204);padding-left:1ex"><span class=3D"gmail-"><div dir=3D"=
ltr">Here&#39;s another way to express the intent:<div><br></div><div><div =
style=3D"color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;f=
ont-style:normal;font-weight:400;letter-spacing:normal;text-align:start;tex=
t-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;backgr=
ound-color:rgb(255,255,255)"><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 auto i =3D either(something()-&gt;get_int())</font></div><div style=3D"=
color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style=
:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:=
0px;text-transform:none;white-space:normal;word-spacing:0px;background-colo=
r:rgb(255,255,255)"><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 .otherwise(1234);</font></div><br><br></div><div><=
br></div><div>And here&#39;s some trivial boilerplate:</div><div><br><div><=
br></div><div><div><font face=3D"monospace, monospace">#include &lt;utility=
&gt;</font></div><div><font face=3D"monospace, monospace"><br></font></div>=
<div><font face=3D"monospace, monospace">struct MyType {</font></div><div><=
font face=3D"monospace, monospace">=C2=A0 =C2=A0 int get_int();</font></div=
><div><font face=3D"monospace, monospace">};</font></div><div><font face=3D=
"monospace, monospace"><br></font></div><div><font face=3D"monospace, monos=
pace">extern MyType* something();</font></div><div><font face=3D"monospace,=
 monospace"><br></font></div><div><font face=3D"monospace, monospace">struc=
t not_zero</font></div><div><font face=3D"monospace, monospace">{</font></d=
iv><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 template&lt;class=
 T&gt;</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 b=
ool operator()(T&amp;&amp; x) const { return x !=3D T(0); }</font></div><di=
v><font face=3D"monospace, monospace">};</font></div><div><font face=3D"mon=
ospace, monospace"><br></font></div><div><font face=3D"monospace, monospace=
">template&lt;class T, class Pred =3D not_zero&gt;</font></div><div><font f=
ace=3D"monospace, monospace">struct either</font></div><div><font face=3D"m=
onospace, monospace">{</font></div><div><font face=3D"monospace, monospace"=
>=C2=A0 =C2=A0 either(T x, Pred p =3D Pred()) : value(x), pred(p) {}</font>=
</div><div><font face=3D"monospace, monospace"><br></font></div><div><font =
face=3D"monospace, monospace">=C2=A0 =C2=A0 T otherwise(T y) const {</font>=
</div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
return pred(value) ? value : y;</font></div><div><font face=3D"monospace, m=
onospace">=C2=A0 =C2=A0 }</font></div><div><font face=3D"monospace, monospa=
ce"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0=
 T value;</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 Pred pred;</font></div><div><font face=3D"monospace, monospace">};</fon=
t></div><div><font face=3D"monospace, monospace"><br></font></div><div><fon=
t face=3D"monospace, monospace">//template&lt;class T&gt; either(T x) -&gt;=
 either&lt;T, is_zero&gt;;</font></div><div><font face=3D"monospace, monosp=
ace"><br></font></div><div><font face=3D"monospace, monospace">int main()</=
font></div><div><font face=3D"monospace, monospace">{</font></div><div><fon=
t face=3D"monospace, monospace"><br></font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 =C2=A0 auto i =3D either(something()-&gt;get_int())</=
font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 .otherwise(1234);</font></div><div><font face=3D"monos=
pace, monospace">=C2=A0 =C2=A0 return i;</font></div><div><font face=3D"mon=
ospace, monospace">}</font></div></div><div><br></div></div></div></span><d=
iv><br><div class=3D"gmail_quote"><span class=3D"gmail-">On 2 April 2018 at=
 20:52,  <span dir=3D"ltr">&lt;<a rel=3D"nofollow">hamza...@me.com</a>&gt;<=
/span> wrote:<br></span><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><=
span class=3D"gmail-"><div dir=3D"ltr">I don=E2=80=99t quite follow your ar=
gument here. Are you trying to say that we don=E2=80=99t need ternaries any=
more because we have lambdas? If so then I completely disagree. Ternaries a=
re a direct expression of intent: set a value based on a condition. A lambd=
a could be anything and is much less clear, especially since the actual inv=
oking of it happens right at the end and so is easily missed (at a glance, =
that looks like you=E2=80=99re assigning a lambda and not an int).<span><br=
><br>On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:</span=
><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border=
-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><span><p class=
=3D"MsoNormal">=C2=A0 auto I =3D [&amp;] {</p><p class=3D"MsoNormal" style=
=3D"text-indent:10.15pt">if (auto x =3D something())</p><p class=3D"MsoNorm=
al" style=3D"text-indent:10.15pt">=C2=A0 return x-&gt;get_int();</p><p clas=
s=3D"MsoNormal" style=3D"text-indent:10.15pt">else</p><p class=3D"MsoNormal=
" style=3D"text-indent:10.15pt">=C2=A0 return 1234;</p><p class=3D"MsoNorma=
l" style=3D"text-indent:10.15pt">}();</p><p class=3D"MsoNormal">=C2=A0</p><=
p class=3D"MsoNormal">--</p><p class=3D"MsoNormal">Zhihao Yuan, ID lichray<=
br>The best way to predict the future is to invent it.<br>_________________=
_____________<wbr>_________________</p><p class=3D"MsoNormal">=C2=A0</p></s=
pan><div style=3D"border-top:none;border-right:none;border-bottom:none;bord=
er-left:1.5pt solid blue;padding:0in 0in 0in 4pt"><div><div style=3D"border=
-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(22=
5,225,225);padding:3pt 0in 0in"><p class=3D"MsoNormal"><b>From:</b> <a rel=
=3D"nofollow">hamza...@me.com</a> &lt;<a rel=3D"nofollow">hamza...@me.com</=
a>&gt; <br><span><b>Sent:</b> Monday, April 2, 2018 1:02 PM</span></p></div=
></div><span><p class=3D"MsoNormal">=C2=A0</p><div><p class=3D"MsoNormal">I=
 propose allowing variable declarations in the condition of a ternary expre=
ssion, which would allow code such as:</p><div><div style=3D"border:1pt sol=
id rgb(187,187,187);padding:0in;word-wrap:break-word"><div><p class=3D"MsoN=
ormal" style=3D"background:rgb(250,250,250)"><span><span style=3D"font-size=
:10pt;font-family:&quot;Courier New&quot;;color:rgb(0,0,136)">const</span><=
/span><span><span style=3D"font-size:10pt;font-family:&quot;Courier New&quo=
t;;color:black"> </span></span><span><span style=3D"font-size:10pt;font-fam=
ily:&quot;Courier New&quot;;color:rgb(0,0,136)">int</span></span><span><spa=
n style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:black">=
 i </span></span><span><span style=3D"font-size:10pt;font-family:&quot;Cour=
ier New&quot;;color:rgb(102,102,0)">=3D</span></span><span><span style=3D"f=
ont-size:10pt;font-family:&quot;Courier New&quot;;color:black"> </span></sp=
an><span><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;=
color:rgb(102,102,0)">(</span></span><span><span style=3D"font-size:10pt;fo=
nt-family:&quot;Courier New&quot;;color:rgb(0,0,136)">const</span></span><s=
pan><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color=
:black"> </span></span><span><span style=3D"font-size:10pt;font-family:&quo=
t;Courier New&quot;;color:rgb(102,0,102)">MyType</span></span><span><span s=
tyle=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(102,10=
2,0)">*</span></span><span><span style=3D"font-size:10pt;font-family:&quot;=
Courier New&quot;;color:black"> x </span></span><span><span style=3D"font-s=
ize:10pt;font-family:&quot;Courier New&quot;;color:rgb(102,102,0)">=3D</spa=
n></span><span><span style=3D"font-size:10pt;font-family:&quot;Courier New&=
quot;;color:black"> something</span></span><span><span style=3D"font-size:1=
0pt;font-family:&quot;Courier New&quot;;color:rgb(102,102,0)">())</span></s=
pan><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color=
:black"><br><span>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 <=
/span></span><span><span style=3D"font-size:10pt;font-family:&quot;Courier =
New&quot;;color:rgb(102,102,0)">?</span></span><span><span style=3D"font-si=
ze:10pt;font-family:&quot;Courier New&quot;;color:black"> x</span></span><s=
pan><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color=
:rgb(102,102,0)">-&gt;</span></span><span><span style=3D"font-size:10pt;fon=
t-family:&quot;Courier New&quot;;color:black">get_int</span></span><span><s=
pan style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(1=
02,102,0)">()</span></span><span style=3D"font-size:10pt;font-family:&quot;=
Courier New&quot;;color:black"><br><span>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 </span></span><span><span style=3D"font-size:10pt;fon=
t-family:&quot;Courier New&quot;;color:rgb(102,102,0)">:</span></span><span=
><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:bl=
ack"> </span></span><span><span style=3D"font-size:10pt;font-family:&quot;C=
ourier New&quot;;color:rgb(0,102,102)">1234</span></span><span><span style=
=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(102,102,0)=
">;</span></span><span style=3D"font-size:10pt;font-family:&quot;Courier Ne=
w&quot;"></span></p></div></div><p class=3D"MsoNormal">In this case the &qu=
ot;something&quot; function may have side effects, so you can&#39;t repeat =
it multiple times in the expression without changing its meaning.</p></div>=
</div><p class=3D"MsoNormal">=C2=A0</p></span></div></div></div></blockquot=
e></div></span><span><span class=3D"gmail-">

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br></span>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<br></span><span class=3D"gmail-">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-pr=
oposals<wbr>/3cdd7b2c-3716-4a58-8a13-<wbr>3f65fb2eae22%40isocpp.org</a>.<br=
>
</span></blockquote></div><br></div>
</blockquote></div><span class=3D"gmail-">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9fabc312-9500-4b34-9a4a-a2793891c585%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/9fab=
c312-9500-4b34-<wbr>9a4a-a2793891c585%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></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/CALvx3hbdffFk56rX5AdDPZA18PjpyUdKjpZX=
84C9JN5kaiBkRg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hbdffFk56rX=
5AdDPZA18PjpyUdKjpZX84C9JN5kaiBkRg%40mail.gmail.com</a>.<br />

--0000000000002406030568e4476a--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Mon, 2 Apr 2018 23:58:32 +0200
Raw View
--001a113ed642e74f8a0568e4b0f2
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Or with a little more boilerplate...

int main()
{
    auto i =3D from(something()).maybe(get_int()).otherwise(1234);
    return i;
}


.... although this is crying out for otherwise() and maybe()'s return type
to be lifted into function objects a-la Haskel/boost::hana etc.


Anyway, here's a first cut of the boilerplate. It's a shame that
std::variant forces the exception handling code into play...

#include <utility>
#include <type_traits>
#include <variant>

struct MyType {
    int get_int();
};

extern MyType* something();

struct get_int
{
    template<class T>
    auto operator()(T* p) const
    {
        return p->get_int();
    }

    template<class T>
    auto operator()(T&& r) const
    {
        return r.get_int();
    }
};

struct nothing_type {};

template<class... Ts> struct overloaded : Ts... { using Ts::operator()...;
};
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;

template<class T>
struct maybe_result
{
    using vtype =3D std::variant<nothing_type, T>;
    constexpr maybe_result() : store(nothing_type()) {}
    constexpr maybe_result(T x) : store(x) {}

    constexpr T otherwise(T x) const
    {
        return std::visit(overloaded{
            [](T const& x) { return x; },
            [&x] (nothing_type const&) { return x; }
        }, store);

    }

    vtype store;
};

template<class T>
struct from
{
    constexpr from(T* ptr) : ptr(ptr)
    {}


    template<class Action>
    constexpr auto maybe(Action action)
    {
        using result_type =3D decltype(action(std::declval<T*>()));
        using maybe_result_type =3D maybe_result<result_type>;
        if (ptr)
        {
            return maybe_result_type(action(ptr));
        }
        else
        {
            return maybe_result_type();
        }
    }

    T* ptr;
};

int main()
{

    auto i =3D from(something()).maybe(get_int()).otherwise(1234);

    return i;
}


On 2 April 2018 at 23:28, Richard Hodges <hodges.r@gmail.com> wrote:

> > Nice solution, but that doesn=E2=80=99t work in the first case where =
=E2=80=9Csomething=E2=80=9D
> might return a nullptr.
>
> You are right, but I am sure you would have no problem writing a wrapper
> function for the pointer access.
>
> For example:
>
> #include <utility>
>
> struct MyType {
>     int get_int();
> };
>
> extern MyType* something();
>
> struct from_type {};
> constexpr auto from =3D from_type();
>
> struct get_int
> {
>     template<class T>
>     auto operator()(T* p) const
>     {
>         return p->get_int();
>     }
>
> };
>
> template<class F, class T>
> struct either
> {
>     using result_type =3D decltype(std::declval<F>()(std::declval<T*>()))=
;
>
>     constexpr either(F f, from_type, T* ptr) : f(f) , ptr(ptr)
>     {}
>
>     auto otherwise(result_type y) const -> result_type {
>         return ptr ? f(ptr) : y;
>     }
>     F f;
>     T* ptr;
> };
>
> int main()
> {
>
>     auto i =3D either(get_int(), from, something()).otherwise(1234);
>
>     return i;
> }
>
>
> On 2 April 2018 at 21:20, <hamza_sood@me.com> wrote:
>
>> Nice solution, but that doesn=E2=80=99t work in the first case where =E2=
=80=9Csomething=E2=80=9D
>> might return a nullptr.
>>
>> On Monday, April 2, 2018 at 8:09:59 PM UTC+1, Richard Hodges wrote:
>>>
>>> Here's another way to express the intent:
>>>
>>>     auto i =3D either(something()->get_int())
>>>             .otherwise(1234);
>>>
>>>
>>>
>>> And here's some trivial boilerplate:
>>>
>>>
>>> #include <utility>
>>>
>>> struct MyType {
>>>     int get_int();
>>> };
>>>
>>> extern MyType* something();
>>>
>>> struct not_zero
>>> {
>>>     template<class T>
>>>     bool operator()(T&& x) const { return x !=3D T(0); }
>>> };
>>>
>>> template<class T, class Pred =3D not_zero>
>>> struct either
>>> {
>>>     either(T x, Pred p =3D Pred()) : value(x), pred(p) {}
>>>
>>>     T otherwise(T y) const {
>>>         return pred(value) ? value : y;
>>>     }
>>>
>>>     T value;
>>>     Pred pred;
>>> };
>>>
>>> //template<class T> either(T x) -> either<T, is_zero>;
>>>
>>> int main()
>>> {
>>>
>>>     auto i =3D either(something()->get_int())
>>>             .otherwise(1234);
>>>     return i;
>>> }
>>>
>>>
>>> On 2 April 2018 at 20:52, <hamza...@me.com> wrote:
>>>
>>>> I don=E2=80=99t quite follow your argument here. Are you trying to say=
 that we
>>>> don=E2=80=99t need ternaries anymore because we have lambdas? If so th=
en I
>>>> completely disagree. Ternaries are a direct expression of intent: set =
a
>>>> value based on a condition. A lambda could be anything and is much les=
s
>>>> clear, especially since the actual invoking of it happens right at the=
 end
>>>> and so is easily missed (at a glance, that looks like you=E2=80=99re a=
ssigning a
>>>> lambda and not an int).
>>>>
>>>> On Monday, April 2, 2018 at 7:39:03 PM UTC+1, Zhihao Yuan wrote:
>>>>>
>>>>>   auto I =3D [&] {
>>>>>
>>>>> if (auto x =3D something())
>>>>>
>>>>>   return x->get_int();
>>>>>
>>>>> else
>>>>>
>>>>>   return 1234;
>>>>>
>>>>> }();
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Zhihao Yuan, ID lichray
>>>>> The best way to predict the future is to invent it.
>>>>> _______________________________________________
>>>>>
>>>>>
>>>>>
>>>>> *From:* hamza...@me.com <hamza...@me.com>
>>>>> *Sent:* Monday, April 2, 2018 1:02 PM
>>>>>
>>>>>
>>>>>
>>>>> I propose allowing variable declarations in the condition of a ternar=
y
>>>>> expression, which would allow code such as:
>>>>>
>>>>> const int i =3D (const MyType* x =3D something())
>>>>>                 ? x->get_int()
>>>>>                 : 1234;
>>>>>
>>>>> In this case the "something" function may have side effects, so you
>>>>> can't repeat it multiple times in the expression without changing its
>>>>> meaning.
>>>>>
>>>>>
>>>>>
>>>> --
>>>> 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-proposal...@isocpp.org.
>>>> To post to this group, send email to std-pr...@isocpp.org.
>>>> To view this discussion on the web visit https://groups.google.com/a/i=
s
>>>> ocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-3f65f
>>>> b2eae22%40isocpp.org
>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c=
-3716-4a58-8a13-3f65fb2eae22%40isocpp.org?utm_medium=3Demail&utm_source=3Df=
ooter>
>>>> .
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/9fabc312-9500-4b34-9a4a-
>> a2793891c585%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/9fabc312-9=
500-4b34-9a4a-a2793891c585%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
>

--=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/CALvx3hYbzDwMFc5VnS5Da4G-WT7QB%2BP0H2oQ9ZG3eXAyV=
36ocw%40mail.gmail.com.

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

<div dir=3D"ltr">Or with a little more boilerplate...<div><br></div><div><d=
iv style=3D"color:rgb(0,0,0);background-color:rgb(255,255,254)"><div><font =
face=3D"monospace, monospace"><span style=3D"color:rgb(0,0,255)">int</span>=
<span style=3D"color:rgb(0,0,0)"> main()</span></font></div><div><span styl=
e=3D"color:rgb(0,0,0)"><font face=3D"monospace, monospace">{</font></span><=
/div><div><font face=3D"monospace, monospace"><span style=3D"color:rgb(0,0,=
255)">=C2=A0 =C2=A0 auto</span><span style=3D"color:rgb(0,0,0)"> i =3D from=
(something()).maybe(get_int()).otherwise(</span><span style=3D"color:rgb(9,=
136,90)">1234</span><span style=3D"color:rgb(0,0,0)">);</span></font></div>=
<div><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, monospace"> =
   </font></span></div><div><font face=3D"monospace, monospace"><span style=
=3D"color:rgb(0,0,0)"></span><span style=3D"color:rgb(0,0,255)">=C2=A0 =C2=
=A0 return</span><span style=3D"color:rgb(0,0,0)"> i;</span></font></div><d=
iv><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, monospace">}</=
font></span></div><br></div><br></div><div>... although this is crying out =
for otherwise() and maybe()&#39;s return type to be lifted into function ob=
jects a-la Haskel/boost::hana etc.<br><br><br></div><div>Anyway, here&#39;s=
 a first cut of the boilerplate. It&#39;s a shame that std::variant forces =
the exception handling code into play...<br><br><div><font face=3D"monospac=
e, monospace">#include &lt;utility&gt;</font></div><div><font face=3D"monos=
pace, monospace">#include &lt;type_traits&gt;</font></div><div><font face=
=3D"monospace, monospace">#include &lt;variant&gt;</font></div><div><font f=
ace=3D"monospace, monospace"><br></font></div><div><font face=3D"monospace,=
 monospace">struct MyType {</font></div><div><font face=3D"monospace, monos=
pace">=C2=A0 =C2=A0 int get_int();</font></div><div><font face=3D"monospace=
, monospace">};</font></div><div><font face=3D"monospace, monospace"><br></=
font></div><div><font face=3D"monospace, monospace">extern MyType* somethin=
g();</font></div><div><font face=3D"monospace, monospace"><br></font></div>=
<div><font face=3D"monospace, monospace">struct get_int</font></div><div><f=
ont face=3D"monospace, monospace">{</font></div><div><font face=3D"monospac=
e, monospace">=C2=A0 =C2=A0 template&lt;class T&gt;</font></div><div><font =
face=3D"monospace, monospace">=C2=A0 =C2=A0 auto operator()(T* p) const</fo=
nt></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 {</font></d=
iv><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 ret=
urn p-&gt;get_int();</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0 }</font></div><div><font face=3D"monospace, monospace"><br></=
font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 template&=
lt;class T&gt;</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 auto operator()(T&amp;&amp; r) const</font></div><div><font face=3D"=
monospace, monospace">=C2=A0 =C2=A0 {</font></div><div><font face=3D"monosp=
ace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return r.get_int();</font></div=
><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 }</font></div><div>=
<font face=3D"monospace, monospace">};</font></div><div><font face=3D"monos=
pace, monospace"><br></font></div><div><font face=3D"monospace, monospace">=
struct nothing_type {};</font></div><div><font face=3D"monospace, monospace=
"><br></font></div><div><font face=3D"monospace, monospace">template&lt;cla=
ss... Ts&gt; struct overloaded : Ts... { using Ts::operator()...; };</font>=
</div><div><font face=3D"monospace, monospace">template&lt;class... Ts&gt; =
overloaded(Ts...) -&gt; overloaded&lt;Ts...&gt;;</font></div><div><font fac=
e=3D"monospace, monospace"><br></font></div><div><font face=3D"monospace, m=
onospace">template&lt;class T&gt;</font></div><div><font face=3D"monospace,=
 monospace">struct maybe_result</font></div><div><font face=3D"monospace, m=
onospace">{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 using vtype =3D std::variant&lt;nothing_type, T&gt;;</font></div><div><=
font face=3D"monospace, monospace">=C2=A0 =C2=A0 constexpr maybe_result() :=
 store(nothing_type()) {}</font></div><div><font face=3D"monospace, monospa=
ce">=C2=A0 =C2=A0 constexpr maybe_result(T x) : store(x) {}</font></div><di=
v><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"m=
onospace, monospace">=C2=A0 =C2=A0 constexpr T otherwise(T x) const</font><=
/div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 {</font></div><=
div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return =
std::visit(overloaded{</font></div><div><font face=3D"monospace, monospace"=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [](T const&amp; x) { return x; }=
,</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 [&amp;x] (nothing_type const&amp;) { return x; }</fon=
t></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 }, store);</font></div><div><font face=3D"monospace, monospace"><br></f=
ont></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 }</font></=
div><div><font face=3D"monospace, monospace"><br></font></div><div><font fa=
ce=3D"monospace, monospace">=C2=A0 =C2=A0 vtype store;</font></div><div><fo=
nt face=3D"monospace, monospace">};</font></div><div><font face=3D"monospac=
e, monospace"><br></font></div><div><font face=3D"monospace, monospace">tem=
plate&lt;class T&gt;=C2=A0</font></div><div><font face=3D"monospace, monosp=
ace">struct from</font></div><div><font face=3D"monospace, monospace">{</fo=
nt></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 constexpr f=
rom(T* ptr) : ptr(ptr)</font></div><div><font face=3D"monospace, monospace"=
>=C2=A0 =C2=A0 {}</font></div><div><font face=3D"monospace, monospace"><br>=
</font></div><div><font face=3D"monospace, monospace"><br></font></div><div=
><font face=3D"monospace, monospace">=C2=A0 =C2=A0 template&lt;class Action=
&gt;</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 con=
stexpr auto maybe(Action action)=C2=A0</font></div><div><font face=3D"monos=
pace, monospace">=C2=A0 =C2=A0 {</font></div><div><font face=3D"monospace, =
monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 using result_type =3D decltype(actio=
n(std::declval&lt;T*&gt;()));</font></div><div><font face=3D"monospace, mon=
ospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 using maybe_result_type =3D maybe_resul=
t&lt;result_type&gt;;</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (ptr)</font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 {</font></div><div><font face=3D=
"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return may=
be_result_type(action(ptr));</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 else</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 {</font></div><div><f=
ont face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 return maybe_result_type();</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 =C2=A0 }</font></div><div><font face=3D"monospace, mo=
nospace"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 T* ptr;</font></div><div><font face=3D"monospace, monospace">};</fon=
t></div><div><font face=3D"monospace, monospace"><br></font></div><div><fon=
t face=3D"monospace, monospace">int main()</font></div><div><font face=3D"m=
onospace, monospace">{</font></div><div><font face=3D"monospace, monospace"=
><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 au=
to i =3D from(something()).maybe(get_int()).otherwise(1234);</font></div><d=
iv><font face=3D"monospace, monospace">=C2=A0 =C2=A0=C2=A0</font></div><div=
><font face=3D"monospace, monospace">=C2=A0 =C2=A0 return i;</font></div><d=
iv><font face=3D"monospace, monospace">}</font></div>=C2=A0</div></div><div=
 class=3D"gmail_extra"><br><div class=3D"gmail_quote">On 2 April 2018 at 23=
:28, Richard Hodges <span dir=3D"ltr">&lt;<a href=3D"mailto:hodges.r@gmail.=
com" target=3D"_blank">hodges.r@gmail.com</a>&gt;</span> wrote:<br><blockqu=
ote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr"><span class=3D"">&gt; Nice solution=
, but that doesn=E2=80=99t work in the first case where =E2=80=9Csomething=
=E2=80=9D might return a nullptr.<div><br></div></span><div>You are right, =
but I am sure you would have no problem writing a wrapper function for the =
pointer access.=C2=A0</div><div><br></div><div>For example:<br></div><div><=
br></div><div><span class=3D""><div><font face=3D"monospace, monospace">#in=
clude &lt;utility&gt;</font></div><div><font face=3D"monospace, monospace">=
<br></font></div><div><font face=3D"monospace, monospace">struct MyType {</=
font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 int get_i=
nt();</font></div><div><font face=3D"monospace, monospace">};</font></div><=
div><font face=3D"monospace, monospace"><br></font></div><div><font face=3D=
"monospace, monospace">extern MyType* something();</font></div><div><font f=
ace=3D"monospace, monospace"><br></font></div></span><div><font face=3D"mon=
ospace, monospace">struct from_type {};</font></div><div><font face=3D"mono=
space, monospace">constexpr auto from =3D from_type();</font></div><div><fo=
nt face=3D"monospace, monospace"><br></font></div><div><font face=3D"monosp=
ace, monospace">struct get_int</font></div><div><font face=3D"monospace, mo=
nospace">{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 template&lt;class T&gt;</font></div><div><font face=3D"monospace, monos=
pace">=C2=A0 =C2=A0 auto operator()(T* p) const</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0 {</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return p-&gt;get_int();</fo=
nt></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 }</font></d=
iv><div><font face=3D"monospace, monospace"><br></font></div><div><font fac=
e=3D"monospace, monospace">};</font></div><div><font face=3D"monospace, mon=
ospace"><br></font></div><div><font face=3D"monospace, monospace">template&=
lt;class F, class T&gt;=C2=A0</font></div><div><font face=3D"monospace, mon=
ospace">struct either</font></div><div><font face=3D"monospace, monospace">=
{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 using =
result_type =3D decltype(std::declval&lt;F&gt;()(<wbr>std::declval&lt;T*&gt=
;()));</font></div><div><font face=3D"monospace, monospace"><br></font></di=
v><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 constexpr either(F=
 f, from_type, T* ptr) : f(f) , ptr(ptr)</font></div><div><font face=3D"mon=
ospace, monospace">=C2=A0 =C2=A0 {}</font></div><div><font face=3D"monospac=
e, monospace"><br></font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 auto otherwise(result_type y) const -&gt; result_type {</font></=
div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 re=
turn ptr ? f(ptr) : y;</font></div><div><font face=3D"monospace, monospace"=
>=C2=A0 =C2=A0 }</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 F f;</font></div><div><font face=3D"monospace, monospace">=C2=A0=
 =C2=A0 T* ptr;</font></div><div><font face=3D"monospace, monospace">};</fo=
nt></div><div><font face=3D"monospace, monospace"><br></font></div><div><fo=
nt face=3D"monospace, monospace">int main()</font></div><div><font face=3D"=
monospace, monospace">{</font></div><div><font face=3D"monospace, monospace=
"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 a=
uto i =3D either(get_int(), from, something()).otherwise(1234);</font></div=
><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0=C2=A0</font></div><=
div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 return i;</font></div=
><div><font face=3D"monospace, monospace">}</font></div></div><div><div cla=
ss=3D"h5"><div><br></div><div><br></div><div><div class=3D"gmail_extra"><di=
v class=3D"gmail_quote">On 2 April 2018 at 21:20,  <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:hamza_sood@me.com" target=3D"_blank">hamza_sood@me.com</a>&=
gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div=
 dir=3D"ltr">Nice solution, but that doesn=E2=80=99t work in the first case=
 where =E2=80=9Csomething=E2=80=9D might return a nullptr.<span class=3D"m_=
5367944730924292255gmail-"><br><br>On Monday, April 2, 2018 at 8:09:59 PM U=
TC+1, Richard Hodges wrote:</span><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><span class=3D"m_5367944730924292255gmail-"><div dir=3D"ltr">Her=
e&#39;s another way to express the intent:<div><br></div><div><div style=3D=
"color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-styl=
e:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent=
:0px;text-transform:none;white-space:normal;word-spacing:0px;background-col=
or:rgb(255,255,255)"><font face=3D"monospace, monospace">=C2=A0 =C2=A0 auto=
 i =3D either(something()-&gt;get_int())</font></div><div style=3D"color:rg=
b(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;=
font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text=
-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(25=
5,255,255)"><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 .otherwise(1234);</font></div><br><br></div><div><br></div><=
div>And here&#39;s some trivial boilerplate:</div><div><br><div><br></div><=
div><div><font face=3D"monospace, monospace">#include &lt;utility&gt;</font=
></div><div><font face=3D"monospace, monospace"><br></font></div><div><font=
 face=3D"monospace, monospace">struct MyType {</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0 int get_int();</font></div><div><fo=
nt face=3D"monospace, monospace">};</font></div><div><font face=3D"monospac=
e, monospace"><br></font></div><div><font face=3D"monospace, monospace">ext=
ern MyType* something();</font></div><div><font face=3D"monospace, monospac=
e"><br></font></div><div><font face=3D"monospace, monospace">struct not_zer=
o</font></div><div><font face=3D"monospace, monospace">{</font></div><div><=
font face=3D"monospace, monospace">=C2=A0 =C2=A0 template&lt;class T&gt;</f=
ont></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 bool opera=
tor()(T&amp;&amp; x) const { return x !=3D T(0); }</font></div><div><font f=
ace=3D"monospace, monospace">};</font></div><div><font face=3D"monospace, m=
onospace"><br></font></div><div><font face=3D"monospace, monospace">templat=
e&lt;class T, class Pred =3D not_zero&gt;</font></div><div><font face=3D"mo=
nospace, monospace">struct either</font></div><div><font face=3D"monospace,=
 monospace">{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 either(T x, Pred p =3D Pred()) : value(x), pred(p) {}</font></div><d=
iv><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"=
monospace, monospace">=C2=A0 =C2=A0 T otherwise(T y) const {</font></div><d=
iv><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 return p=
red(value) ? value : y;</font></div><div><font face=3D"monospace, monospace=
">=C2=A0 =C2=A0 }</font></div><div><font face=3D"monospace, monospace"><br>=
</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 T value=
;</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 Pred p=
red;</font></div><div><font face=3D"monospace, monospace">};</font></div><d=
iv><font face=3D"monospace, monospace"><br></font></div><div><font face=3D"=
monospace, monospace">//template&lt;class T&gt; either(T x) -&gt; either&lt=
;T, is_zero&gt;;</font></div><div><font face=3D"monospace, monospace"><br><=
/font></div><div><font face=3D"monospace, monospace">int main()</font></div=
><div><font face=3D"monospace, monospace">{</font></div><div><font face=3D"=
monospace, monospace"><br></font></div><div><font face=3D"monospace, monosp=
ace">=C2=A0 =C2=A0 auto i =3D either(something()-&gt;get_int())</font></div=
><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 .otherwise(1234);</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 =C2=A0 return i;</font></div><div><font face=3D"monospace, mo=
nospace">}</font></div></div><div><br></div></div></div></span><div><br><di=
v class=3D"gmail_quote"><span class=3D"m_5367944730924292255gmail-">On 2 Ap=
ril 2018 at 20:52,  <span dir=3D"ltr">&lt;<a rel=3D"nofollow">hamza...@me.c=
om</a>&gt;</span> wrote:<br></span><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><span class=3D"m_5367944730924292255gmail-"><div dir=3D"ltr">I d=
on=E2=80=99t quite follow your argument here. Are you trying to say that we=
 don=E2=80=99t need ternaries anymore because we have lambdas? If so then I=
 completely disagree. Ternaries are a direct expression of intent: set a va=
lue based on a condition. A lambda could be anything and is much less clear=
, especially since the actual invoking of it happens right at the end and s=
o is easily missed (at a glance, that looks like you=E2=80=99re assigning a=
 lambda and not an int).<span><br><br>On Monday, April 2, 2018 at 7:39:03 P=
M UTC+1, Zhihao Yuan wrote:</span><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex"><div><div><span><p class=3D"MsoNormal">=C2=A0 auto I =3D [&amp;]=
 {</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">if (auto x =3D s=
omething())</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">=C2=A0 =
return x-&gt;get_int();</p><p class=3D"MsoNormal" style=3D"text-indent:10.1=
5pt">else</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">=C2=A0 re=
turn 1234;</p><p class=3D"MsoNormal" style=3D"text-indent:10.15pt">}();</p>=
<p class=3D"MsoNormal">=C2=A0</p><p class=3D"MsoNormal">--</p><p class=3D"M=
soNormal">Zhihao Yuan, ID lichray<br>The best way to predict the future is =
to invent it.<br>______________________________<wbr>_________________</p><p=
 class=3D"MsoNormal">=C2=A0</p></span><div style=3D"border-top:none;border-=
right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in =
0in 4pt"><div><div style=3D"border-right:none;border-bottom:none;border-lef=
t:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in"><p class=
=3D"MsoNormal"><b>From:</b> <a rel=3D"nofollow">hamza...@me.com</a> &lt;<a =
rel=3D"nofollow">hamza...@me.com</a>&gt; <br><span><b>Sent:</b> Monday, Apr=
il 2, 2018 1:02 PM</span></p></div></div><span><p class=3D"MsoNormal">=C2=
=A0</p><div><p class=3D"MsoNormal">I propose allowing variable declarations=
 in the condition of a ternary expression, which would allow code such as:<=
/p><div><div style=3D"border:1pt solid rgb(187,187,187);padding:0in;word-wr=
ap:break-word"><div><p class=3D"MsoNormal" style=3D"background:rgb(250,250,=
250)"><span><span style=3D"font-size:10pt;font-family:&quot;Courier New&quo=
t;;color:rgb(0,0,136)">const</span></span><span><span style=3D"font-size:10=
pt;font-family:&quot;Courier New&quot;;color:black"> </span></span><span><s=
pan style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(0=
,0,136)">int</span></span><span><span style=3D"font-size:10pt;font-family:&=
quot;Courier New&quot;;color:black"> i </span></span><span><span style=3D"f=
ont-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(102,102,0)">=3D=
</span></span><span><span style=3D"font-size:10pt;font-family:&quot;Courier=
 New&quot;;color:black"> </span></span><span><span style=3D"font-size:10pt;=
font-family:&quot;Courier New&quot;;color:rgb(102,102,0)">(</span></span><s=
pan><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color=
:rgb(0,0,136)">const</span></span><span><span style=3D"font-size:10pt;font-=
family:&quot;Courier New&quot;;color:black"> </span></span><span><span styl=
e=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(102,0,102=
)">MyType</span></span><span><span style=3D"font-size:10pt;font-family:&quo=
t;Courier New&quot;;color:rgb(102,102,0)">*</span></span><span><span style=
=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:black"> x </sp=
an></span><span><span style=3D"font-size:10pt;font-family:&quot;Courier New=
&quot;;color:rgb(102,102,0)">=3D</span></span><span><span style=3D"font-siz=
e:10pt;font-family:&quot;Courier New&quot;;color:black"> something</span></=
span><span><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot=
;;color:rgb(102,102,0)">())</span></span><span style=3D"font-size:10pt;font=
-family:&quot;Courier New&quot;;color:black"><br><span>=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></span><span><span style=3D"font=
-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(102,102,0)">?</spa=
n></span><span><span style=3D"font-size:10pt;font-family:&quot;Courier New&=
quot;;color:black"> x</span></span><span><span style=3D"font-size:10pt;font=
-family:&quot;Courier New&quot;;color:rgb(102,102,0)">-&gt;</span></span><s=
pan><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color=
:black">get_int</span></span><span><span style=3D"font-size:10pt;font-famil=
y:&quot;Courier New&quot;;color:rgb(102,102,0)">()</span></span><span style=
=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:black"><br><sp=
an>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span></span><s=
pan><span style=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color=
:rgb(102,102,0)">:</span></span><span><span style=3D"font-size:10pt;font-fa=
mily:&quot;Courier New&quot;;color:black"> </span></span><span><span style=
=3D"font-size:10pt;font-family:&quot;Courier New&quot;;color:rgb(0,102,102)=
">1234</span></span><span><span style=3D"font-size:10pt;font-family:&quot;C=
ourier New&quot;;color:rgb(102,102,0)">;</span></span><span style=3D"font-s=
ize:10pt;font-family:&quot;Courier New&quot;"></span></p></div></div><p cla=
ss=3D"MsoNormal">In this case the &quot;something&quot; function may have s=
ide effects, so you can&#39;t repeat it multiple times in the expression wi=
thout changing its meaning.</p></div></div><p class=3D"MsoNormal">=C2=A0</p=
></span></div></div></div></blockquote></div></span><span><span class=3D"m_=
5367944730924292255gmail-">

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br></span>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">std-pr...@isocpp.o=
rg</a>.<br></span><span class=3D"m_5367944730924292255gmail-">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/3cdd7b2c-3716-4a58-8a13-3f65fb2eae22%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" rel=3D"nofollow" t=
arget=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-pr=
oposals<wbr>/3cdd7b2c-3716-4a58-8a13-3f65f<wbr>b2eae22%40isocpp.org</a>.<br=
>
</span></blockquote></div><br></div>
</blockquote></div><span class=3D"m_5367944730924292255gmail-">

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9fabc312-9500-4b34-9a4a-a2793891c585%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/9fab=
c312-9500-4b34-9a4a-<wbr>a2793891c585%40isocpp.org</a>.<br>
</blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></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/CALvx3hYbzDwMFc5VnS5Da4G-WT7QB%2BP0H2=
oQ9ZG3eXAyV36ocw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbzDwMFc=
5VnS5Da4G-WT7QB%2BP0H2oQ9ZG3eXAyV36ocw%40mail.gmail.com</a>.<br />

--001a113ed642e74f8a0568e4b0f2--

.


Author: hamza_sood@me.com
Date: Tue, 3 Apr 2018 07:26:11 -0700 (PDT)
Raw View
------=_Part_21563_951908904.1522765571275
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Again, that=E2=80=99s a very cool use of templates but it only solves this =
particular example. What about if you want to call a free function on the r=
esult instead of a member functions? Or maybe the result is an int that you=
 want to perform some operation on? While I=E2=80=99m sure you could come u=
p with individual solutions for each of those, a slightly modified ternary =
operator would solve them all without the need for lots of per-case boilerp=
late. Do you have any specific objections about the proposal?

Regarding motivation: the GCC extension is seen as very useful to many and =
has previously been proposed for standardisation, but I believe it was reje=
cted because they didn=E2=80=99t want to introduce a whole new operator for=
 it. This proposal allows for a similar effect (and more) with only a small=
 change to an existing operator, which could be better received.

--=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/d772dfc9-cd4e-45fa-87e3-9b91551cfdb5%40isocpp.or=
g.

------=_Part_21563_951908904.1522765571275--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Tue, 3 Apr 2018 15:42:07 +0100
Raw View
--000000000000f750440568f2b582
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

> Do you have any specific objections about the proposal?

No. I'm a fan of shorthand notations, but then people think I'm weird
because I like perl.

> This proposal allows for a similar effect (and more) with only a small
change to an existing operator, which could be better received.

This is perhaps true. From what I've read the risk might be that it gets
pushed back because it's essentially doing nothing more than introducing
some shorthand, as opposed to new functionality that was previously
difficult or unwieldy.

Specifically, it might be argued that although the following example
requires a few more keystrokes, it is already clear and maintainable in
c++17:


auto as_opt =3D [](auto p)
{
  std::optional<int> result;
  if (p)
    result =3D p->get_int();
  return result;
};

auto i =3D as_opt(something()).value_or(1234);

Having said that, nothing ventured, nothing gained.

R

On 3 April 2018 at 15:26, <hamza_sood@me.com> wrote:

> Again, that=E2=80=99s a very cool use of templates but it only solves thi=
s
> particular example. What about if you want to call a free function on the
> result instead of a member functions? Or maybe the result is an int that
> you want to perform some operation on? While I=E2=80=99m sure you could c=
ome up
> with individual solutions for each of those, a slightly modified ternary
> operator would solve them all without the need for lots of per-case
> boilerplate. Do you have any specific objections about the proposal?
>
> Regarding motivation: the GCC extension is seen as very useful to many an=
d
> has previously been proposed for standardisation, but I believe it was
> rejected because they didn=E2=80=99t want to introduce a whole new operat=
or for it.
> This proposal allows for a similar effect (and more) with only a small
> change to an existing operator, which could be better received.
>
> --
> 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/d772dfc9-cd4e-45fa-
> 87e3-9b91551cfdb5%40isocpp.org.
>

--=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/CALvx3hbw%2BnwB0iKdu0p%2BDqNcT2eTrz2gTb5pHzrf-%3=
DVcjiSBow%40mail.gmail.com.

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

<div dir=3D"ltr">&gt;=C2=A0<span style=3D"color:rgb(34,34,34);font-family:a=
rial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:no=
rmal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-al=
ign:start;text-indent:0px;text-transform:none;white-space:normal;word-spaci=
ng:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text=
-decoration-color:initial;float:none;display:inline">Do you have any specif=
ic objections about the proposal?</span><br style=3D"color:rgb(34,34,34);fo=
nt-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-l=
igatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:nor=
mal;text-align:start;text-indent:0px;text-transform:none;white-space:normal=
;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:i=
nitial;text-decoration-color:initial"><br>No. I&#39;m a fan of shorthand no=
tations, but then people think I&#39;m weird because I like perl.=C2=A0<div=
><br></div><div>&gt;=C2=A0<span style=3D"color:rgb(34,34,34);font-family:ar=
ial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:nor=
mal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-ali=
gn:start;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-=
decoration-color:initial;float:none;display:inline">This proposal allows fo=
r a similar effect (and more) with only a small change to an existing opera=
tor, which could be better received.</span></div><div><span style=3D"color:=
rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:norma=
l;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;le=
tter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;wh=
ite-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-de=
coration-style:initial;text-decoration-color:initial;float:none;display:inl=
ine"><br></span></div><div><span style=3D"color:rgb(34,34,34);font-family:a=
rial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:no=
rmal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-al=
ign:start;text-indent:0px;text-transform:none;white-space:normal;word-spaci=
ng:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text=
-decoration-color:initial;float:none;display:inline">This is perhaps true. =
From what I&#39;ve read the risk might be that it gets pushed back because =
it&#39;s essentially doing nothing more than introducing some shorthand, as=
 opposed to new functionality that was previously difficult or unwieldy.</s=
pan></div><div><span style=3D"color:rgb(34,34,34);font-family:arial,sans-se=
rif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-va=
riant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;te=
xt-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;backg=
round-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-=
color:initial;float:none;display:inline"><br></span></div><div><span style=
=3D"color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-s=
tyle:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-wei=
ght:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transfo=
rm:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,25=
5);text-decoration-style:initial;text-decoration-color:initial;float:none;d=
isplay:inline">Specifically, it might be argued that although the following=
 example requires a few more keystrokes, it is already clear=C2=A0and maint=
ainable in c++17:</span></div><div><span style=3D"color:rgb(34,34,34);font-=
family:arial,sans-serif;font-size:small;font-style:normal;font-variant-liga=
tures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal=
;text-align:start;text-indent:0px;text-transform:none;white-space:normal;wo=
rd-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:init=
ial;text-decoration-color:initial;float:none;display:inline"><br></span></d=
iv><div><span style=3D"color:rgb(34,34,34);font-size:small;font-style:norma=
l;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;le=
tter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;wh=
ite-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-de=
coration-style:initial;text-decoration-color:initial;float:none;display:inl=
ine">=C2=A0<div style=3D"color:rgb(0,0,0);background-color:rgb(255,255,254)=
"><div style=3D""><font face=3D"monospace, monospace"><span style=3D"color:=
rgb(0,0,0)">    </span><span style=3D"color:rgb(0,0,255)">auto</span><span =
style=3D"color:rgb(0,0,0)"> as_opt =3D [](</span><span style=3D"color:rgb(0=
,0,255)">auto</span><span style=3D"color:rgb(0,0,0)"> p)</span></font></div=
><div style=3D""><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, =
monospace">    {</font></span></div><div style=3D""><font face=3D"monospace=
, monospace"><span style=3D"color:rgb(0,0,0)">=C2=A0 std::optional&lt;</spa=
n><span style=3D"color:rgb(0,0,255)">int</span><span style=3D"color:rgb(0,0=
,0)">&gt; result;</span></font></div><div style=3D""><font face=3D"monospac=
e, monospace"><span style=3D"color:rgb(0,0,0)"></span><span style=3D"color:=
rgb(0,0,255)">=C2=A0 if</span><span style=3D"color:rgb(0,0,0)"> (p)</span><=
/font></div><div style=3D""><span style=3D"color:rgb(0,0,0)"><font face=3D"=
monospace, monospace">=C2=A0 =C2=A0 result =3D p-&gt;get_int();</font></spa=
n></div><div style=3D""><font face=3D"monospace, monospace"><span style=3D"=
color:rgb(0,0,0)"></span><span style=3D"color:rgb(0,0,255)">=C2=A0 return</=
span><span style=3D"color:rgb(0,0,0)"> result;</span></font></div><div styl=
e=3D""><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, monospace"=
>    };</font></span></div><font face=3D"monospace, monospace"><br></font><=
div style=3D""><font face=3D"monospace, monospace"><span style=3D"color:rgb=
(0,0,0)">     </span><span style=3D"color:rgb(0,0,255)">auto</span><span st=
yle=3D"color:rgb(0,0,0)"> i =3D as_opt(something()).value_or(</span><span s=
tyle=3D"color:rgb(9,136,90)">1234</span><span style=3D"color:rgb(0,0,0)">);=
</span></font></div><div style=3D"font-family:arial,sans-serif"><span style=
=3D"color:rgb(0,0,0)"><br></span></div><div style=3D"font-family:arial,sans=
-serif"><span style=3D"color:rgb(0,0,0)"></span></div></div></span></div><d=
iv>Having said that, nothing ventured, nothing gained.</div><div><br></div>=
<div>R<br><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On 3 Ap=
ril 2018 at 15:26,  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_sood@me.c=
om" target=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrote:<br><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex">Again, that=E2=80=99s a very cool use of templates but=
 it only solves this particular example. What about if you want to call a f=
ree function on the result instead of a member functions? Or maybe the resu=
lt is an int that you want to perform some operation on? While I=E2=80=99m =
sure you could come up with individual solutions for each of those, a sligh=
tly modified ternary operator would solve them all without the need for lot=
s of per-case boilerplate. Do you have any specific objections about the pr=
oposal?<br>
<br>
Regarding motivation: the GCC extension is seen as very useful to many and =
has previously been proposed for standardisation, but I believe it was reje=
cted because they didn=E2=80=99t want to introduce a whole new operator for=
 it. This proposal allows for a similar effect (and more) with only a small=
 change to an existing operator, which could be better received.<br>
<span class=3D""><br>
--<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%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@<wbr>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>
</span>To view this discussion on the web visit <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/d772dfc9-cd4e-45fa-87e3-9b9155=
1cfdb5%40isocpp.org" rel=3D"noreferrer" target=3D"_blank">https://groups.go=
ogle.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/d772dfc9-cd4e-45fa-<w=
br>87e3-9b91551cfdb5%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div></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/CALvx3hbw%2BnwB0iKdu0p%2BDqNcT2eTrz2g=
Tb5pHzrf-%3DVcjiSBow%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hbw%2=
BnwB0iKdu0p%2BDqNcT2eTrz2gTb5pHzrf-%3DVcjiSBow%40mail.gmail.com</a>.<br />

--000000000000f750440568f2b582--

.


Author: hamza_sood@me.com
Date: Tue, 3 Apr 2018 08:06:29 -0700 (PDT)
Raw View
------=_Part_21894_1272398565.1522767989552
Content-Type: multipart/alternative;
 boundary="----=_Part_21895_806979017.1522767989552"

------=_Part_21895_806979017.1522767989552
Content-Type: text/plain; charset="UTF-8"

On Tuesday, April 3, 2018 at 3:42:10 PM UTC+1, Richard Hodges wrote:
>
> This is perhaps true. From what I've read the risk might be that it gets
> pushed back because it's essentially doing nothing more than introducing
> some shorthand, as opposed to new functionality that was previously
> difficult or unwieldy.
>

While that's a good point that's definitely worth keeping in mind, haven't
there been quite a few minor shorthand features accepted recently? The
first one that springs to mind is if statement initialisers
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305r0.html> in
C++17: it didn't really bring any new functionality and it isn't
particularly difficult to write an explicit scope (arguably much simpler
than the lambda-based alternatives to this proposal discussed here). I
don't mean that in a bad way; I love shorthand notation and I'm enjoying
using if statements with initialisers. But I think it makes a good
comparison with this proposal.

--
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/820d844c-21a7-429c-bf55-17ee12f8ca8e%40isocpp.org.

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

<div dir=3D"ltr">On Tuesday, April 3, 2018 at 3:42:10 PM UTC+1, Richard Hod=
ges 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"><di=
v><span style=3D"color:rgb(34,34,34);font-family:arial,sans-serif;font-size=
:small;font-style:normal;font-weight:400;letter-spacing:normal;text-align:s=
tart;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0p=
x;background-color:rgb(255,255,255);float:none;display:inline">This is perh=
aps true. From what I&#39;ve read the risk might be that it gets pushed bac=
k because it&#39;s essentially doing nothing more than introducing some sho=
rthand, as opposed to new functionality that was previously difficult or un=
wieldy.</span></div></div></blockquote><div><br></div><div>While that&#39;s=
 a good point that&#39;s definitely worth keeping in mind, haven&#39;t ther=
e been quite a few minor shorthand features accepted recently? The first on=
e that springs to mind is=C2=A0<a href=3D"http://www.open-std.org/jtc1/sc22=
/wg21/docs/papers/2016/p0305r0.html">if statement initialisers</a> in C++17=
: it didn&#39;t really bring any new functionality and it isn&#39;t particu=
larly difficult to write an explicit scope (arguably much simpler than the =
lambda-based alternatives to this proposal discussed here). I don&#39;t mea=
n that in a bad way; I love shorthand notation and I&#39;m enjoying using i=
f statements with initialisers. But I think it makes a good comparison with=
 this proposal.</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/820d844c-21a7-429c-bf55-17ee12f8ca8e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/820d844c-21a7-429c-bf55-17ee12f8ca8e=
%40isocpp.org</a>.<br />

------=_Part_21895_806979017.1522767989552--

------=_Part_21894_1272398565.1522767989552--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Tue, 3 Apr 2018 20:43:55 +0100
Raw View
--089e08286f0c7ac6890568f6eef0
Content-Type: text/plain; charset="UTF-8"

I think if anything it unifies the conditional operator with if-statements;
however, I'd still prefer if it looked more like the if-statement with
initializer:

(auto x = function(); p(x)) ? z(x) : y(x);

where
- p(x) is a predicate of x (perhaps just an automatic contextual conversion
to bool, if omitted)
- z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning x at
all)

It *does* go further than the gnu extension, in a *far* more useful way.

G

On Tue, Apr 3, 2018 at 4:06 PM, <hamza_sood@me.com> wrote:

> On Tuesday, April 3, 2018 at 3:42:10 PM UTC+1, Richard Hodges wrote:
>>
>> This is perhaps true. From what I've read the risk might be that it gets
>> pushed back because it's essentially doing nothing more than introducing
>> some shorthand, as opposed to new functionality that was previously
>> difficult or unwieldy.
>>
>
> While that's a good point that's definitely worth keeping in mind, haven't
> there been quite a few minor shorthand features accepted recently? The
> first one that springs to mind is if statement initialisers
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305r0.html> in
> C++17: it didn't really bring any new functionality and it isn't
> particularly difficult to write an explicit scope (arguably much simpler
> than the lambda-based alternatives to this proposal discussed here). I
> don't mean that in a bad way; I love shorthand notation and I'm enjoying
> using if statements with initialisers. But I think it makes a good
> comparison with this proposal.
>
> --
> 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/820d844c-21a7-429c-
> bf55-17ee12f8ca8e%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/820d844c-21a7-429c-bf55-17ee12f8ca8e%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/CAANG%3DkX5nk%3DtVyY1fvzFppy8XEcqxMTtAh_PMSGHHiE%3DcgXQZw%40mail.gmail.com.

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

<div dir=3D"ltr">I think if anything it unifies the conditional operator wi=
th if-statements; however, I&#39;d still prefer if it looked more like the =
if-statement with initializer:<div><br></div><div>(auto x =3D function(); p=
(x)) ? z(x) : y(x);</div><div><br></div><div>where</div><div>- p(x) is a pr=
edicate of x (perhaps just an automatic contextual conversion to bool, if o=
mitted)</div><div>- z(x) and y(x) are arbitrary expressions in x (perhaps n=
ot mentioning x at all)</div><div><br></div><div>It *does* go further than =
the gnu extension, in a *far* more useful way.</div><div><br></div><div>G</=
div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Tue,=
 Apr 3, 2018 at 4:06 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_soo=
d@me.com" target=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrote:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D"">On Tuesday, Ap=
ril 3, 2018 at 3:42:10 PM UTC+1, Richard Hodges 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"><div><span style=3D"color:rgb(34,34,34)=
;font-family:arial,sans-serif;font-size:small;font-style:normal;font-weight=
:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:=
none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);=
float:none;display:inline">This is perhaps true. From what I&#39;ve read th=
e risk might be that it gets pushed back because it&#39;s essentially doing=
 nothing more than introducing some shorthand, as opposed to new functional=
ity that was previously difficult or unwieldy.</span></div></div></blockquo=
te><div><br></div></span><div>While that&#39;s a good point that&#39;s defi=
nitely worth keeping in mind, haven&#39;t there been quite a few minor shor=
thand features accepted recently? The first one that springs to mind is=C2=
=A0<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305=
r0.html" target=3D"_blank">if statement initialisers</a> in C++17: it didn&=
#39;t really bring any new functionality and it isn&#39;t particularly diff=
icult to write an explicit scope (arguably much simpler than the lambda-bas=
ed alternatives to this proposal discussed here). I don&#39;t mean that in =
a bad way; I love shorthand notation and I&#39;m enjoying using if statemen=
ts with initialisers. But I think it makes a good comparison with this prop=
osal.</div></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/820d844c-21a7-429c-bf55-17ee12f8ca8e%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/820d=
844c-21a7-429c-<wbr>bf55-17ee12f8ca8e%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></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/CAANG%3DkX5nk%3DtVyY1fvzFppy8XEcqxMTt=
Ah_PMSGHHiE%3DcgXQZw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkX5=
nk%3DtVyY1fvzFppy8XEcqxMTtAh_PMSGHHiE%3DcgXQZw%40mail.gmail.com</a>.<br />

--089e08286f0c7ac6890568f6eef0--

.


Author: hamza_sood@me.com
Date: Wed, 4 Apr 2018 11:10:50 -0700 (PDT)
Raw View
------=_Part_32633_2048551309.1522865450267
Content-Type: multipart/alternative;
 boundary="----=_Part_32634_1846156165.1522865450271"

------=_Part_32634_1846156165.1522865450271
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable



On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wrote=
:
>
> however, I'd still prefer if it looked more like the if-statement with=20
> initializer:
>
> (auto x =3D function(); p(x)) ? z(x) : y(x);
>
> where
> - p(x) is a predicate of x (perhaps just an automatic contextual=20
> conversion to bool, if omitted)
> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning x=
=20
> at all)
>

Good idea! It=E2=80=99d made sense for that to work too.

So what=E2=80=99s the consensus here? Is it worth starting work on a paper =
yet?

--=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/2fe5d081-e13f-4750-87b0-a3b5b47eb252%40isocpp.or=
g.

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

<div dir=3D"ltr"><br><br>On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=
=C5=A1per A=C5=BEman wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr">however, I&#39;d still prefer if it looked more like the if-s=
tatement with initializer:<div><br></div><div>(auto x =3D function(); p(x))=
 ? z(x) : y(x);</div><div><br></div><div>where</div><div>- p(x) is a predic=
ate of x (perhaps just an automatic contextual conversion to bool, if omitt=
ed)</div><div>- z(x) and y(x) are arbitrary expressions in x (perhaps not m=
entioning x at all)</div></div></blockquote><div><br></div><div>Good idea! =
It=E2=80=99d made sense for that to work too.</div><div><br></div><div>So w=
hat=E2=80=99s the consensus here? Is it worth starting work on a paper yet?=
</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/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252=
%40isocpp.org</a>.<br />

------=_Part_32634_1846156165.1522865450271--

------=_Part_32633_2048551309.1522865450267--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 4 Apr 2018 19:13:20 +0100
Raw View
--94eb2c14070267790b056909c8e2
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Honestly it feels more like a missing feature to me than an extension to me
at this point - I'd be glad to support this paper in the BSI, as long as I
agreed with the final text of course.

It's a fairly small, well contained, and "obvious" extension, what with the
if-statement-with-initializer already having figured out all the
corner-cases. All we're doing is transplanting that into the conditional
operator. That is, if we can make the grammar work out to not enormously
complicate the parser :).

G

On Wed, Apr 4, 2018 at 7:10 PM, <hamza_sood@me.com> wrote:

>
>
> On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wro=
te:
>>
>> however, I'd still prefer if it looked more like the if-statement with
>> initializer:
>>
>> (auto x =3D function(); p(x)) ? z(x) : y(x);
>>
>> where
>> - p(x) is a predicate of x (perhaps just an automatic contextual
>> conversion to bool, if omitted)
>> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning x
>> at all)
>>
>
> Good idea! It=E2=80=99d made sense for that to work too.
>
> So what=E2=80=99s the consensus here? Is it worth starting work on a pape=
r yet?
>
> --
> 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/2fe5d081-e13f-4750-
> 87b0-a3b5b47eb252%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e1=
3f-4750-87b0-a3b5b47eb252%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>

--=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/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACu=
ZNgFDoA%40mail.gmail.com.

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

<div dir=3D"ltr">Honestly it feels more like a missing feature to me than a=
n extension to me at this point - I&#39;d be glad to support this paper in =
the BSI, as long as I agreed with the final text of course.<div><br></div><=
div>It&#39;s a fairly small, well contained, and &quot;obvious&quot; extens=
ion, what with the if-statement-with-initializer already having figured out=
 all the corner-cases. All we&#39;re doing is transplanting that into the c=
onditional operator. That is, if we can make the grammar work out to not en=
ormously complicate the parser :).</div><div><br></div><div>G</div></div><d=
iv class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, 2018=
 at 7:10 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_sood@me.com" ta=
rget=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrote:<br><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div dir=3D"ltr"><span class=3D""><br><br>On Tuesday, April =
3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">however, I&#39;d still prefer if it=
 looked more like the if-statement with initializer:<div><br></div><div>(au=
to x =3D function(); p(x)) ? z(x) : y(x);</div><div><br></div><div>where</d=
iv><div>- p(x) is a predicate of x (perhaps just an automatic contextual co=
nversion to bool, if omitted)</div><div>- z(x) and y(x) are arbitrary expre=
ssions in x (perhaps not mentioning x at all)</div></div></blockquote><div>=
<br></div></span><div>Good idea! It=E2=80=99d made sense for that to work t=
oo.</div><div><br></div><div>So what=E2=80=99s the consensus here? Is it wo=
rth starting work on a paper yet?</div></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/2fe5=
d081-e13f-4750-<wbr>87b0-a3b5b47eb252%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></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/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp=
%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com</a>.<br />

--94eb2c14070267790b056909c8e2--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 04 Apr 2018 14:18:22 -0400
Raw View
<html><head></head><body lang=3D"en-US" style=3D"background-color: rgb(255,=
 255, 255); line-height: initial;">                                        =
                                              <div style=3D"width: 100%; fo=
nt-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif=
; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, =
255, 255);">It's not small and we'll contained.&nbsp;</div><div style=3D"wi=
dth: 100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-seri=
f, sans-serif; color: rgb(31, 73, 125); text-align: initial; background-col=
or: rgb(255, 255, 255);">The ? operator comes after the expression. You wou=
ld need to change the grammar for ALL expressions. =E2=80=8E(Or require arb=
itrary look ahead, which isn't going to happen.)</div><div style=3D"width: =
100%; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sa=
ns-serif; color: rgb(31, 73, 125); text-align: initial; background-color: r=
gb(255, 255, 255);"><span style=3D"font-size: initial; line-height: initial=
; text-align: initial;"><br></span></div><div style=3D"width: 100%; font-si=
ze: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; col=
or: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255, =
255);"><span style=3D"font-size: initial; line-height: initial; text-align:=
 initial;">I think this needs lots more motivation than just the condition =
operator. =E2=80=8ESo far, the answer is 'just use an if' (inside a lambda =
is necessary) .</span></div><div style=3D"width: 100%; font-size: initial; =
font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 7=
3, 125); text-align: initial; background-color: rgb(255, 255, 255);"><span =
style=3D"font-size: initial; line-height: initial; text-align: initial;"><b=
r></span></div><div style=3D"width: 100%; font-size: initial; font-family: =
Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text=
-align: initial; background-color: rgb(255, 255, 255);"><span style=3D"font=
-size: initial; line-height: initial; text-align: initial;"><br></span></di=
v>                                                                         =
                                                                           =
                                               <div style=3D"font-size: ini=
tial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; color: rgb=
(31, 73, 125); text-align: initial; background-color: rgb(255, 255, 255);">=
Sent&nbsp;from&nbsp;my&nbsp;BlackBerry&nbsp;portable&nbsp;Babbage&nbsp;Devi=
ce</div>                                                                   =
                                                                           =
                                    <table width=3D"100%" style=3D"backgrou=
nd-color:white;border-spacing:0px;"> <tbody><tr><td colspan=3D"2" style=3D"=
font-size: initial; text-align: initial; background-color: rgb(255, 255, 25=
5);">                           <div style=3D"border-style: solid none none=
; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; padding: 3pt=
 0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-size: 10p=
t;">  <div><b>From: </b>Ga=C5=A1per A=C5=BEman</div><div><b>Sent: </b>Wedne=
sday, April 4, 2018 2:13 PM</div><div><b>To: </b>std-proposals@isocpp.org</=
div><div><b>Reply To: </b>std-proposals@isocpp.org</div><div><b>Subject: </=
b>Re: [std-proposals] Variable declaration in a ternary conditional</div></=
div></td></tr></tbody></table><div style=3D"border-style: solid none none; =
border-top-color: rgb(186, 188, 209); border-top-width: 1pt; font-size: ini=
tial; text-align: initial; background-color: rgb(255, 255, 255);"></div><br=
><div id=3D"_originalContent" style=3D""><div dir=3D"ltr">Honestly it feels=
 more like a missing feature to me than an extension to me at this point - =
I'd be glad to support this paper in the BSI, as long as I agreed with the =
final text of course.<div><br></div><div>It's a fairly small, well containe=
d, and "obvious" extension, what with the if-statement-with-initializer alr=
eady having figured out all the corner-cases. All we're doing is transplant=
ing that into the conditional operator. That is, if we can make the grammar=
 work out to not enormously complicate the parser :).</div><div><br></div><=
div>G</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On Wed, Apr 4, 2018 at 7:10 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:ha=
mza_sood@me.com" target=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D""><br><br=
>On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">however, I'd sti=
ll prefer if it looked more like the if-statement with initializer:<div><br=
></div><div>(auto x =3D function(); p(x)) ? z(x) : y(x);</div><div><br></di=
v><div>where</div><div>- p(x) is a predicate of x (perhaps just an automati=
c contextual conversion to bool, if omitted)</div><div>- z(x) and y(x) are =
arbitrary expressions in x (perhaps not mentioning x at all)</div></div></b=
lockquote><div><br></div></span><div>Good idea! It=E2=80=99d made sense for=
 that to work too.</div><div><br></div><div>So what=E2=80=99s the consensus=
 here? Is it worth starting work on a paper yet?</div></div><span class=3D"=
">

<p></p>

-- <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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/2fe5=
d081-e13f-4750-<wbr>87b0-a3b5b47eb252%40isocpp.org</a><wbr>.<br>
</blockquote></div><br></div>

<p></p>

-- <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/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3Dk=
WVYp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com</a>.<br>
<br><!--end of _originalContent --></div></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/20180404181822.5103698.54527.49083%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20180404181822.5103698.54527.49083%40gm=
ail.com</a>.<br />

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 4 Apr 2018 19:20:02 +0100
Raw View
--000000000000567f36056909e0a9
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Well, that's my parser caveat triggered - I guess we need a better solution
:).

On Wed, Apr 4, 2018 at 7:18 PM, Tony V E <tvaneerd@gmail.com> wrote:

> It's not small and we'll contained.
> The ? operator comes after the expression. You would need to change the
> grammar for ALL expressions. =E2=80=8E(Or require arbitrary look ahead, w=
hich isn't
> going to happen.)
>
> I think this needs lots more motivation than just the condition operator.
> =E2=80=8ESo far, the answer is 'just use an if' (inside a lambda is neces=
sary) .
>
>
> Sent from my BlackBerry portable Babbage Device
> *From: *Ga=C5=A1per A=C5=BEman
> *Sent: *Wednesday, April 4, 2018 2:13 PM
> *To: *std-proposals@isocpp.org
> *Reply To: *std-proposals@isocpp.org
> *Subject: *Re: [std-proposals] Variable declaration in a ternary
> conditional
>
> Honestly it feels more like a missing feature to me than an extension to
> me at this point - I'd be glad to support this paper in the BSI, as long =
as
> I agreed with the final text of course.
>
> It's a fairly small, well contained, and "obvious" extension, what with
> the if-statement-with-initializer already having figured out all the
> corner-cases. All we're doing is transplanting that into the conditional
> operator. That is, if we can make the grammar work out to not enormously
> complicate the parser :).
>
> G
>
> On Wed, Apr 4, 2018 at 7:10 PM, <hamza_sood@me.com> wrote:
>
>>
>>
>> On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wr=
ote:
>>>
>>> however, I'd still prefer if it looked more like the if-statement with
>>> initializer:
>>>
>>> (auto x =3D function(); p(x)) ? z(x) : y(x);
>>>
>>> where
>>> - p(x) is a predicate of x (perhaps just an automatic contextual
>>> conversion to bool, if omitted)
>>> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning =
x
>>> at all)
>>>
>>
>> Good idea! It=E2=80=99d made sense for that to work too.
>>
>> So what=E2=80=99s the consensus here? Is it worth starting work on a pap=
er yet?
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-
>> a3b5b47eb252%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e=
13f-4750-87b0-a3b5b47eb252%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
> --
> 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/CAANG%3DkWVYp%
> 3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWV=
Yp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3D=
email&utm_source=3Dfooter>
> .
>
> --
> 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/20180404181822.
> 5103698.54527.49083%40gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/20180404181=
822.5103698.54527.49083%40gmail.com?utm_medium=3Demail&utm_source=3Dfooter>
> .
>

--=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/CAANG%3DkVhuY%3D0_4AkoZ%2B9NNLSQAHGJtvYG9EXd7kUj=
P6OdhUSVw%40mail.gmail.com.

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

<div dir=3D"ltr">Well, that&#39;s my parser caveat triggered - I guess we n=
eed a better solution :).</div><div class=3D"gmail_extra"><br><div class=3D=
"gmail_quote">On Wed, Apr 4, 2018 at 7:18 PM, Tony V E <span dir=3D"ltr">&l=
t;<a href=3D"mailto:tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gmail.co=
m</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang=3D"en-U=
S" style=3D"background-color:rgb(255,255,255);line-height:initial">        =
                                                                           =
   <div style=3D"width:100%;font-size:initial;font-family:Calibri,&#39;Slat=
e Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;ba=
ckground-color:rgb(255,255,255)">It&#39;s not small and we&#39;ll contained=
..=C2=A0</div><div style=3D"width:100%;font-size:initial;font-family:Calibri=
,&#39;Slate Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:=
initial;background-color:rgb(255,255,255)">The ? operator comes after the e=
xpression. You would need to change the grammar for ALL expressions. =E2=80=
=8E(Or require arbitrary look ahead, which isn&#39;t going to happen.)</div=
><div style=3D"width:100%;font-size:initial;font-family:Calibri,&#39;Slate =
Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;back=
ground-color:rgb(255,255,255)"><span style=3D"font-size:initial;line-height=
:initial;text-align:initial"><br></span></div><div style=3D"width:100%;font=
-size:initial;font-family:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif=
;color:rgb(31,73,125);text-align:initial;background-color:rgb(255,255,255)"=
><span style=3D"font-size:initial;line-height:initial;text-align:initial">I=
 think this needs lots more motivation than just the condition operator. =
=E2=80=8ESo far, the answer is &#39;just use an if&#39; (inside a lambda is=
 necessary) .</span></div><div style=3D"width:100%;font-size:initial;font-f=
amily:Calibri,&#39;Slate Pro&#39;,sans-serif,sans-serif;color:rgb(31,73,125=
);text-align:initial;background-color:rgb(255,255,255)"><span style=3D"font=
-size:initial;line-height:initial;text-align:initial"><br></span></div><div=
 style=3D"width:100%;font-size:initial;font-family:Calibri,&#39;Slate Pro&#=
39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backgroun=
d-color:rgb(255,255,255)"><span style=3D"font-size:initial;line-height:init=
ial;text-align:initial"><br></span></div>                                  =
                                                                           =
                                                                           =
           <div style=3D"font-size:initial;font-family:Calibri,&#39;Slate P=
ro&#39;,sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backg=
round-color:rgb(255,255,255)">Sent=C2=A0from=C2=A0my=C2=A0BlackBerry=C2=A0<=
wbr>portable=C2=A0Babbage=C2=A0Device</div>                                =
                                                                           =
                                                                       <tab=
le width=3D"100%" style=3D"background-color:white;border-spacing:0px"> <tbo=
dy><tr><td colspan=3D"2" style=3D"font-size:initial;text-align:initial;back=
ground-color:rgb(255,255,255)">                           <div style=3D"bor=
der-style:solid none none;border-top-color:rgb(181,196,223);border-top-widt=
h:1pt;padding:3pt 0in 0in;font-family:Tahoma,&#39;BB Alpha Sans&#39;,&#39;S=
late Pro&#39;;font-size:10pt">  <div><b>From: </b>Ga=C5=A1per A=C5=BEman</d=
iv><div><b>Sent: </b>Wednesday, April 4, 2018 2:13 PM</div><div><b>To: </b>=
<a href=3D"mailto:std-proposals@isocpp.org" target=3D"_blank">std-proposals=
@isocpp.org</a></div><div><b>Reply To: </b><a href=3D"mailto:std-proposals@=
isocpp.org" target=3D"_blank">std-proposals@isocpp.org</a></div><div><b>Sub=
ject: </b>Re: [std-proposals] Variable declaration in a ternary conditional=
</div></div></td></tr></tbody></table><div style=3D"border-style:solid none=
 none;border-top-color:rgb(186,188,209);border-top-width:1pt;font-size:init=
ial;text-align:initial;background-color:rgb(255,255,255)"></div><br><div id=
=3D"m_-592169244586975519_originalContent"><div><div class=3D"h5"><div dir=
=3D"ltr">Honestly it feels more like a missing feature to me than an extens=
ion to me at this point - I&#39;d be glad to support this paper in the BSI,=
 as long as I agreed with the final text of course.<div><br></div><div>It&#=
39;s a fairly small, well contained, and &quot;obvious&quot; extension, wha=
t with the if-statement-with-initializer already having figured out all the=
 corner-cases. All we&#39;re doing is transplanting that into the condition=
al operator. That is, if we can make the grammar work out to not enormously=
 complicate the parser :).</div><div><br></div><div>G</div></div><div class=
=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, 2018 at 7:10=
 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_sood@me.com" target=3D"=
_blank">hamza_sood@me.com</a>&gt;</span> wrote:<br><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex"><div dir=3D"ltr"><span><br><br>On Tuesday, April 3, 2018 at 8:44:18 =
PM UTC+1, Ga=C5=A1per A=C5=BEman wrote:<blockquote class=3D"gmail_quote" st=
yle=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1=
ex"><div dir=3D"ltr">however, I&#39;d still prefer if it looked more like t=
he if-statement with initializer:<div><br></div><div>(auto x =3D function()=
; p(x)) ? z(x) : y(x);</div><div><br></div><div>where</div><div>- p(x) is a=
 predicate of x (perhaps just an automatic contextual conversion to bool, i=
f omitted)</div><div>- z(x) and y(x) are arbitrary expressions in x (perhap=
s not mentioning x at all)</div></div></blockquote><div><br></div></span><d=
iv>Good idea! It=E2=80=99d made sense for that to work too.</div><div><br><=
/div><div>So what=E2=80=99s the consensus here? Is it worth starting work o=
n a paper yet?</div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/2fe5=
d081-e13f-4750-87b0-<wbr>a3b5b47eb252%40isocpp.org</a>.<br>
</blockquote></div><br></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@<wbr>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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/=
std-<wbr>proposals/CAANG%3DkWVYp%<wbr>3DSyO3wkiSWYNTcZgTNwrB0FmZOKqP<wbr>fA=
CuZNgFDoA%40mail.gmail.com</a>.<br>
<br></div></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20180404181822.5103698.54527.49083%40=
gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">htt=
ps://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/2018040=
4181822.<wbr>5103698.54527.49083%40gmail.<wbr>com</a>.<br>
</blockquote></div><br></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/CAANG%3DkVhuY%3D0_4AkoZ%2B9NNLSQAHGJt=
vYG9EXd7kUjP6OdhUSVw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkVh=
uY%3D0_4AkoZ%2B9NNLSQAHGJtvYG9EXd7kUjP6OdhUSVw%40mail.gmail.com</a>.<br />

--000000000000567f36056909e0a9--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Wed, 4 Apr 2018 20:23:40 +0200
Raw View
--0000000000002b48ca056909ec66
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Just a thought, but how badly would it mangle the language if the if
keyword, as well as introducing a statement, was also able to introduce an
expression which returned:

* In the case where there is an else clause:  the std::common_type of its
true and false clauses
* In the case where there is no else clause: a std::optional<T> where T is
the expression type of the true case.

?

e.g.

// x is an int
auto x =3D if(auto p =3D something(); p) p->get_int() else 1234;

// y is bool
auto y =3D if(something()) true else false;

// z  is std::optional<int>
auto z =3D if(auto p =3D something(); p) p->get_int();





On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com> w=
rote:

> Honestly it feels more like a missing feature to me than an extension to
> me at this point - I'd be glad to support this paper in the BSI, as long =
as
> I agreed with the final text of course.
>
> It's a fairly small, well contained, and "obvious" extension, what with
> the if-statement-with-initializer already having figured out all the
> corner-cases. All we're doing is transplanting that into the conditional
> operator. That is, if we can make the grammar work out to not enormously
> complicate the parser :).
>
> G
>
> On Wed, Apr 4, 2018 at 7:10 PM, <hamza_sood@me.com> wrote:
>
>>
>>
>> On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wr=
ote:
>>>
>>> however, I'd still prefer if it looked more like the if-statement with
>>> initializer:
>>>
>>> (auto x =3D function(); p(x)) ? z(x) : y(x);
>>>
>>> where
>>> - p(x) is a predicate of x (perhaps just an automatic contextual
>>> conversion to bool, if omitted)
>>> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning =
x
>>> at all)
>>>
>>
>> Good idea! It=E2=80=99d made sense for that to work too.
>>
>> So what=E2=80=99s the consensus here? Is it worth starting work on a pap=
er yet?
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-
>> a3b5b47eb252%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e=
13f-4750-87b0-a3b5b47eb252%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>
> --
> 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/CAANG%3DkWVYp%
> 3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWV=
Yp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3D=
email&utm_source=3Dfooter>
> .
>

--=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/CALvx3hYbx1X81NWBaS4o2ScsA%2Bnuy%3D%2BgYWJirtN%2=
BZdPgCP_0ug%40mail.gmail.com.

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

<div dir=3D"ltr">Just a thought, but how badly would it mangle the language=
 if the <font face=3D"monospace, monospace">if</font> keyword, as well as i=
ntroducing a statement, was also able to introduce an expression which retu=
rned:<br><br>* In the case where there is an else clause:=C2=A0 the std::co=
mmon_type of its true and false clauses<br>* In the case where there is no =
else clause: a std::optional&lt;T&gt; where T is the expression type of the=
 true case.<br><br>?<br><br>e.g.<br><br><font face=3D"monospace, monospace"=
>// x is an int<br>auto x =3D if(auto p =3D something(); p) p-&gt;get_int()=
 else 1234;<br><br>// y is bool<br>auto y =3D if(something()) true else fal=
se;<br><br>// z=C2=A0 is std::optional&lt;int&gt;<br>auto z =3D if(<span st=
yle=3D"color:rgb(34,34,34);font-size:small;font-style:normal;font-variant-l=
igatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:nor=
mal;text-align:start;text-indent:0px;text-transform:none;white-space:normal=
;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:i=
nitial;text-decoration-color:initial;float:none;display:inline">auto p =3D =
something(); p) p-&gt;get_int();<br></span></font><br><br><br><br></div><di=
v class=3D"gmail_extra"><br><div class=3D"gmail_quote">On 4 April 2018 at 2=
0:13, Ga=C5=A1per A=C5=BEman <span dir=3D"ltr">&lt;<a href=3D"mailto:gasper=
..azman@gmail.com" target=3D"_blank">gasper.azman@gmail.com</a>&gt;</span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Honestly it feels =
more like a missing feature to me than an extension to me at this point - I=
&#39;d be glad to support this paper in the BSI, as long as I agreed with t=
he final text of course.<div><br></div><div>It&#39;s a fairly small, well c=
ontained, and &quot;obvious&quot; extension, what with the if-statement-wit=
h-initializer already having figured out all the corner-cases. All we&#39;r=
e doing is transplanting that into the conditional operator. That is, if we=
 can make the grammar work out to not enormously complicate the parser :).<=
/div><div><br></div><div>G</div></div><div><div class=3D"h5"><div class=3D"=
gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, 2018 at 7:10 PM,=
  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_sood@me.com" target=3D"_bla=
nk">hamza_sood@me.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr"><span><br><br>On Tuesday, April 3, 2018 at 8:44:18 PM U=
TC+1, Ga=C5=A1per A=C5=BEman 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">however, I&#39;d still prefer if it looked more like the =
if-statement with initializer:<div><br></div><div>(auto x =3D function(); p=
(x)) ? z(x) : y(x);</div><div><br></div><div>where</div><div>- p(x) is a pr=
edicate of x (perhaps just an automatic contextual conversion to bool, if o=
mitted)</div><div>- z(x) and y(x) are arbitrary expressions in x (perhaps n=
ot mentioning x at all)</div></div></blockquote><div><br></div></span><div>=
Good idea! It=E2=80=99d made sense for that to work too.</div><div><br></di=
v><div>So what=E2=80=99s the consensus here? Is it worth starting work on a=
 paper yet?</div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/2fe5=
d081-e13f-4750-87b0-<wbr>a3b5b47eb252%40isocpp.org</a>.<br>
</blockquote></div><br></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@<wbr>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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/=
std-<wbr>proposals/CAANG%3DkWVYp%<wbr>3DSyO3wkiSWYNTcZgTNwrB0FmZOKqP<wbr>fA=
CuZNgFDoA%40mail.gmail.com</a>.<br>
</blockquote></div><br></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/CALvx3hYbx1X81NWBaS4o2ScsA%2Bnuy%3D%2=
BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYb=
x1X81NWBaS4o2ScsA%2Bnuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com</a>.<br=
 />

--0000000000002b48ca056909ec66--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 4 Apr 2018 19:26:15 +0100
Raw View
--00000000000093a43e056909f6b6
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Just off the top of my head with 10 seconds of thinking about it - the
result of the last statement of the compound if-statement should be
destroyed first, but will now be destroyed last (as if it were returned). I
think it might be a non-starter.

G

On Wed, Apr 4, 2018 at 7:23 PM, Richard Hodges <hodges.r@gmail.com> wrote:

> Just a thought, but how badly would it mangle the language if the if
> keyword, as well as introducing a statement, was also able to introduce a=
n
> expression which returned:
>
> * In the case where there is an else clause:  the std::common_type of its
> true and false clauses
> * In the case where there is no else clause: a std::optional<T> where T i=
s
> the expression type of the true case.
>
> ?
>
> e.g.
>
> // x is an int
> auto x =3D if(auto p =3D something(); p) p->get_int() else 1234;
>
> // y is bool
> auto y =3D if(something()) true else false;
>
> // z  is std::optional<int>
> auto z =3D if(auto p =3D something(); p) p->get_int();
>
>
>
>
>
> On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com>=
 wrote:
>
>> Honestly it feels more like a missing feature to me than an extension to
>> me at this point - I'd be glad to support this paper in the BSI, as long=
 as
>> I agreed with the final text of course.
>>
>> It's a fairly small, well contained, and "obvious" extension, what with
>> the if-statement-with-initializer already having figured out all the
>> corner-cases. All we're doing is transplanting that into the conditional
>> operator. That is, if we can make the grammar work out to not enormously
>> complicate the parser :).
>>
>> G
>>
>> On Wed, Apr 4, 2018 at 7:10 PM, <hamza_sood@me.com> wrote:
>>
>>>
>>>
>>> On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman w=
rote:
>>>>
>>>> however, I'd still prefer if it looked more like the if-statement with
>>>> initializer:
>>>>
>>>> (auto x =3D function(); p(x)) ? z(x) : y(x);
>>>>
>>>> where
>>>> - p(x) is a predicate of x (perhaps just an automatic contextual
>>>> conversion to bool, if omitted)
>>>> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning
>>>> x at all)
>>>>
>>>
>>> Good idea! It=E2=80=99d made sense for that to work too.
>>>
>>> So what=E2=80=99s the consensus here? Is it worth starting work on a pa=
per yet?
>>>
>>> --
>>> 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/is
>>> ocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b
>>> 47eb252%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2fe5d081-=
e13f-4750-87b0-a3b5b47eb252%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
>>> .
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTc
>> ZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkW=
VYp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=
=3Demail&utm_source=3Dfooter>
>> .
>>
>
> --
> 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/CALvx3hYbx1X81NWBaS4o2ScsA%
> 2Bnuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbx1=
X81NWBaS4o2ScsA%2Bnuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_mediu=
m=3Demail&utm_source=3Dfooter>
> .
>

--=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/CAANG%3DkVd2HWzcRQfNsjQutDpXC0F4EB7%3DE2C1-VKWYR=
kVWGtOw%40mail.gmail.com.

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

<div dir=3D"ltr">Just off the top of my head with 10 seconds of thinking ab=
out it - the result of the last statement of the compound if-statement shou=
ld be destroyed first, but will now be destroyed last (as if it were return=
ed). I think it might be a non-starter.<div><br></div><div>G</div></div><di=
v class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, 2018 =
at 7:23 PM, Richard Hodges <span dir=3D"ltr">&lt;<a href=3D"mailto:hodges.r=
@gmail.com" target=3D"_blank">hodges.r@gmail.com</a>&gt;</span> wrote:<br><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex"><div dir=3D"ltr">Just a thought, but how badl=
y would it mangle the language if the <font face=3D"monospace, monospace">i=
f</font> keyword, as well as introducing a statement, was also able to intr=
oduce an expression which returned:<br><br>* In the case where there is an =
else clause:=C2=A0 the std::common_type of its true and false clauses<br>* =
In the case where there is no else clause: a std::optional&lt;T&gt; where T=
 is the expression type of the true case.<br><br>?<br><br>e.g.<br><br><font=
 face=3D"monospace, monospace">// x is an int<br>auto x =3D if(auto p =3D s=
omething(); p) p-&gt;get_int() else 1234;<br><br>// y is bool<br>auto y =3D=
 if(something()) true else false;<br><br>// z=C2=A0 is std::optional&lt;int=
&gt;<br>auto z =3D if(<span style=3D"color:rgb(34,34,34);font-size:small;fo=
nt-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font=
-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-tra=
nsform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,25=
5,255);text-decoration-style:initial;text-decoration-color:initial;float:no=
ne;display:inline">auto p =3D something(); p) p-&gt;get_int();<br></span></=
font><br><br><br><br></div><div class=3D"gmail_extra"><br><div class=3D"gma=
il_quote"><div><div class=3D"h5">On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=
=BEman <span dir=3D"ltr">&lt;<a href=3D"mailto:gasper.azman@gmail.com" targ=
et=3D"_blank">gasper.azman@gmail.com</a>&gt;</span> wrote:<br></div></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex"><div><div class=3D"h5"><div dir=3D"ltr">Hones=
tly it feels more like a missing feature to me than an extension to me at t=
his point - I&#39;d be glad to support this paper in the BSI, as long as I =
agreed with the final text of course.<div><br></div><div>It&#39;s a fairly =
small, well contained, and &quot;obvious&quot; extension, what with the if-=
statement-with-initializer already having figured out all the corner-cases.=
 All we&#39;re doing is transplanting that into the conditional operator. T=
hat is, if we can make the grammar work out to not enormously complicate th=
e parser :).</div><div><br></div><div>G</div></div><div><div class=3D"m_-33=
4735635176395500h5"><div class=3D"gmail_extra"><br><div class=3D"gmail_quot=
e">On Wed, Apr 4, 2018 at 7:10 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto=
:hamza_sood@me.com" target=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrot=
e:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><br><br>On Tues=
day, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wrote:<block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">however, I&#39;d still p=
refer if it looked more like the if-statement with initializer:<div><br></d=
iv><div>(auto x =3D function(); p(x)) ? z(x) : y(x);</div><div><br></div><d=
iv>where</div><div>- p(x) is a predicate of x (perhaps just an automatic co=
ntextual conversion to bool, if omitted)</div><div>- z(x) and y(x) are arbi=
trary expressions in x (perhaps not mentioning x at all)</div></div></block=
quote><div><br></div></span><div>Good idea! It=E2=80=99d made sense for tha=
t to work too.</div><div><br></div><div>So what=E2=80=99s the consensus her=
e? Is it worth starting work on a paper yet?</div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/2fe5=
d081-e13f-4750-87b0-a3b5b<wbr>47eb252%40isocpp.org</a>.<br>
</blockquote></div><br></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@isoc<wbr>pp.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></div></div></div>=
</div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/=
std-proposals<wbr>/CAANG%3DkWVYp%3DSyO3wkiSWYNTc<wbr>ZgTNwrB0FmZOKqPfACuZNg=
FDoA%<wbr>40mail.gmail.com</a>.<br>
</blockquote></div><br></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbx1X81NWBaS4o2ScsA%2Bnuy%3D%2=
BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=
=3Dfooter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/=
msgid/std-<wbr>proposals/<wbr>CALvx3hYbx1X81NWBaS4o2ScsA%<wbr>2Bnuy%3D%2BgY=
WJirtN%2BZdPgCP_<wbr>0ug%40mail.gmail.com</a>.<br>
</blockquote></div><br></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/CAANG%3DkVd2HWzcRQfNsjQutDpXC0F4EB7%3=
DE2C1-VKWYRkVWGtOw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkVd2H=
WzcRQfNsjQutDpXC0F4EB7%3DE2C1-VKWYRkVWGtOw%40mail.gmail.com</a>.<br />

--00000000000093a43e056909f6b6--

.


Author: "'Johannes Schaub' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Wed, 04 Apr 2018 18:31:26 +0000
Raw View
--00000000000085e8c705690a0805
Content-Type: text/plain; charset="UTF-8"

Richard Hodges <hodges.r@gmail.com> schrieb am Mo., 2. Apr. 2018, 23:58:

> Or with a little more boilerplate...
>
> int main()
> {
>     auto i = from(something()).maybe(get_int()).otherwise(1234);
>     return i;
> }
>
>
> ... although this is crying out for otherwise() and maybe()'s return type
> to be lifted into function objects a-la Haskel/boost::hana etc.
>

Get a C++ programmer who hasn't read the previous messages and ask her what
this line of code means.

In contrast, it's immediately clear what the declaration-in-ternary means.



>

--
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/CANu6V4V-JgesQa7vmtFEQURZg3Lhx3qn8wYjmMLpwbsFxBLvYA%40mail.gmail.com.

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

<div dir=3D"auto"><div><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">=
Richard Hodges &lt;<a href=3D"mailto:hodges.r@gmail.com">hodges.r@gmail.com=
</a>&gt; schrieb am Mo., 2. Apr. 2018, 23:58:<br></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex"><div dir=3D"ltr">Or with a little more boilerplate...<div><br></=
div><div><div style=3D"color:rgb(0,0,0);background-color:rgb(255,255,254)">=
<div><font face=3D"monospace, monospace"><span style=3D"color:rgb(0,0,255)"=
>int</span><span style=3D"color:rgb(0,0,0)"> main()</span></font></div><div=
><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, monospace">{</fo=
nt></span></div><div><font face=3D"monospace, monospace"><span style=3D"col=
or:rgb(0,0,255)">=C2=A0 =C2=A0 auto</span><span style=3D"color:rgb(0,0,0)">=
 i =3D from(something()).maybe(get_int()).otherwise(</span><span style=3D"c=
olor:rgb(9,136,90)">1234</span><span style=3D"color:rgb(0,0,0)">);</span></=
font></div><div><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, m=
onospace">    </font></span></div><div><font face=3D"monospace, monospace">=
<span style=3D"color:rgb(0,0,0)"></span><span style=3D"color:rgb(0,0,255)">=
=C2=A0 =C2=A0 return</span><span style=3D"color:rgb(0,0,0)"> i;</span></fon=
t></div><div><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, mono=
space">}</font></span></div><br></div><br></div><div>... although this is c=
rying out for otherwise() and maybe()&#39;s return type to be lifted into f=
unction objects a-la Haskel/boost::hana etc.<br></div></div></blockquote></=
div></div><div dir=3D"auto"><br></div><div dir=3D"auto">Get a C++ programme=
r who hasn&#39;t read the previous messages and ask her what this line of c=
ode means.=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto">In cont=
rast, it&#39;s immediately clear what the declaration-in-ternary means.</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"auto"=
><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"marg=
in:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"=
><div><br></div></div>
</blockquote></div></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/CANu6V4V-JgesQa7vmtFEQURZg3Lhx3qn8wYj=
mMLpwbsFxBLvYA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANu6V4V-JgesQa7v=
mtFEQURZg3Lhx3qn8wYjmMLpwbsFxBLvYA%40mail.gmail.com</a>.<br />

--00000000000085e8c705690a0805--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 4 Apr 2018 11:41:39 -0700 (PDT)
Raw View
------=_Part_8_870928626.1522867300023
Content-Type: multipart/alternative;
 boundary="----=_Part_9_1337700500.1522867300023"

------=_Part_9_1337700500.1522867300023
Content-Type: text/plain; charset="UTF-8"



On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, Richard Hodges wrote:
>
> Just a thought, but how badly would it mangle the language if the if
> keyword, as well as introducing a statement, was also able to introduce an
> expression which returned:
>
> * In the case where there is an else clause:  the std::common_type of its
> true and false clauses
> * In the case where there is no else clause: a std::optional<T> where T is
> the expression type of the true case.
>

I don't like the idea of implicitly tying syntax into a standard library
type like `optional` in this way. We should just require that
if-expressions have an `else` clause.

Otherwise, the idea of an if-expression seems to be a solid one. This
formulation also solves other problems; since it uses `if` as an
introducer, it can use `if constexpr` as an introducer as well for
`constexpr` initializations.

--
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/0f06146e-ae61-4c74-b09d-07dae4aa058f%40isocpp.org.

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

<div dir=3D"ltr"><br><br>On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, R=
ichard Hodges wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Just a thought, but how badly would it mangle the language if the =
<font face=3D"monospace, monospace">if</font> keyword, as well as introduci=
ng a statement, was also able to introduce an expression which returned:<br=
><br>* In the case where there is an else clause:=C2=A0 the std::common_typ=
e of its true and false clauses<br>* In the case where there is no else cla=
use: a std::optional&lt;T&gt; where T is the expression type of the true ca=
se.<br></div></blockquote><div><br>I don&#39;t like the idea of implicitly =
tying syntax into a standard library type like `optional` in this way. We s=
hould just require that if-expressions have an `else` clause.<br><br>Otherw=
ise, the idea of an if-expression seems to be a solid one. This formulation=
 also solves other problems; since it uses `if` as an introducer, it can us=
e `if constexpr` as an introducer as well for `constexpr` initializations.<=
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/0f06146e-ae61-4c74-b09d-07dae4aa058f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae4aa058f=
%40isocpp.org</a>.<br />

------=_Part_9_1337700500.1522867300023--

------=_Part_8_870928626.1522867300023--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 4 Apr 2018 19:45:08 +0100
Raw View
--0000000000001a5ec605690a3a5d
Content-Type: text/plain; charset="UTF-8"

I keep thinking we're trying to re-invent the wheel of a
compound-statement-inside-a-statement. There's a mechanism for that
already, and it's called the immediately-invoked-lambda (as previously
pointed out).

As a wild weird-brain idea - there have been a bunch of (yeah, I know)
short-hand lambda proposals for lambdas that are just a single expression.

So... you can already do:

auto result = [x = f()]{return p(x) ? y(x) : z(x); }();

which is *pretty close*. I guess we don't like the return and the extra set
of parens. But what if this read as

auto result = [x = f(x)] => p(x) ? y(x) : z(x);

"Syntax for immediately invoked lambdas" :)

I'm not sure I'd even support this proposal, as the immediately-invoked
lambda is plenty short enough, but for the sake of argument :).

G

On Wed, Apr 4, 2018 at 7:31 PM, 'Johannes Schaub' via ISO C++ Standard -
Future Proposals <std-proposals@isocpp.org> wrote:

>
>
> Richard Hodges <hodges.r@gmail.com> schrieb am Mo., 2. Apr. 2018, 23:58:
>
>> Or with a little more boilerplate...
>>
>> int main()
>> {
>>     auto i = from(something()).maybe(get_int()).otherwise(1234);
>>     return i;
>> }
>>
>>
>> ... although this is crying out for otherwise() and maybe()'s return type
>> to be lifted into function objects a-la Haskel/boost::hana etc.
>>
>
> Get a C++ programmer who hasn't read the previous messages and ask her
> what this line of code means.
>
> In contrast, it's immediately clear what the declaration-in-ternary means.
>
>
>
>> --
> 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/CANu6V4V-JgesQa7vmtFEQURZg3Lhx3qn8wYjmM
> LpwbsFxBLvYA%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANu6V4V-JgesQa7vmtFEQURZg3Lhx3qn8wYjmMLpwbsFxBLvYA%40mail.gmail.com?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/CAANG%3DkWr%2BZQ5vt4WGtsVvyG1BOBU3_DhJcPFKzfxaUucuBH3Wg%40mail.gmail.com.

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

<div dir=3D"ltr"><div>I keep thinking we&#39;re trying to re-invent the whe=
el of a compound-statement-inside-a-statement. There&#39;s a mechanism for =
that already, and it&#39;s called the immediately-invoked-lambda (as previo=
usly pointed out).</div><div><br></div>As a wild weird-brain idea - there h=
ave been a bunch of (yeah, I know) short-hand lambda proposals for lambdas =
that are just a single expression.<div><br></div><div>So... you can already=
 do:</div><div><br></div><div><font face=3D"monospace, monospace">auto resu=
lt =3D [x =3D f()]{return p(x) ? y(x) : z(x); }();</font></div><div><br></d=
iv><div>which is *pretty close*. I guess we don&#39;t like the return and t=
he extra set of parens. But what if this read as</div><div><br></div><div><=
font face=3D"monospace, monospace">auto result =3D [x =3D f(x)] =3D&gt; p(x=
) ? y(x) : z(x);</font></div><div><br></div><div>&quot;Syntax for immediate=
ly invoked lambdas&quot; :)</div><div><br></div><div>I&#39;m not sure I&#39=
;d even support this proposal, as the immediately-invoked lambda is plenty =
short enough, but for the sake of argument :).</div><div><br></div><div>G</=
div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed,=
 Apr 4, 2018 at 7:31 PM, &#39;Johannes Schaub&#39; via ISO C++ Standard - F=
uture Proposals <span dir=3D"ltr">&lt;<a href=3D"mailto:std-proposals@isocp=
p.org" target=3D"_blank">std-proposals@isocpp.org</a>&gt;</span> wrote:<br>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"auto"><span class=3D""><div><br>=
<br><div class=3D"gmail_quote"><div dir=3D"ltr">Richard Hodges &lt;<a href=
=3D"mailto:hodges.r@gmail.com" target=3D"_blank">hodges.r@gmail.com</a>&gt;=
 schrieb am Mo., 2. Apr. 2018, 23:58:<br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1e=
x"><div dir=3D"ltr">Or with a little more boilerplate...<div><br></div><div=
><div style=3D"color:rgb(0,0,0);background-color:rgb(255,255,254)"><div><fo=
nt face=3D"monospace, monospace"><span style=3D"color:rgb(0,0,255)">int</sp=
an><span style=3D"color:rgb(0,0,0)"> main()</span></font></div><div><span s=
tyle=3D"color:rgb(0,0,0)"><font face=3D"monospace, monospace">{</font></spa=
n></div><div><font face=3D"monospace, monospace"><span style=3D"color:rgb(0=
,0,255)">=C2=A0 =C2=A0 auto</span><span style=3D"color:rgb(0,0,0)"> i =3D f=
rom(something()).maybe(get_<wbr>int()).otherwise(</span><span style=3D"colo=
r:rgb(9,136,90)">1234</span><span style=3D"color:rgb(0,0,0)">);</span></fon=
t></div><div><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, mono=
space">    </font></span></div><div><font face=3D"monospace, monospace"><sp=
an style=3D"color:rgb(0,0,0)"></span><span style=3D"color:rgb(0,0,255)">=C2=
=A0 =C2=A0 return</span><span style=3D"color:rgb(0,0,0)"> i;</span></font><=
/div><div><span style=3D"color:rgb(0,0,0)"><font face=3D"monospace, monospa=
ce">}</font></span></div><br></div><br></div><div>... although this is cryi=
ng out for otherwise() and maybe()&#39;s return type to be lifted into func=
tion objects a-la Haskel/boost::hana etc.<br></div></div></blockquote></div=
></div><div dir=3D"auto"><br></div></span><div dir=3D"auto">Get a C++ progr=
ammer who hasn&#39;t read the previous messages and ask her what this line =
of code means.=C2=A0</div><div dir=3D"auto"><br></div><div dir=3D"auto">In =
contrast, it&#39;s immediately clear what the declaration-in-ternary means.=
</div><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"a=
uto"><div class=3D"gmail_quote"><blockquote 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>
</blockquote></div></div></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CANu6V4V-JgesQa7vmtFEQURZg3Lhx3qn8wYj=
mMLpwbsFxBLvYA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter"=
 target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-=
<wbr>proposals/CANu6V4V-<wbr>JgesQa7vmtFEQURZg3Lhx3qn8wYjmM<wbr>LpwbsFxBLvY=
A%40mail.gmail.com</a>.<br>
</blockquote></div><br></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/CAANG%3DkWr%2BZQ5vt4WGtsVvyG1BOBU3_Dh=
JcPFKzfxaUucuBH3Wg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWr%2=
BZQ5vt4WGtsVvyG1BOBU3_DhJcPFKzfxaUucuBH3Wg%40mail.gmail.com</a>.<br />

--0000000000001a5ec605690a3a5d--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 4 Apr 2018 14:50:14 -0400
Raw View
--00000000000021a1c405690a4b92
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wed, Apr 4, 2018 at 2:23 PM, Richard Hodges <hodges.r@gmail.com> wrote:

> Just a thought, but how badly would it mangle the language if the if
> keyword, as well as introducing a statement, was also able to introduce a=
n
> expression which returned:
>
> * In the case where there is an else clause:  the std::common_type of its
> true and false clauses
> * In the case where there is no else clause: a std::optional<T> where T i=
s
> the expression type of the true case.
>
> ?
>
> e.g.
>
> // x is an int
> auto x =3D if(auto p =3D something(); p) p->get_int() else 1234;
>
> // y is bool
> auto y =3D if(something()) true else false;
>
> // z  is std::optional<int>
> auto z =3D if(auto p =3D something(); p) p->get_int();
>
>
>

This is something that I've wanted for `for` loops as well.

auto x =3D for(auto const & e : v) if (pred(e)) break e;

(of course, you could just call std::find)



>
>
>
> On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com>=
 wrote:
>
>> Honestly it feels more like a missing feature to me than an extension to
>> me at this point - I'd be glad to support this paper in the BSI, as long=
 as
>> I agreed with the final text of course.
>>
>> It's a fairly small, well contained, and "obvious" extension, what with
>> the if-statement-with-initializer already having figured out all the
>> corner-cases. All we're doing is transplanting that into the conditional
>> operator. That is, if we can make the grammar work out to not enormously
>> complicate the parser :).
>>
>> G
>>
>> On Wed, Apr 4, 2018 at 7:10 PM, <hamza_sood@me.com> wrote:
>>
>>>
>>>
>>> On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman w=
rote:
>>>>
>>>> however, I'd still prefer if it looked more like the if-statement with
>>>> initializer:
>>>>
>>>> (auto x =3D function(); p(x)) ? z(x) : y(x);
>>>>
>>>> where
>>>> - p(x) is a predicate of x (perhaps just an automatic contextual
>>>> conversion to bool, if omitted)
>>>> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning
>>>> x at all)
>>>>
>>>
>>> Good idea! It=E2=80=99d made sense for that to work too.
>>>
>>> So what=E2=80=99s the consensus here? Is it worth starting work on a pa=
per yet?
>>>
>>> --
>>> 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/is
>>> ocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b
>>> 47eb252%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2fe5d081-=
e13f-4750-87b0-a3b5b47eb252%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
>>> .
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTc
>> ZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkW=
VYp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=
=3Demail&utm_source=3Dfooter>
>> .
>>
>
> --
> 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/CALvx3hYbx1X81NWBaS4o2ScsA%
> 2Bnuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbx1=
X81NWBaS4o2ScsA%2Bnuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_mediu=
m=3Demail&utm_source=3Dfooter>
> .
>



--=20
Be seeing you,
Tony

--=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/CAOHCbis-i4i%3DsKCFkwaHU7Q6VkHipdJFVUCBqJsT5hOg_=
-OAUg%40mail.gmail.com.

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Apr 4, 2018 at 2:23 PM, Richard Hodges <span dir=3D"ltr">&lt;<a=
 href=3D"mailto:hodges.r@gmail.com" target=3D"_blank">hodges.r@gmail.com</a=
>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Just=
 a thought, but how badly would it mangle the language if the <font face=3D=
"monospace, monospace">if</font> keyword, as well as introducing a statemen=
t, was also able to introduce an expression which returned:<br><br>* In the=
 case where there is an else clause:=C2=A0 the std::common_type of its true=
 and false clauses<br>* In the case where there is no else clause: a std::o=
ptional&lt;T&gt; where T is the expression type of the true case.<br><br>?<=
br><br>e.g.<br><br><font face=3D"monospace, monospace">// x is an int<br>au=
to x =3D if(auto p =3D something(); p) p-&gt;get_int() else 1234;<br><br>//=
 y is bool<br>auto y =3D if(something()) true else false;<br><br>// z=C2=A0=
 is std::optional&lt;int&gt;<br>auto z =3D if(<span style=3D"color:rgb(34,3=
4,34);font-size:small;font-style:normal;font-variant-ligatures:normal;font-=
variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;=
text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;bac=
kground-color:rgb(255,255,255);text-decoration-style:initial;text-decoratio=
n-color:initial;float:none;display:inline">auto p =3D something(); p) p-&gt=
;get_int();<br></span></font><br><br></div></blockquote><div><br><br></div>=
<div>This is something that I&#39;ve wanted for `for` loops as well.<br><br=
></div><div>auto x =3D for(auto const &amp; e : v) if (pred(e)) break e;<br=
><br></div><div>(of course, you could just call std::find)<br><br></div><di=
v>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br><=
/div><div><div class=3D"h5"><div class=3D"gmail_extra"><br><div class=3D"gm=
ail_quote">On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <span dir=3D"lt=
r">&lt;<a href=3D"mailto:gasper.azman@gmail.com" target=3D"_blank">gasper.a=
zman@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div=
 dir=3D"ltr">Honestly it feels more like a missing feature to me than an ex=
tension to me at this point - I&#39;d be glad to support this paper in the =
BSI, as long as I agreed with the final text of course.<div><br></div><div>=
It&#39;s a fairly small, well contained, and &quot;obvious&quot; extension,=
 what with the if-statement-with-initializer already having figured out all=
 the corner-cases. All we&#39;re doing is transplanting that into the condi=
tional operator. That is, if we can make the grammar work out to not enormo=
usly complicate the parser :).</div><div><br></div><div>G</div></div><div><=
div class=3D"m_7707034446442086071h5"><div class=3D"gmail_extra"><br><div c=
lass=3D"gmail_quote">On Wed, Apr 4, 2018 at 7:10 PM,  <span dir=3D"ltr">&lt=
;<a href=3D"mailto:hamza_sood@me.com" target=3D"_blank">hamza_sood@me.com</=
a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><sp=
an><br><br>On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=
=BEman wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-lef=
t:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">howev=
er, I&#39;d still prefer if it looked more like the if-statement with initi=
alizer:<div><br></div><div>(auto x =3D function(); p(x)) ? z(x) : y(x);</di=
v><div><br></div><div>where</div><div>- p(x) is a predicate of x (perhaps j=
ust an automatic contextual conversion to bool, if omitted)</div><div>- z(x=
) and y(x) are arbitrary expressions in x (perhaps not mentioning x at all)=
</div></div></blockquote><div><br></div></span><div>Good idea! It=E2=80=99d=
 made sense for that to work too.</div><div><br></div><div>So what=E2=80=99=
s the consensus here? Is it worth starting work on a paper yet?</div></div>=
<span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/2fe5=
d081-e13f-4750-87b0-a3b5b<wbr>47eb252%40isocpp.org</a>.<br>
</blockquote></div><br></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@isoc<wbr>pp.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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/=
std-proposals<wbr>/CAANG%3DkWVYp%3DSyO3wkiSWYNTc<wbr>ZgTNwrB0FmZOKqPfACuZNg=
FDoA%<wbr>40mail.gmail.com</a>.<br>
</blockquote></div><br></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@<wbr>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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbx1X81NWBaS4o2ScsA%2Bnuy%3D%2=
BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=
=3Dfooter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/=
msgid/std-<wbr>proposals/<wbr>CALvx3hYbx1X81NWBaS4o2ScsA%<wbr>2Bnuy%3D%2BgY=
WJirtN%2BZdPgCP_<wbr>0ug%40mail.gmail.com</a>.<br>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div>Be seeing =
you,<br></div>Tony<br></div></div>
</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/CAOHCbis-i4i%3DsKCFkwaHU7Q6VkHipdJFVU=
CBqJsT5hOg_-OAUg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbis-i4i%3D=
sKCFkwaHU7Q6VkHipdJFVUCBqJsT5hOg_-OAUg%40mail.gmail.com</a>.<br />

--00000000000021a1c405690a4b92--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Wed, 4 Apr 2018 20:55:29 +0200
Raw View
--000000000000eee6cc05690a5d98
Content-Type: text/plain; charset="UTF-8"

On 4 April 2018 at 20:41, Nicol Bolas <jmckesson@gmail.com> wrote:

>
>
> On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, Richard Hodges wrote:
>>
>> Just a thought, but how badly would it mangle the language if the if
>> keyword, as well as introducing a statement, was also able to introduce an
>> expression which returned:
>>
>> * In the case where there is an else clause:  the std::common_type of its
>> true and false clauses
>> * In the case where there is no else clause: a std::optional<T> where T
>> is the expression type of the true case.
>>
>
> I don't like the idea of implicitly tying syntax into a standard library
> type like `optional` in this way. We should just require that
> if-expressions have an `else` clause.
>

I equivocated on this point myself, feeling that a "value or nothing"
result was useful. Of course that leads directly into, "why should it not
return an outcome<>"... and that I think leads to Gasper's argument for
just using a lambda.

So I think I am persuaded that the std::common_type<> is sufficient.


>
> Otherwise, the idea of an if-expression seems to be a solid one. This
> formulation also solves other problems; since it uses `if` as an
> introducer, it can use `if constexpr` as an introducer as well for
> `constexpr` initializations.
>
> --
> 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/0f06146e-ae61-4c74-
> b09d-07dae4aa058f%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae4aa058f%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/CALvx3haNnehD4fpuzbHr2DeiXA154eCgmtbJrP680y4uzBgbCg%40mail.gmail.com.

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 4 April 2018 at 20:41, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"=
mailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</=
span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=
=3D""><br><br>On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, Richard Hodg=
es 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">Just a th=
ought, but how badly would it mangle the language if the <font face=3D"mono=
space, monospace">if</font> keyword, as well as introducing a statement, wa=
s also able to introduce an expression which returned:<br><br>* In the case=
 where there is an else clause:=C2=A0 the std::common_type of its true and =
false clauses<br>* In the case where there is no else clause: a std::option=
al&lt;T&gt; where T is the expression type of the true case.<br></div></blo=
ckquote></span><div><br>I don&#39;t like the idea of implicitly tying synta=
x into a standard library type like `optional` in this way. We should just =
require that if-expressions have an `else` clause.<br></div></div></blockqu=
ote><div><br></div><div>I equivocated on this point myself, feeling that a =
&quot;value or nothing&quot; result was useful. Of course that leads direct=
ly into, &quot;why should it not return an outcome&lt;&gt;&quot;... and tha=
t I think leads to Gasper&#39;s argument for just using a lambda.<br></div>=
<div><br></div><div>So I think I am persuaded that the std::common_type&lt;=
&gt; is sufficient.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"ltr"><div><br>Otherwise, the idea of an if-expression seems to be=
 a solid one. This formulation also solves other problems; since it uses `i=
f` as an introducer, it can use `if constexpr` as an introducer as well for=
 `constexpr` initializations.<br></div></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae4aa058f%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/0f06=
146e-ae61-4c74-<wbr>b09d-07dae4aa058f%40isocpp.org</a><wbr>.<br>
</blockquote></div><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/CALvx3haNnehD4fpuzbHr2DeiXA154eCgmtbJ=
rP680y4uzBgbCg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3haNnehD4fpu=
zbHr2DeiXA154eCgmtbJrP680y4uzBgbCg%40mail.gmail.com</a>.<br />

--000000000000eee6cc05690a5d98--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 4 Apr 2018 19:55:55 +0100
Raw View
--94eb2c0b42b0aa821c05690a60cf
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

auto x =3D [&]{ for (auto const& e : v) { if (pred(e)) return
std::make_optional(e); return std::nullopt; }}()?

On Wed, Apr 4, 2018 at 7:50 PM, Tony V E <tvaneerd@gmail.com> wrote:

>
>
> On Wed, Apr 4, 2018 at 2:23 PM, Richard Hodges <hodges.r@gmail.com> wrote=
:
>
>> Just a thought, but how badly would it mangle the language if the if
>> keyword, as well as introducing a statement, was also able to introduce =
an
>> expression which returned:
>>
>> * In the case where there is an else clause:  the std::common_type of it=
s
>> true and false clauses
>> * In the case where there is no else clause: a std::optional<T> where T
>> is the expression type of the true case.
>>
>> ?
>>
>> e.g.
>>
>> // x is an int
>> auto x =3D if(auto p =3D something(); p) p->get_int() else 1234;
>>
>> // y is bool
>> auto y =3D if(something()) true else false;
>>
>> // z  is std::optional<int>
>> auto z =3D if(auto p =3D something(); p) p->get_int();
>>
>>
>>
>
> This is something that I've wanted for `for` loops as well.
>
> auto x =3D for(auto const & e : v) if (pred(e)) break e;
>
> (of course, you could just call std::find)
>
>
>
>>
>>
>>
>> On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com=
> wrote:
>>
>>> Honestly it feels more like a missing feature to me than an extension t=
o
>>> me at this point - I'd be glad to support this paper in the BSI, as lon=
g as
>>> I agreed with the final text of course.
>>>
>>> It's a fairly small, well contained, and "obvious" extension, what with
>>> the if-statement-with-initializer already having figured out all the
>>> corner-cases. All we're doing is transplanting that into the conditiona=
l
>>> operator. That is, if we can make the grammar work out to not enormousl=
y
>>> complicate the parser :).
>>>
>>> G
>>>
>>> On Wed, Apr 4, 2018 at 7:10 PM, <hamza_sood@me.com> wrote:
>>>
>>>>
>>>>
>>>> On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman =
wrote:
>>>>>
>>>>> however, I'd still prefer if it looked more like the if-statement wit=
h
>>>>> initializer:
>>>>>
>>>>> (auto x =3D function(); p(x)) ? z(x) : y(x);
>>>>>
>>>>> where
>>>>> - p(x) is a predicate of x (perhaps just an automatic contextual
>>>>> conversion to bool, if omitted)
>>>>> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentionin=
g
>>>>> x at all)
>>>>>
>>>>
>>>> Good idea! It=E2=80=99d made sense for that to work too.
>>>>
>>>> So what=E2=80=99s the consensus here? Is it worth starting work on a p=
aper yet?
>>>>
>>>> --
>>>> 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/i=
s
>>>> ocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b
>>>> 47eb252%40isocpp.org
>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2fe5d081=
-e13f-4750-87b0-a3b5b47eb252%40isocpp.org?utm_medium=3Demail&utm_source=3Df=
ooter>
>>>> .
>>>>
>>>
>>> --
>>> 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/is
>>> ocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTc
>>> ZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3Dk=
WVYp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=
=3Demail&utm_source=3Dfooter>
>>> .
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/CALvx3hYbx1X81NWBaS4o2ScsA%2B
>> nuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbx=
1X81NWBaS4o2ScsA%2Bnuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_medi=
um=3Demail&utm_source=3Dfooter>
>> .
>>
>
>
>
> --
> Be seeing you,
> Tony
>
> --
> 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/CAOHCbis-i4i%
> 3DsKCFkwaHU7Q6VkHipdJFVUCBqJsT5hOg_-OAUg%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbis-i4=
i%3DsKCFkwaHU7Q6VkHipdJFVUCBqJsT5hOg_-OAUg%40mail.gmail.com?utm_medium=3Dem=
ail&utm_source=3Dfooter>
> .
>

--=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/CAANG%3DkXrg9QU%3Dwk-DOjU7ypRSHhBiBTzLcx8_jpvsNS=
%2BVeiFRg%40mail.gmail.com.

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

<div dir=3D"ltr">auto x =3D [&amp;]{ for (auto const&amp; e : v) { if (pred=
(e)) return std::make_optional(e); return std::nullopt; }}()?</div><div cla=
ss=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, 2018 at 7:=
50 PM, Tony V E <span dir=3D"ltr">&lt;<a href=3D"mailto:tvaneerd@gmail.com"=
 target=3D"_blank">tvaneerd@gmail.com</a>&gt;</span> wrote:<br><blockquote =
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid=
;padding-left:1ex"><div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div=
 class=3D"gmail_quote"><span class=3D"">On Wed, Apr 4, 2018 at 2:23 PM, Ric=
hard Hodges <span dir=3D"ltr">&lt;<a href=3D"mailto:hodges.r@gmail.com" tar=
get=3D"_blank">hodges.r@gmail.com</a>&gt;</span> wrote:<br><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div dir=3D"ltr">Just a thought, but how badly would it mang=
le the language if the <font face=3D"monospace, monospace">if</font> keywor=
d, as well as introducing a statement, was also able to introduce an expres=
sion which returned:<br><br>* In the case where there is an else clause:=C2=
=A0 the std::common_type of its true and false clauses<br>* In the case whe=
re there is no else clause: a std::optional&lt;T&gt; where T is the express=
ion type of the true case.<br><br>?<br><br>e.g.<br><br><font face=3D"monosp=
ace, monospace">// x is an int<br>auto x =3D if(auto p =3D something(); p) =
p-&gt;get_int() else 1234;<br><br>// y is bool<br>auto y =3D if(something()=
) true else false;<br><br>// z=C2=A0 is std::optional&lt;int&gt;<br>auto z =
=3D if(<span style=3D"color:rgb(34,34,34);font-size:small;font-style:normal=
;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;let=
ter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;whi=
te-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-dec=
oration-style:initial;text-decoration-color:initial;float:none;display:inli=
ne">auto p =3D something(); p) p-&gt;get_int();<br></span></font><br><br></=
div></blockquote><div><br><br></div></span><div>This is something that I&#3=
9;ve wanted for `for` loops as well.<br><br></div><div>auto x =3D for(auto =
const &amp; e : v) if (pred(e)) break e;<br><br></div><div>(of course, you =
could just call std::find)<br><br></div><div><div class=3D"h5"><div>=C2=A0<=
br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><br></div><div=
><div class=3D"m_-6626269311515332757h5"><div class=3D"gmail_extra"><br><di=
v class=3D"gmail_quote">On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <s=
pan dir=3D"ltr">&lt;<a href=3D"mailto:gasper.azman@gmail.com" target=3D"_bl=
ank">gasper.azman@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr">Honestly it feels more like a missing feature to =
me than an extension to me at this point - I&#39;d be glad to support this =
paper in the BSI, as long as I agreed with the final text of course.<div><b=
r></div><div>It&#39;s a fairly small, well contained, and &quot;obvious&quo=
t; extension, what with the if-statement-with-initializer already having fi=
gured out all the corner-cases. All we&#39;re doing is transplanting that i=
nto the conditional operator. That is, if we can make the grammar work out =
to not enormously complicate the parser :).</div><div><br></div><div>G</div=
></div><div><div class=3D"m_-6626269311515332757m_7707034446442086071h5"><d=
iv class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, 2018=
 at 7:10 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_sood@me.com" ta=
rget=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrote:<br><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div dir=3D"ltr"><span><br><br>On Tuesday, April 3, 2018 at =
8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wrote:<blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex"><div dir=3D"ltr">however, I&#39;d still prefer if it looked mor=
e like the if-statement with initializer:<div><br></div><div>(auto x =3D fu=
nction(); p(x)) ? z(x) : y(x);</div><div><br></div><div>where</div><div>- p=
(x) is a predicate of x (perhaps just an automatic contextual conversion to=
 bool, if omitted)</div><div>- z(x) and y(x) are arbitrary expressions in x=
 (perhaps not mentioning x at all)</div></div></blockquote><div><br></div><=
/span><div>Good idea! It=E2=80=99d made sense for that to work too.</div><d=
iv><br></div><div>So what=E2=80=99s the consensus here? Is it worth startin=
g work on a paper yet?</div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/2fe5=
d081-e13f-4750-87b0-a3b5b<wbr>47eb252%40isocpp.org</a>.<br>
</blockquote></div><br></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@isoc<wbr>pp.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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/=
std-proposals<wbr>/CAANG%3DkWVYp%3DSyO3wkiSWYNTc<wbr>ZgTNwrB0FmZOKqPfACuZNg=
FDoA%40m<wbr>ail.gmail.com</a>.<br>
</blockquote></div><br></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@isoc<wbr>pp.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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbx1X81NWBaS4o2ScsA%2Bnuy%3D%2=
BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=
=3Dfooter" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/=
msgid/std-proposals<wbr>/CALvx3hYbx1X81NWBaS4o2ScsA%2B<wbr>nuy%3D%2BgYWJirt=
N%2BZdPgCP_0ug<wbr>%40mail.gmail.com</a>.<br>
</blockquote></div></div></div><br><br clear=3D"all"><br>-- <br><div class=
=3D"m_-6626269311515332757gmail_signature" data-smartmail=3D"gmail_signatur=
e"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></div></div>
</div></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbis-i4i%3DsKCFkwaHU7Q6VkHipdJFVU=
CBqJsT5hOg_-OAUg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/st=
d-<wbr>proposals/CAOHCbis-i4i%<wbr>3DsKCFkwaHU7Q6VkHipdJFVUCBqJsT<wbr>5hOg_=
-OAUg%40mail.gmail.com</a>.<br>
</blockquote></div><br></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/CAANG%3DkXrg9QU%3Dwk-DOjU7ypRSHhBiBTz=
Lcx8_jpvsNS%2BVeiFRg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkXr=
g9QU%3Dwk-DOjU7ypRSHhBiBTzLcx8_jpvsNS%2BVeiFRg%40mail.gmail.com</a>.<br />

--94eb2c0b42b0aa821c05690a60cf--

.


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Wed, 4 Apr 2018 19:59:05 +0100
Raw View
--94eb2c140702f6efe205690a6bce
Content-Type: text/plain; charset="UTF-8"

Richard, I think the if-expression has the issue of being a compound
statement, and therefore lifetimes get jumbled - basically, the semantics
would *have* to be defined as if it were a lambda, and at that point we're
just arguing for shorthand immediately-invoked-lambda syntax for a
particular purpose.

At which point it's just easier to start *actually* arguing about
immediately-invoked lambdas, because the lambda introducer is one hell of a
way to tell the parser that it needs to do special stuff.

G

On Wed, Apr 4, 2018 at 7:55 PM, Richard Hodges <hodges.r@gmail.com> wrote:

>
>
> On 4 April 2018 at 20:41, Nicol Bolas <jmckesson@gmail.com> wrote:
>
>>
>>
>> On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, Richard Hodges wrote:
>>>
>>> Just a thought, but how badly would it mangle the language if the if
>>> keyword, as well as introducing a statement, was also able to introduce an
>>> expression which returned:
>>>
>>> * In the case where there is an else clause:  the std::common_type of
>>> its true and false clauses
>>> * In the case where there is no else clause: a std::optional<T> where T
>>> is the expression type of the true case.
>>>
>>
>> I don't like the idea of implicitly tying syntax into a standard library
>> type like `optional` in this way. We should just require that
>> if-expressions have an `else` clause.
>>
>
> I equivocated on this point myself, feeling that a "value or nothing"
> result was useful. Of course that leads directly into, "why should it not
> return an outcome<>"... and that I think leads to Gasper's argument for
> just using a lambda.
>
> So I think I am persuaded that the std::common_type<> is sufficient.
>
>
>>
>> Otherwise, the idea of an if-expression seems to be a solid one. This
>> formulation also solves other problems; since it uses `if` as an
>> introducer, it can use `if constexpr` as an introducer as well for
>> `constexpr` initializations.
>>
>> --
>> 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/is
>> ocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-
>> 07dae4aa058f%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae4aa058f%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/CALvx3haNnehD4fpuzbHr2DeiXA154
> eCgmtbJrP680y4uzBgbCg%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3haNnehD4fpuzbHr2DeiXA154eCgmtbJrP680y4uzBgbCg%40mail.gmail.com?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/CAANG%3DkUHEkkvHpH5OvpmNF025KeFhJqHQCZFO-1gxDNjK5dFOQ%40mail.gmail.com.

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

<div dir=3D"ltr">Richard, I think the if-expression has the issue of being =
a compound statement, and therefore lifetimes get jumbled - basically, the =
semantics would *have* to be defined as if it were a lambda, and at that po=
int we&#39;re just arguing for shorthand immediately-invoked-lambda syntax =
for a particular purpose.<div><br></div><div>At which point it&#39;s just e=
asier to start *actually* arguing about immediately-invoked lambdas, becaus=
e the lambda introducer is one hell of a way to tell the parser that it nee=
ds to do special stuff.</div><div><br></div><div>G</div></div><div class=3D=
"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, 2018 at 7:55 PM=
, Richard Hodges <span dir=3D"ltr">&lt;<a href=3D"mailto:hodges.r@gmail.com=
" target=3D"_blank">hodges.r@gmail.com</a>&gt;</span> wrote:<br><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><di=
v class=3D"gmail_quote"><span class=3D"">On 4 April 2018 at 20:41, Nicol Bo=
las <span dir=3D"ltr">&lt;<a href=3D"mailto:jmckesson@gmail.com" target=3D"=
_blank">jmckesson@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr"><span><br><br>On Wednesday, April 4, 2018 at 2:23=
:43 PM UTC-4, Richard Hodges 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">Just a thought, but how badly would it mangle the languag=
e if the <font face=3D"monospace, monospace">if</font> keyword, as well as =
introducing a statement, was also able to introduce an expression which ret=
urned:<br><br>* In the case where there is an else clause:=C2=A0 the std::c=
ommon_type of its true and false clauses<br>* In the case where there is no=
 else clause: a std::optional&lt;T&gt; where T is the expression type of th=
e true case.<br></div></blockquote></span><div><br>I don&#39;t like the ide=
a of implicitly tying syntax into a standard library type like `optional` i=
n this way. We should just require that if-expressions have an `else` claus=
e.<br></div></div></blockquote><div><br></div></span><div>I equivocated on =
this point myself, feeling that a &quot;value or nothing&quot; result was u=
seful. Of course that leads directly into, &quot;why should it not return a=
n outcome&lt;&gt;&quot;... and that I think leads to Gasper&#39;s argument =
for just using a lambda.<br></div><div><br></div><div>So I think I am persu=
aded that the std::common_type&lt;&gt; is sufficient.</div><span class=3D""=
><div>=C2=A0</div><blockquote 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>=
Otherwise, the idea of an if-expression seems to be a solid one. This formu=
lation also solves other problems; since it uses `if` as an introducer, it =
can use `if constexpr` as an introducer as well for `constexpr` initializat=
ions.<br></div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae4aa058f%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/0f06=
146e-ae61-4c74-b09d-<wbr>07dae4aa058f%40isocpp.org</a>.<br>
</blockquote></span></div><br></div></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3haNnehD4fpuzbHr2DeiXA154eCgmtbJ=
rP680y4uzBgbCg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter"=
 target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-=
<wbr>proposals/<wbr>CALvx3haNnehD4fpuzbHr2DeiXA154<wbr>eCgmtbJrP680y4uzBgbC=
g%40mail.<wbr>gmail.com</a>.<br>
</blockquote></div><br></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/CAANG%3DkUHEkkvHpH5OvpmNF025KeFhJqHQC=
ZFO-1gxDNjK5dFOQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkUHEkkv=
HpH5OvpmNF025KeFhJqHQCZFO-1gxDNjK5dFOQ%40mail.gmail.com</a>.<br />

--94eb2c140702f6efe205690a6bce--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Wed, 4 Apr 2018 20:59:37 +0200
Raw View
--001a11402a56b7c60305690a6c0d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On 4 April 2018 at 20:55, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com> w=
rote:

> auto x =3D [&]{ for (auto const& e : v) { if (pred(e)) return
> std::make_optional(e); return std::nullopt; }}()?
>

sadly, results in "*<source>:10:96:* *error: *inconsistent types '
*std::optional<int>*' and '*std::nullopt_t*' deduced for lambda return type
<https://godbolt.org/#>"

But I agree - the immediately-invoked lambda is fit for purpose, if a
little tricky to type.


>
> On Wed, Apr 4, 2018 at 7:50 PM, Tony V E <tvaneerd@gmail.com> wrote:
>
>>
>>
>> On Wed, Apr 4, 2018 at 2:23 PM, Richard Hodges <hodges.r@gmail.com>
>> wrote:
>>
>>> Just a thought, but how badly would it mangle the language if the if
>>> keyword, as well as introducing a statement, was also able to introduce=
 an
>>> expression which returned:
>>>
>>> * In the case where there is an else clause:  the std::common_type of
>>> its true and false clauses
>>> * In the case where there is no else clause: a std::optional<T> where T
>>> is the expression type of the true case.
>>>
>>> ?
>>>
>>> e.g.
>>>
>>> // x is an int
>>> auto x =3D if(auto p =3D something(); p) p->get_int() else 1234;
>>>
>>> // y is bool
>>> auto y =3D if(something()) true else false;
>>>
>>> // z  is std::optional<int>
>>> auto z =3D if(auto p =3D something(); p) p->get_int();
>>>
>>>
>>>
>>
>> This is something that I've wanted for `for` loops as well.
>>
>> auto x =3D for(auto const & e : v) if (pred(e)) break e;
>>
>> (of course, you could just call std::find)
>>
>>
>>
>>>
>>>
>>>
>>> On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.co=
m> wrote:
>>>
>>>> Honestly it feels more like a missing feature to me than an extension
>>>> to me at this point - I'd be glad to support this paper in the BSI, as=
 long
>>>> as I agreed with the final text of course.
>>>>
>>>> It's a fairly small, well contained, and "obvious" extension, what wit=
h
>>>> the if-statement-with-initializer already having figured out all the
>>>> corner-cases. All we're doing is transplanting that into the condition=
al
>>>> operator. That is, if we can make the grammar work out to not enormous=
ly
>>>> complicate the parser :).
>>>>
>>>> G
>>>>
>>>> On Wed, Apr 4, 2018 at 7:10 PM, <hamza_sood@me.com> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Tuesday, April 3, 2018 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman=
 wrote:
>>>>>>
>>>>>> however, I'd still prefer if it looked more like the if-statement
>>>>>> with initializer:
>>>>>>
>>>>>> (auto x =3D function(); p(x)) ? z(x) : y(x);
>>>>>>
>>>>>> where
>>>>>> - p(x) is a predicate of x (perhaps just an automatic contextual
>>>>>> conversion to bool, if omitted)
>>>>>> - z(x) and y(x) are arbitrary expressions in x (perhaps not
>>>>>> mentioning x at all)
>>>>>>
>>>>>
>>>>> Good idea! It=E2=80=99d made sense for that to work too.
>>>>>
>>>>> So what=E2=80=99s the consensus here? Is it worth starting work on a =
paper yet?
>>>>>
>>>>> --
>>>>> 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, sen=
d
>>>>> 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
>>>>> /2fe5d081-e13f-4750-87b0-a3b5b47eb252%40isocpp.org
>>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2fe5d08=
1-e13f-4750-87b0-a3b5b47eb252%40isocpp.org?utm_medium=3Demail&utm_source=3D=
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/i=
s
>>>> ocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTc
>>>> ZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com
>>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3D=
kWVYp%3DSyO3wkiSWYNTcZgTNwrB0FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=
=3Demail&utm_source=3Dfooter>
>>>> .
>>>>
>>>
>>> --
>>> 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/is
>>> ocpp.org/d/msgid/std-proposals/CALvx3hYbx1X81NWBaS4o2ScsA%2B
>>> nuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYb=
x1X81NWBaS4o2ScsA%2Bnuy%3D%2BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_med=
ium=3Demail&utm_source=3Dfooter>
>>> .
>>>
>>
>>
>>
>> --
>> Be seeing you,
>> Tony
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/CAOHCbis-i4i%3DsKCFkwaHU7Q6Vk
>> HipdJFVUCBqJsT5hOg_-OAUg%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbis-i=
4i%3DsKCFkwaHU7Q6VkHipdJFVUCBqJsT5hOg_-OAUg%40mail.gmail.com?utm_medium=3De=
mail&utm_source=3Dfooter>
>> .
>>
>
> --
> 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/CAANG%3DkXrg9QU%
> 3Dwk-DOjU7ypRSHhBiBTzLcx8_jpvsNS%2BVeiFRg%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkXr=
g9QU%3Dwk-DOjU7ypRSHhBiBTzLcx8_jpvsNS%2BVeiFRg%40mail.gmail.com?utm_medium=
=3Demail&utm_source=3Dfooter>
> .
>

--=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/CALvx3haJHTDytw3pTZ0vR3ET4nw7QyvaymL5YZ8aNcNZFnx=
6yA%40mail.gmail.com.

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 4 April 2018 at 20:55, Ga=C5=A1per A=C5=BEman <span dir=3D"ltr">&lt;=
<a href=3D"mailto:gasper.azman@gmail.com" target=3D"_blank">gasper.azman@gm=
ail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr">auto x =3D [&amp;]{ for (auto const&amp; e : v) { if (pred(e)) return=
 std::make_optional(e); return std::nullopt; }}()?</div></blockquote><div><=
br></div><div>sadly, results in &quot;<a href=3D"https://godbolt.org/#" sty=
le=3D"box-sizing:border-box;background-color:rgb(245,245,245);color:rgb(35,=
82,124);text-decoration:underline;outline:-webkit-focus-ring-color auto 5px=
;font-family:Menlo,Monaco,Consolas,&quot;Courier New&quot;,monospace;font-s=
ize:13.3333px;font-style:normal;font-variant-ligatures:normal;font-variant-=
caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-ind=
ent:0px;text-transform:none;white-space:pre;word-spacing:0px"><b style=3D"b=
ox-sizing:border-box;font-weight:700">&lt;source&gt;:10:96:</b> <b style=3D=
"box-sizing:border-box;font-weight:700"><span style=3D"box-sizing:border-bo=
x;color:rgb(170,0,0)">error: </span></b>inconsistent types &#39;<b style=3D=
"box-sizing:border-box;font-weight:700">std::optional&lt;int&gt;</b>&#39; a=
nd &#39;<b style=3D"box-sizing:border-box;font-weight:700">std::nullopt_t</=
b>&#39; deduced for lambda return type</a>&quot;</div><div><br></div><div>B=
ut I agree - the immediately-invoked lambda is fit for purpose, if a little=
 tricky to type.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>=
<div class=3D"h5"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote"=
>On Wed, Apr 4, 2018 at 7:50 PM, Tony V E <span dir=3D"ltr">&lt;<a href=3D"=
mailto:tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gmail.com</a>&gt;</sp=
an> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div clas=
s=3D"gmail_extra"><br><div class=3D"gmail_quote"><span>On Wed, Apr 4, 2018 =
at 2:23 PM, Richard Hodges <span dir=3D"ltr">&lt;<a href=3D"mailto:hodges.r=
@gmail.com" target=3D"_blank">hodges.r@gmail.com</a>&gt;</span> wrote:<br><=
blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px=
 #ccc solid;padding-left:1ex"><div dir=3D"ltr">Just a thought, but how badl=
y would it mangle the language if the <font face=3D"monospace, monospace">i=
f</font> keyword, as well as introducing a statement, was also able to intr=
oduce an expression which returned:<br><br>* In the case where there is an =
else clause:=C2=A0 the std::common_type of its true and false clauses<br>* =
In the case where there is no else clause: a std::optional&lt;T&gt; where T=
 is the expression type of the true case.<br><br>?<br><br>e.g.<br><br><font=
 face=3D"monospace, monospace">// x is an int<br>auto x =3D if(auto p =3D s=
omething(); p) p-&gt;get_int() else 1234;<br><br>// y is bool<br>auto y =3D=
 if(something()) true else false;<br><br>// z=C2=A0 is std::optional&lt;int=
&gt;<br>auto z =3D if(<span style=3D"color:rgb(34,34,34);font-size:small;fo=
nt-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font=
-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-tra=
nsform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,25=
5,255);text-decoration-style:initial;text-decoration-color:initial;float:no=
ne;display:inline">auto p =3D something(); p) p-&gt;get_int();<br></span></=
font><br><br></div></blockquote><div><br><br></div></span><div>This is some=
thing that I&#39;ve wanted for `for` loops as well.<br><br></div><div>auto =
x =3D for(auto const &amp; e : v) if (pred(e)) break e;<br><br></div><div>(=
of course, you could just call std::find)<br><br></div><div><div class=3D"m=
_6775575160230060161h5"><div>=C2=A0<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><br><br></div><div><div class=3D"m_6775575160230060161m_-=
6626269311515332757h5"><div class=3D"gmail_extra"><br><div class=3D"gmail_q=
uote">On 4 April 2018 at 20:13, Ga=C5=A1per A=C5=BEman <span dir=3D"ltr">&l=
t;<a href=3D"mailto:gasper.azman@gmail.com" target=3D"_blank">gasper.azman@=
gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr">Honestly it feels more like a missing feature to me than an extens=
ion to me at this point - I&#39;d be glad to support this paper in the BSI,=
 as long as I agreed with the final text of course.<div><br></div><div>It&#=
39;s a fairly small, well contained, and &quot;obvious&quot; extension, wha=
t with the if-statement-with-initializer already having figured out all the=
 corner-cases. All we&#39;re doing is transplanting that into the condition=
al operator. That is, if we can make the grammar work out to not enormously=
 complicate the parser :).</div><div><br></div><div>G</div></div><div><div =
class=3D"m_6775575160230060161m_-6626269311515332757m_7707034446442086071h5=
"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, Apr 4, =
2018 at 7:10 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:hamza_sood@me.com=
" target=3D"_blank">hamza_sood@me.com</a>&gt;</span> wrote:<br><blockquote =
class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid=
;padding-left:1ex"><div dir=3D"ltr"><span><br><br>On Tuesday, April 3, 2018=
 at 8:44:18 PM UTC+1, Ga=C5=A1per A=C5=BEman wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr">however, I&#39;d still prefer if it looked=
 more like the if-statement with initializer:<div><br></div><div>(auto x =
=3D function(); p(x)) ? z(x) : y(x);</div><div><br></div><div>where</div><d=
iv>- p(x) is a predicate of x (perhaps just an automatic contextual convers=
ion to bool, if omitted)</div><div>- z(x) and y(x) are arbitrary expression=
s in x (perhaps not mentioning x at all)</div></div></blockquote><div><br><=
/div></span><div>Good idea! It=E2=80=99d made sense for that to work too.</=
div><div><br></div><div>So what=E2=80=99s the consensus here? Is it worth s=
tarting work on a paper yet?</div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2fe5d081-e13f-4750-87b0-a3b5b47eb252%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/2fe5=
d081-e13f-4750-87b0-a3b5b<wbr>47eb252%40isocpp.org</a>.<br>
</blockquote></div><br></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@isoc<wbr>pp.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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWVYp%3DSyO3wkiSWYNTcZgTNwrB0=
FmZOKqPfACuZNgFDoA%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/=
std-proposals<wbr>/CAANG%3DkWVYp%3DSyO3wkiSWYNTc<wbr>ZgTNwrB0FmZOKqPfACuZNg=
FDoA%40m<wbr>ail.gmail.com</a>.<br>
</blockquote></div><br></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@isoc<wbr>pp.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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3hYbx1X81NWBaS4o2ScsA%2Bnuy%3D%2=
BgYWJirtN%2BZdPgCP_0ug%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=
=3Dfooter" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/=
msgid/std-proposals<wbr>/CALvx3hYbx1X81NWBaS4o2ScsA%2B<wbr>nuy%3D%2BgYWJirt=
N%2BZdPgCP_0ug<wbr>%40mail.gmail.com</a>.<br>
</blockquote></div></div></div><br><br clear=3D"all"><br>-- <br><div class=
=3D"m_6775575160230060161m_-6626269311515332757gmail_signature" data-smartm=
ail=3D"gmail_signature"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<=
br></div></div>
</div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbis-i4i%3DsKCFkwaHU7Q6VkHipdJFVU=
CBqJsT5hOg_-OAUg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/st=
d-proposals<wbr>/CAOHCbis-i4i%3DsKCFkwaHU7Q6Vk<wbr>HipdJFVUCBqJsT5hOg_-OAUg=
%<wbr>40mail.gmail.com</a>.<br>
</blockquote></div><br></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@<wbr>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></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkXrg9QU%3Dwk-DOjU7ypRSHhBiBTz=
Lcx8_jpvsNS%2BVeiFRg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Df=
ooter" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgi=
d/std-<wbr>proposals/CAANG%3DkXrg9QU%<wbr>3Dwk-DOjU7ypRSHhBiBTzLcx8_<wbr>jp=
vsNS%2BVeiFRg%40mail.gmail.<wbr>com</a>.<br>
</blockquote></div><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/CALvx3haJHTDytw3pTZ0vR3ET4nw7QyvaymL5=
YZ8aNcNZFnx6yA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3haJHTDytw3p=
TZ0vR3ET4nw7QyvaymL5YZ8aNcNZFnx6yA%40mail.gmail.com</a>.<br />

--001a11402a56b7c60305690a6c0d--

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Wed, 4 Apr 2018 21:01:07 +0200
Raw View
--001a11402a561a448305690a7250
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On 4 April 2018 at 20:59, Ga=C5=A1per A=C5=BEman <gasper.azman@gmail.com> w=
rote:

> Richard, I think the if-expression has the issue of being a compound
> statement, and therefore lifetimes get jumbled - basically, the semantics
> would *have* to be defined as if it were a lambda, and at that point we'r=
e
> just arguing for shorthand immediately-invoked-lambda syntax for a
> particular purpose.
>
> At which point it's just easier to start *actually* arguing about
> immediately-invoked lambdas, because the lambda introducer is one hell of=
 a
> way to tell the parser that it needs to do special stuff.
>

Yes, on reflection I agree.

I think in my heart, I just want to be able to write c++ that looks like
perl...


>
> G
>
> On Wed, Apr 4, 2018 at 7:55 PM, Richard Hodges <hodges.r@gmail.com> wrote=
:
>
>>
>>
>> On 4 April 2018 at 20:41, Nicol Bolas <jmckesson@gmail.com> wrote:
>>
>>>
>>>
>>> On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, Richard Hodges wrote:
>>>>
>>>> Just a thought, but how badly would it mangle the language if the if
>>>> keyword, as well as introducing a statement, was also able to introduc=
e an
>>>> expression which returned:
>>>>
>>>> * In the case where there is an else clause:  the std::common_type of
>>>> its true and false clauses
>>>> * In the case where there is no else clause: a std::optional<T> where =
T
>>>> is the expression type of the true case.
>>>>
>>>
>>> I don't like the idea of implicitly tying syntax into a standard librar=
y
>>> type like `optional` in this way. We should just require that
>>> if-expressions have an `else` clause.
>>>
>>
>> I equivocated on this point myself, feeling that a "value or nothing"
>> result was useful. Of course that leads directly into, "why should it no=
t
>> return an outcome<>"... and that I think leads to Gasper's argument for
>> just using a lambda.
>>
>> So I think I am persuaded that the std::common_type<> is sufficient.
>>
>>
>>>
>>> Otherwise, the idea of an if-expression seems to be a solid one. This
>>> formulation also solves other problems; since it uses `if` as an
>>> introducer, it can use `if constexpr` as an introducer as well for
>>> `constexpr` initializations.
>>>
>>> --
>>> 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/is
>>> ocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae
>>> 4aa058f%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0f06146e-=
ae61-4c74-b09d-07dae4aa058f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
>>> .
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> 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/is
>> ocpp.org/d/msgid/std-proposals/CALvx3haNnehD4fpuzbHr2DeiXA15
>> 4eCgmtbJrP680y4uzBgbCg%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3haNn=
ehD4fpuzbHr2DeiXA154eCgmtbJrP680y4uzBgbCg%40mail.gmail.com?utm_medium=3Dema=
il&utm_source=3Dfooter>
>> .
>>
>
> --
> 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/CAANG%3DkUHEkkvHpH5OvpmNF025KeFhJqHQ
> CZFO-1gxDNjK5dFOQ%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkUH=
EkkvHpH5OvpmNF025KeFhJqHQCZFO-1gxDNjK5dFOQ%40mail.gmail.com?utm_medium=3Dem=
ail&utm_source=3Dfooter>
> .
>

--=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/CALvx3hYCs0E4ssOLyCFAX4YuZ-pULs1HXPmyXNqrUH4C%2B=
-e1ug%40mail.gmail.com.

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 4 April 2018 at 20:59, Ga=C5=A1per A=C5=BEman <span dir=3D"ltr">&lt;=
<a href=3D"mailto:gasper.azman@gmail.com" target=3D"_blank">gasper.azman@gm=
ail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr">Richard, I think the if-expression has the issue of being a compound =
statement, and therefore lifetimes get jumbled - basically, the semantics w=
ould *have* to be defined as if it were a lambda, and at that point we&#39;=
re just arguing for shorthand immediately-invoked-lambda syntax for a parti=
cular purpose.<div><br></div><div>At which point it&#39;s just easier to st=
art *actually* arguing about immediately-invoked lambdas, because the lambd=
a introducer is one hell of a way to tell the parser that it needs to do sp=
ecial stuff.</div></div></blockquote><div><br></div><div>Yes, on reflection=
 I agree.</div><div><br></div><div>I think in my heart, I just want to be a=
ble to write c++ that looks like perl...</div><div>=C2=A0</div><blockquote =
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>G</div></div><div c=
lass=3D"gmail_extra"><br><div class=3D"gmail_quote"><div><div class=3D"h5">=
On Wed, Apr 4, 2018 at 7:55 PM, Richard Hodges <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:hodges.r@gmail.com" target=3D"_blank">hodges.r@gmail.com</a>&gt=
;</span> wrote:<br></div></div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div cla=
ss=3D"h5"><div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D=
"gmail_quote"><span>On 4 April 2018 at 20:41, Nicol Bolas <span dir=3D"ltr"=
>&lt;<a href=3D"mailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gma=
il.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"=
ltr"><span><br><br>On Wednesday, April 4, 2018 at 2:23:43 PM UTC-4, Richard=
 Hodges wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-le=
ft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Just=
 a thought, but how badly would it mangle the language if the <font face=3D=
"monospace, monospace">if</font> keyword, as well as introducing a statemen=
t, was also able to introduce an expression which returned:<br><br>* In the=
 case where there is an else clause:=C2=A0 the std::common_type of its true=
 and false clauses<br>* In the case where there is no else clause: a std::o=
ptional&lt;T&gt; where T is the expression type of the true case.<br></div>=
</blockquote></span><div><br>I don&#39;t like the idea of implicitly tying =
syntax into a standard library type like `optional` in this way. We should =
just require that if-expressions have an `else` clause.<br></div></div></bl=
ockquote><div><br></div></span><div>I equivocated on this point myself, fee=
ling that a &quot;value or nothing&quot; result was useful. Of course that =
leads directly into, &quot;why should it not return an outcome&lt;&gt;&quot=
;... and that I think leads to Gasper&#39;s argument for just using a lambd=
a.<br></div><div><br></div><div>So I think I am persuaded that the std::com=
mon_type&lt;&gt; is sufficient.</div><span><div>=C2=A0</div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr"><div><br>Otherwise, the idea of an if-expr=
ession seems to be a solid one. This formulation also solves other problems=
; since it uses `if` as an introducer, it can use `if constexpr` as an intr=
oducer as well for `constexpr` initializations.<br></div></div><span>

<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@isoc<wbr>pp.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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0f06146e-ae61-4c74-b09d-07dae4aa058f%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-proposals<wbr>/0f06=
146e-ae61-4c74-b09d-07dae<wbr>4aa058f%40isocpp.org</a>.<br>
</blockquote></span></div><br></div></div><span>

<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@isoc<wbr>pp.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></span></div></div=
>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CALvx3haNnehD4fpuzbHr2DeiXA154eCgmtbJ=
rP680y4uzBgbCg%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfooter"=
 target=3D"_blank">https://groups.google.com/a/is<wbr>ocpp.org/d/msgid/std-=
proposals<wbr>/CALvx3haNnehD4fpuzbHr2DeiXA15<wbr>4eCgmtbJrP680y4uzBgbCg%40m=
ail.<wbr>gmail.com</a>.<br>
</blockquote></div><br></div><span class=3D"">

<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@<wbr>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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkUHEkkvHpH5OvpmNF025KeFhJqHQC=
ZFO-1gxDNjK5dFOQ%40mail.gmail.com?utm_medium=3Demail&amp;utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/st=
d-<wbr>proposals/CAANG%<wbr>3DkUHEkkvHpH5OvpmNF025KeFhJqHQ<wbr>CZFO-1gxDNjK=
5dFOQ%40mail.<wbr>gmail.com</a>.<br>
</blockquote></div><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/CALvx3hYCs0E4ssOLyCFAX4YuZ-pULs1HXPmy=
XNqrUH4C%2B-e1ug%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYCs0E4ss=
OLyCFAX4YuZ-pULs1HXPmyXNqrUH4C%2B-e1ug%40mail.gmail.com</a>.<br />

--001a11402a561a448305690a7250--

.


Author: Magnus Fromreide <magfr@lysator.liu.se>
Date: Thu, 5 Apr 2018 10:49:46 +0200
Raw View
On Tue, Apr 03, 2018 at 08:43:55PM +0100, Ga=C5=A1per A=C5=BEman wrote:
> I think if anything it unifies the conditional operator with if-statement=
s;
> however, I'd still prefer if it looked more like the if-statement with
> initializer:
>=20
> (auto x =3D function(); p(x)) ? z(x) : y(x);

This do look extremely similar to another GNU extension - statement
expressions:

({ auto x =3D function(); p(x) ? z(x) : y(x); })

Now, that one have also been up in the committe and have been rejected but =
it
is arguably even more powerful.

This differs from

[&]{ auto x =3D function(); return p(x) ? z(x) : y(x); }()

in that an embedded return in an expression statement leaves the containing
function, and embedded break, continue and goto also operate on the contain=
ing
function.

/MF

> where
> - p(x) is a predicate of x (perhaps just an automatic contextual conversi=
on
> to bool, if omitted)
> - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning x =
at
> all)
>=20
> It *does* go further than the gnu extension, in a *far* more useful way.
>=20
> G
>=20
> On Tue, Apr 3, 2018 at 4:06 PM, <hamza_sood@me.com> wrote:
>=20
> > On Tuesday, April 3, 2018 at 3:42:10 PM UTC+1, Richard Hodges wrote:
> >>
> >> This is perhaps true. From what I've read the risk might be that it ge=
ts
> >> pushed back because it's essentially doing nothing more than introduci=
ng
> >> some shorthand, as opposed to new functionality that was previously
> >> difficult or unwieldy.
> >>
> >
> > While that's a good point that's definitely worth keeping in mind, have=
n't
> > there been quite a few minor shorthand features accepted recently? The
> > first one that springs to mind is if statement initialisers
> > <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305r0.html> =
in
> > C++17: it didn't really bring any new functionality and it isn't
> > particularly difficult to write an explicit scope (arguably much simple=
r
> > than the lambda-based alternatives to this proposal discussed here). I
> > don't mean that in a bad way; I love shorthand notation and I'm enjoyin=
g
> > using if statements with initialisers. But I think it makes a good
> > comparison with this proposal.
> >
> > --
> > You received this message because you are subscribed to the Google Grou=
ps
> > "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/820d844c-21a7-429c-
> > bf55-17ee12f8ca8e%40isocpp.org
> > <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/820d844c-=
21a7-429c-bf55-17ee12f8ca8e%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
> > .
> >
>=20
> --=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=
 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/isoc=
pp.org/d/msgid/std-proposals/CAANG%3DkX5nk%3DtVyY1fvzFppy8XEcqxMTtAh_PMSGHH=
iE%3DcgXQZw%40mail.gmail.com.

--=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/20180405084946.GA7056%40noemi.bahnhof.se.

.


Author: Richard Hodges <hodges.r@gmail.com>
Date: Thu, 5 Apr 2018 10:38:19 +0100
Raw View
--00000000000032d316056916b346
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On 5 April 2018 at 09:49, Magnus Fromreide <magfr@lysator.liu.se> wrote:

> On Tue, Apr 03, 2018 at 08:43:55PM +0100, Ga=C5=A1per A=C5=BEman wrote:
> > I think if anything it unifies the conditional operator with
> if-statements;
> > however, I'd still prefer if it looked more like the if-statement with
> > initializer:
> >
> > (auto x =3D function(); p(x)) ? z(x) : y(x);
>
> This do look extremely similar to another GNU extension - statement
> expressions:
>
> ({ auto x =3D function(); p(x) ? z(x) : y(x); })
>

This would be incredibly useful!

>
> Now, that one have also been up in the committe and have been rejected bu=
t
> it
> is arguably even more powerful.
>
>
Why? It's so obviously beneficial.


> This differs from
>
> [&]{ auto x =3D function(); return p(x) ? z(x) : y(x); }()
>
> in that an embedded return in an expression statement leaves the containi=
ng
> function, and embedded break, continue and goto also operate on the
> containing
> function.
>
> /MF
>
> > where
> > - p(x) is a predicate of x (perhaps just an automatic contextual
> conversion
> > to bool, if omitted)
> > - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning =
x
> at
> > all)
> >
> > It *does* go further than the gnu extension, in a *far* more useful way=
..
> >
> > G
> >
> > On Tue, Apr 3, 2018 at 4:06 PM, <hamza_sood@me.com> wrote:
> >
> > > On Tuesday, April 3, 2018 at 3:42:10 PM UTC+1, Richard Hodges wrote:
> > >>
> > >> This is perhaps true. From what I've read the risk might be that it
> gets
> > >> pushed back because it's essentially doing nothing more than
> introducing
> > >> some shorthand, as opposed to new functionality that was previously
> > >> difficult or unwieldy.
> > >>
> > >
> > > While that's a good point that's definitely worth keeping in mind,
> haven't
> > > there been quite a few minor shorthand features accepted recently? Th=
e
> > > first one that springs to mind is if statement initialisers
> > > <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0305r0.html=
>
> in
> > > C++17: it didn't really bring any new functionality and it isn't
> > > particularly difficult to write an explicit scope (arguably much
> simpler
> > > than the lambda-based alternatives to this proposal discussed here). =
I
> > > don't mean that in a bad way; I love shorthand notation and I'm
> enjoying
> > > using if statements with initialisers. But I think it makes a good
> > > comparison with this proposal.
> > >
> > > --
> > > 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, sen=
d
> 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/820d844c-21a7-429c-
> > > bf55-17ee12f8ca8e%40isocpp.org
> > > <https://groups.google.com/a/isocpp.org/d/msgid/std-
> proposals/820d844c-21a7-429c-bf55-17ee12f8ca8e%40isocpp.
> org?utm_medium=3Demail&utm_source=3Dfooter>
> > > .
> > >
> >
> > --
> > 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/CAANG%3DkX5nk%3DtVyY1fvzFppy8XEcqxMTtAh_
> PMSGHHiE%3DcgXQZw%40mail.gmail.com.
>
> --
> 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/20180405084946.GA7056%40noemi.bahnhof.se=
..
>

--=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/CALvx3hYTX1LxoveHjj2TpdQQFrAgnxvdeYn_z1wGNW6wYDP=
VaA%40mail.gmail.com.

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 5 April 2018 at 09:49, Magnus Fromreide <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:magfr@lysator.liu.se" target=3D"_blank">magfr@lysator.liu.se</a=
>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=3D"">On T=
ue, Apr 03, 2018 at 08:43:55PM +0100, Ga=C5=A1per A=C5=BEman wrote:<br>
&gt; I think if anything it unifies the conditional operator with if-statem=
ents;<br>
&gt; however, I&#39;d still prefer if it looked more like the if-statement =
with<br>
&gt; initializer:<br>
&gt;<br>
&gt; (auto x =3D function(); p(x)) ? z(x) : y(x);<br>
<br>
</span>This do look extremely similar to another GNU extension - statement<=
br>
expressions:<br>
<br>
({ auto x =3D function(); p(x) ? z(x) : y(x); })<br></blockquote><div><br><=
/div><div>This would be incredibly useful!=C2=A0</div><blockquote class=3D"=
gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-=
left:1ex">
<br>
Now, that one have also been up in the committe and have been rejected but =
it<br>
is arguably even more powerful.<br>
<br></blockquote><div><br></div><div>Why? It&#39;s so obviously beneficial.=
</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This differs from<br>
<br>
[&amp;]{ auto x =3D function(); return p(x) ? z(x) : y(x); }()<br>
<br>
in that an embedded return in an expression statement leaves the containing=
<br>
function, and embedded break, continue and goto also operate on the contain=
ing<br>
function.<br>
<br>
/MF<br>
<span class=3D""><br>
&gt; where<br>
&gt; - p(x) is a predicate of x (perhaps just an automatic contextual conve=
rsion<br>
&gt; to bool, if omitted)<br>
&gt; - z(x) and y(x) are arbitrary expressions in x (perhaps not mentioning=
 x at<br>
&gt; all)<br>
&gt;<br>
&gt; It *does* go further than the gnu extension, in a *far* more useful wa=
y.<br>
&gt;<br>
&gt; G<br>
&gt;<br>
&gt; On Tue, Apr 3, 2018 at 4:06 PM, &lt;<a href=3D"mailto:hamza_sood@me.co=
m">hamza_sood@me.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; On Tuesday, April 3, 2018 at 3:42:10 PM UTC+1, Richard Hodges wro=
te:<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt; This is perhaps true. From what I&#39;ve read the risk might =
be that it gets<br>
&gt; &gt;&gt; pushed back because it&#39;s essentially doing nothing more t=
han introducing<br>
&gt; &gt;&gt; some shorthand, as opposed to new functionality that was prev=
iously<br>
&gt; &gt;&gt; difficult or unwieldy.<br>
&gt; &gt;&gt;<br>
&gt; &gt;<br>
&gt; &gt; While that&#39;s a good point that&#39;s definitely worth keeping=
 in mind, haven&#39;t<br>
&gt; &gt; there been quite a few minor shorthand features accepted recently=
? The<br>
&gt; &gt; first one that springs to mind is if statement initialisers<br>
</span>&gt; &gt; &lt;<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs=
/papers/2016/p0305r0.html" rel=3D"noreferrer" target=3D"_blank">http://www.=
open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2016/<wbr>p0305r0.html</a>&gt;=
 in<br>
<span class=3D"">&gt; &gt; C++17: it didn&#39;t really bring any new functi=
onality and it isn&#39;t<br>
&gt; &gt; particularly difficult to write an explicit scope (arguably much =
simpler<br>
&gt; &gt; than the lambda-based alternatives to this proposal discussed her=
e). I<br>
&gt; &gt; don&#39;t mean that in a bad way; I love shorthand notation and I=
&#39;m enjoying<br>
&gt; &gt; using if statements with initialisers. But I think it makes a goo=
d<br>
&gt; &gt; comparison with this proposal.<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; You received this message because you are subscribed to the Googl=
e Groups<br>
&gt; &gt; &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
&gt; &gt; To unsubscribe from this group and stop receiving emails from it,=
 send an<br>
&gt; &gt; email to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org=
">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
&gt; &gt; To post to this group, send email to <a href=3D"mailto:std-propos=
als@isocpp.org">std-proposals@isocpp.org</a>.<br>
&gt; &gt; To view this discussion on the web visit <a href=3D"https://group=
s.google.com/a/" rel=3D"noreferrer" target=3D"_blank">https://groups.google=
..com/a/</a><br>
&gt; &gt; <a href=3D"http://isocpp.org/d/msgid/std-proposals/820d844c-21a7-=
429c-" rel=3D"noreferrer" target=3D"_blank">isocpp.org/d/msgid/std-<wbr>pro=
posals/820d844c-21a7-429c-</a><br>
&gt; &gt; bf55-17ee12f8ca8e%<a href=3D"http://40isocpp.org" rel=3D"noreferr=
er" target=3D"_blank">40isocpp.org</a><br>
</span>&gt; &gt; &lt;<a href=3D"https://groups.google.com/a/isocpp.org/d/ms=
gid/std-proposals/820d844c-21a7-429c-bf55-17ee12f8ca8e%40isocpp.org?utm_med=
ium=3Demail&amp;utm_source=3Dfooter" rel=3D"noreferrer" target=3D"_blank">h=
ttps://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/820d8=
44c-21a7-429c-<wbr>bf55-17ee12f8ca8e%40isocpp.<wbr>org?utm_medium=3Demail&a=
mp;utm_<wbr>source=3Dfooter</a>&gt;<br>
<span class=3D"">&gt; &gt; .<br>
&gt; &gt;<br>
&gt;<br>
&gt; --<br>
&gt; You received this message because you are subscribed to the Google Gro=
ups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
&gt; To unsubscribe from this group and stop receiving emails from it, send=
 an email to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-=
proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
&gt; To post to this group, send email to <a href=3D"mailto:std-proposals@i=
socpp.org">std-proposals@isocpp.org</a>.<br>
&gt; To view this discussion on the web visit <a href=3D"https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkX5nk%3DtVyY1fvzFppy8XEc=
qxMTtAh_PMSGHHiE%3DcgXQZw%40mail.gmail.com" rel=3D"noreferrer" target=3D"_b=
lank">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposal=
s/CAANG%3DkX5nk%<wbr>3DtVyY1fvzFppy8XEcqxMTtAh_<wbr>PMSGHHiE%3DcgXQZw%40mai=
l.<wbr>gmail.com</a>.<br>
<br>
</span><span class=3D"">--<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%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@<wbr>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>
</span>To view this discussion on the web visit <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/20180405084946.GA7056%40noemi.=
bahnhof.se" rel=3D"noreferrer" target=3D"_blank">https://groups.google.com/=
a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/20180405084946.<wbr>GA7056%40n=
oemi.bahnhof.se</a>.<br>
</blockquote></div><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/CALvx3hYTX1LxoveHjj2TpdQQFrAgnxvdeYn_=
z1wGNW6wYDPVaA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYTX1LxoveH=
jj2TpdQQFrAgnxvdeYn_z1wGNW6wYDPVaA%40mail.gmail.com</a>.<br />

--00000000000032d316056916b346--

.


Author: "'Johannes Schaub' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Thu, 05 Apr 2018 09:54:53 +0000
Raw View
--000000000000082aa6056916ef44
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Magnus Fromreide <magfr@lysator.liu.se> schrieb am Do., 5. Apr. 2018, 10:49=
:

> On Tue, Apr 03, 2018 at 08:43:55PM +0100, Ga=C5=A1per A=C5=BEman wrote:
> > I think if anything it unifies the conditional operator with
> if-statements;
> > however, I'd still prefer if it looked more like the if-statement with
> > initializer:
> >
> > (auto x =3D function(); p(x)) ? z(x) : y(x);
>
> This do look extremely similar to another GNU extension - statement
> expressions:
>
> ({ auto x =3D function(); p(x) ? z(x) : y(x); })
>
> Now, that one have also been up in the committe and have been rejected bu=
t
> it
> is arguably even more powerful
>

For adding up 1 and 2, you don't want to confuse primary school students
with complex number theory.

The 'declaration in ternary' feature doesn't allow statements inside of it.
So the issues known about mangling in dependent types won't come up with it=
..


This differs from
>
> [&]{ auto x =3D function(); return p(x) ? z(x) : y(x); }()
>
> in that an embedded return in an expression statement leaves the containi=
ng
> function, and embedded break, continue and goto also operate on the
> containing
> function


s/expression statement/statement expression/. Let's add more places one has
to think about when reasoning how a function or loop may terminate \o/

--=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/CANu6V4XJuNUQ%2Bvjve8dBELBBGkfTxB65hQNsC2a%3Dk-V=
3OwvSrQ%40mail.gmail.com.

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

<div dir=3D"auto"><br><br><div class=3D"gmail_quote" dir=3D"auto"><div dir=
=3D"ltr">Magnus Fromreide &lt;<a href=3D"mailto:magfr@lysator.liu.se">magfr=
@lysator.liu.se</a>&gt; schrieb am Do., 5. Apr. 2018, 10:49:<br></div><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #cc=
c solid;padding-left:1ex">On Tue, Apr 03, 2018 at 08:43:55PM +0100, Ga=C5=
=A1per A=C5=BEman wrote:<br>
&gt; I think if anything it unifies the conditional operator with if-statem=
ents;<br>
&gt; however, I&#39;d still prefer if it looked more like the if-statement =
with<br>
&gt; initializer:<br>
&gt;<br>
&gt; (auto x =3D function(); p(x)) ? z(x) : y(x);<br>
<br>
This do look extremely similar to another GNU extension - statement<br>
expressions:<br>
<br>
({ auto x =3D function(); p(x) ? z(x) : y(x); })<br>
<br>
Now, that one have also been up in the committe and have been rejected but =
it<br>
is arguably even more powerful<br></blockquote></div><div dir=3D"auto"><br>=
</div><div dir=3D"auto">For adding up 1 and 2, you don&#39;t want to confus=
e primary school students with complex number theory.=C2=A0</div><div dir=
=3D"auto"><br></div><div dir=3D"auto">The &#39;declaration in ternary&#39; =
feature doesn&#39;t allow statements inside of it. So the issues known abou=
t mangling in dependent types won&#39;t come up with it.</div><div dir=3D"a=
uto"><br></div><div dir=3D"auto"><br></div><div class=3D"gmail_quote" dir=
=3D"auto"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bord=
er-left:1px #ccc solid;padding-left:1ex">
This differs from<br>
<br>
[&amp;]{ auto x =3D function(); return p(x) ? z(x) : y(x); }()<br>
<br>
in that an embedded return in an expression statement leaves the containing=
<br>
function, and embedded break, continue and goto also operate on the contain=
ing<br>function</blockquote></div><div dir=3D"auto"><br></div><div dir=3D"a=
uto">s/expression statement/statement expression/. Let&#39;s add more place=
s one has to think about when reasoning how a function or loop may terminat=
e \o/</div><div dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div cla=
ss=3D"gmail_quote" dir=3D"auto"></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/CANu6V4XJuNUQ%2Bvjve8dBELBBGkfTxB65hQ=
NsC2a%3Dk-V3OwvSrQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANu6V4XJuNUQ=
%2Bvjve8dBELBBGkfTxB65hQNsC2a%3Dk-V3OwvSrQ%40mail.gmail.com</a>.<br />

--000000000000082aa6056916ef44--

.