Topic: Optional-returning functions
Author: windowssnt@gmail.com
Date: Mon, 18 Dec 2017 14:48:55 -0800 (PST)
Raw View
------=_Part_3185_1211799655.1513637335683
Content-Type: multipart/alternative;
boundary="----=_Part_3186_398730088.1513637335683"
------=_Part_3186_398730088.1513637335683
Content-Type: text/plain; charset="UTF-8"
// C++ 17#include <iostream>#include <optional>using namespace std;
optional<string> foo(){
if (false)
return "Hello"; }
int main(){
auto rv = foo();
cout << rv.value_or("dada"); }
When an optional-returning function does not return, return {} should be
implied. Not anymore a compiler warning or an undefined behaviour.
--
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/f7ed2560-e332-4f44-9926-e1e80e8b898e%40isocpp.org.
------=_Part_3186_398730088.1513637335683
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><pre class=3D"lang-cpp prettyprint prettyprinted" sty=
le=3D"padding: 5px; font-variant-numeric: inherit; font-variant-east-asian:=
inherit; font-stretch: inherit; line-height: inherit; font-family: Consola=
s, Menlo, Monaco, "Lucida Console", "Liberation Mono", =
"DejaVu Sans Mono", "Bitstream Vera Sans Mono", "C=
ourier New", monospace, sans-serif; vertical-align: baseline; width: a=
uto; max-height: 600px; overflow: auto; background-color: rgb(239, 240, 241=
); color: rgb(57, 51, 24); word-wrap: normal;"><code style=3D"font-style: i=
nherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit;=
line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida C=
onsole", "Liberation Mono", "DejaVu Sans Mono", &q=
uot;Bitstream Vera Sans Mono", "Courier New", monospace, san=
s-serif; vertical-align: baseline; white-space: inherit;"><span class=3D"co=
m" style=3D"font-style: inherit; font-variant: inherit; font-weight: inheri=
t; font-stretch: inherit; font-size: inherit; line-height: inherit; font-fa=
mily: inherit; vertical-align: baseline; color: rgb(133, 140, 147);">// C++=
17</span><span class=3D"pln" style=3D"font-style: inherit; font-variant: i=
nherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; li=
ne-height: inherit; font-family: inherit; vertical-align: baseline; color: =
rgb(48, 51, 54);">
</span><span class=3D"com" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(133, 140, 147);">#include</span><span class=3D"pln" style=3D"font-style: i=
nherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit;=
font-size: inherit; line-height: inherit; font-family: inherit; vertical-a=
lign: baseline; color: rgb(48, 51, 54);"> </span><span class=3D"str" style=
=3D"font-style: inherit; font-variant: inherit; font-weight: inherit; font-=
stretch: inherit; font-size: inherit; line-height: inherit; font-family: in=
herit; vertical-align: baseline; color: rgb(125, 39, 39);"><iostream>=
</span><span class=3D"pln" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(48, 51, 54);">
</span><span class=3D"com" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(133, 140, 147);">#include</span><span class=3D"pln" style=3D"font-style: i=
nherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit;=
font-size: inherit; line-height: inherit; font-family: inherit; vertical-a=
lign: baseline; color: rgb(48, 51, 54);"> </span><span class=3D"str" style=
=3D"font-style: inherit; font-variant: inherit; font-weight: inherit; font-=
stretch: inherit; font-size: inherit; line-height: inherit; font-family: in=
herit; vertical-align: baseline; color: rgb(125, 39, 39);"><optional>=
</span><span class=3D"pln" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(48, 51, 54);">
</span><span class=3D"kwd" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(16, 16, 148);">using</span><span class=3D"pln" style=3D"font-style: inheri=
t; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font=
-size: inherit; line-height: inherit; font-family: inherit; vertical-align:=
baseline; color: rgb(48, 51, 54);"> </span><span class=3D"kwd" style=3D"fo=
nt-style: inherit; font-variant: inherit; font-weight: inherit; font-stretc=
h: inherit; font-size: inherit; line-height: inherit; font-family: inherit;=
vertical-align: baseline; color: rgb(16, 16, 148);">namespace</span><span =
class=3D"pln" style=3D"font-style: inherit; font-variant: inherit; font-wei=
ght: inherit; font-stretch: inherit; font-size: inherit; line-height: inher=
it; font-family: inherit; vertical-align: baseline; color: rgb(48, 51, 54);=
"> std</span><span class=3D"pun" style=3D"font-style: inherit; font-variant=
: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit;=
line-height: inherit; font-family: inherit; vertical-align: baseline; colo=
r: rgb(48, 51, 54);">;</span><span class=3D"pln" style=3D"font-style: inher=
it; font-variant: inherit; font-weight: inherit; font-stretch: inherit; fon=
t-size: inherit; line-height: inherit; font-family: inherit; vertical-align=
: baseline; color: rgb(48, 51, 54);">
optional</span><span class=3D"str" style=3D"font-style: inherit; font-varia=
nt: inherit; font-weight: inherit; font-stretch: inherit; font-size: inheri=
t; line-height: inherit; font-family: inherit; vertical-align: baseline; co=
lor: rgb(125, 39, 39);"><string></span><span class=3D"pln" style=3D"f=
ont-style: inherit; font-variant: inherit; font-weight: inherit; font-stret=
ch: inherit; font-size: inherit; line-height: inherit; font-family: inherit=
; vertical-align: baseline; color: rgb(48, 51, 54);"> foo</span><span class=
=3D"pun" style=3D"font-style: inherit; font-variant: inherit; font-weight: =
inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; f=
ont-family: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">()<=
/span><span class=3D"pln" style=3D"font-style: inherit; font-variant: inher=
it; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-h=
eight: inherit; font-family: inherit; vertical-align: baseline; color: rgb(=
48, 51, 54);">
</span><span class=3D"pun" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(48, 51, 54);">{</span><span class=3D"pln" style=3D"font-style: inherit; fo=
nt-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size=
: inherit; line-height: inherit; font-family: inherit; vertical-align: base=
line; color: rgb(48, 51, 54);">
</span><span class=3D"kwd" style=3D"font-style: inherit; font-variant: =
inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; l=
ine-height: inherit; font-family: inherit; vertical-align: baseline; color:=
rgb(16, 16, 148);">if</span><span class=3D"pln" style=3D"font-style: inher=
it; font-variant: inherit; font-weight: inherit; font-stretch: inherit; fon=
t-size: inherit; line-height: inherit; font-family: inherit; vertical-align=
: baseline; color: rgb(48, 51, 54);"> </span><span class=3D"pun" style=3D"f=
ont-style: inherit; font-variant: inherit; font-weight: inherit; font-stret=
ch: inherit; font-size: inherit; line-height: inherit; font-family: inherit=
; vertical-align: baseline; color: rgb(48, 51, 54);">(</span><span class=3D=
"kwd" style=3D"font-style: inherit; font-variant: inherit; font-weight: inh=
erit; font-stretch: inherit; font-size: inherit; line-height: inherit; font=
-family: inherit; vertical-align: baseline; color: rgb(16, 16, 148);">false=
</span><span class=3D"pun" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(48, 51, 54);">)</span><span class=3D"pln" style=3D"font-style: inherit; fo=
nt-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size=
: inherit; line-height: inherit; font-family: inherit; vertical-align: base=
line; color: rgb(48, 51, 54);">
</span><span class=3D"kwd" style=3D"font-style: inherit; font-varia=
nt: inherit; font-weight: inherit; font-stretch: inherit; font-size: inheri=
t; line-height: inherit; font-family: inherit; vertical-align: baseline; co=
lor: rgb(16, 16, 148);">return</span><span class=3D"pln" style=3D"font-styl=
e: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inhe=
rit; font-size: inherit; line-height: inherit; font-family: inherit; vertic=
al-align: baseline; color: rgb(48, 51, 54);"> </span><span class=3D"str" st=
yle=3D"font-style: inherit; font-variant: inherit; font-weight: inherit; fo=
nt-stretch: inherit; font-size: inherit; line-height: inherit; font-family:=
inherit; vertical-align: baseline; color: rgb(125, 39, 39);">"Hello&q=
uot;</span><span class=3D"pun" style=3D"font-style: inherit; font-variant: =
inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; l=
ine-height: inherit; font-family: inherit; vertical-align: baseline; color:=
rgb(48, 51, 54);">;</span><span class=3D"pln" style=3D"font-style: inherit=
; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-=
size: inherit; line-height: inherit; font-family: inherit; vertical-align: =
baseline; color: rgb(48, 51, 54);"> =20
</span><span class=3D"pun" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(48, 51, 54);">}</span><span class=3D"pln" style=3D"font-style: inherit; fo=
nt-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size=
: inherit; line-height: inherit; font-family: inherit; vertical-align: base=
line; color: rgb(48, 51, 54);">
</span><span class=3D"typ" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(43, 145, 175);">int</span><span class=3D"pln" style=3D"font-style: inherit=
; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-=
size: inherit; line-height: inherit; font-family: inherit; vertical-align: =
baseline; color: rgb(48, 51, 54);"> main</span><span class=3D"pun" style=3D=
"font-style: inherit; font-variant: inherit; font-weight: inherit; font-str=
etch: inherit; font-size: inherit; line-height: inherit; font-family: inher=
it; vertical-align: baseline; color: rgb(48, 51, 54);">()</span><span class=
=3D"pln" style=3D"font-style: inherit; font-variant: inherit; font-weight: =
inherit; font-stretch: inherit; font-size: inherit; line-height: inherit; f=
ont-family: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">
</span><span class=3D"pun" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(48, 51, 54);">{</span><span class=3D"pln" style=3D"font-style: inherit; fo=
nt-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size=
: inherit; line-height: inherit; font-family: inherit; vertical-align: base=
line; color: rgb(48, 51, 54);">
</span><span class=3D"kwd" style=3D"font-style: inherit; font-variant: in=
herit; font-weight: inherit; font-stretch: inherit; font-size: inherit; lin=
e-height: inherit; font-family: inherit; vertical-align: baseline; color: r=
gb(16, 16, 148);">auto</span><span class=3D"pln" style=3D"font-style: inher=
it; font-variant: inherit; font-weight: inherit; font-stretch: inherit; fon=
t-size: inherit; line-height: inherit; font-family: inherit; vertical-align=
: baseline; color: rgb(48, 51, 54);"> rv </span><span class=3D"pun" style=
=3D"font-style: inherit; font-variant: inherit; font-weight: inherit; font-=
stretch: inherit; font-size: inherit; line-height: inherit; font-family: in=
herit; vertical-align: baseline; color: rgb(48, 51, 54);">=3D</span><span c=
lass=3D"pln" style=3D"font-style: inherit; font-variant: inherit; font-weig=
ht: inherit; font-stretch: inherit; font-size: inherit; line-height: inheri=
t; font-family: inherit; vertical-align: baseline; color: rgb(48, 51, 54);"=
> foo</span><span class=3D"pun" style=3D"font-style: inherit; font-variant:=
inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit; =
line-height: inherit; font-family: inherit; vertical-align: baseline; color=
: rgb(48, 51, 54);">();</span><span class=3D"pln" style=3D"font-style: inhe=
rit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; fo=
nt-size: inherit; line-height: inherit; font-family: inherit; vertical-alig=
n: baseline; color: rgb(48, 51, 54);">
cout </span><span class=3D"pun" style=3D"font-style: inherit; font-varian=
t: inherit; font-weight: inherit; font-stretch: inherit; font-size: inherit=
; line-height: inherit; font-family: inherit; vertical-align: baseline; col=
or: rgb(48, 51, 54);"><<</span><span class=3D"pln" style=3D"font-styl=
e: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inhe=
rit; font-size: inherit; line-height: inherit; font-family: inherit; vertic=
al-align: baseline; color: rgb(48, 51, 54);"> rv</span><span class=3D"pun" =
style=3D"font-style: inherit; font-variant: inherit; font-weight: inherit; =
font-stretch: inherit; font-size: inherit; line-height: inherit; font-famil=
y: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">.</span><spa=
n class=3D"pln" style=3D"font-style: inherit; font-variant: inherit; font-w=
eight: inherit; font-stretch: inherit; font-size: inherit; line-height: inh=
erit; font-family: inherit; vertical-align: baseline; color: rgb(48, 51, 54=
);">value_or</span><span class=3D"pun" style=3D"font-style: inherit; font-v=
ariant: inherit; font-weight: inherit; font-stretch: inherit; font-size: in=
herit; line-height: inherit; font-family: inherit; vertical-align: baseline=
; color: rgb(48, 51, 54);">(</span><span class=3D"str" style=3D"font-style:=
inherit; font-variant: inherit; font-weight: inherit; font-stretch: inheri=
t; font-size: inherit; line-height: inherit; font-family: inherit; vertical=
-align: baseline; color: rgb(125, 39, 39);">"dada"</span><span cl=
ass=3D"pun" style=3D"font-style: inherit; font-variant: inherit; font-weigh=
t: inherit; font-stretch: inherit; font-size: inherit; line-height: inherit=
; font-family: inherit; vertical-align: baseline; color: rgb(48, 51, 54);">=
);</span><span class=3D"pln" style=3D"font-style: inherit; font-variant: in=
herit; font-weight: inherit; font-stretch: inherit; font-size: inherit; lin=
e-height: inherit; font-family: inherit; vertical-align: baseline; color: r=
gb(48, 51, 54);">=20
</span><span class=3D"pun" style=3D"font-style: inherit; font-variant: inhe=
rit; font-weight: inherit; font-stretch: inherit; font-size: inherit; line-=
height: inherit; font-family: inherit; vertical-align: baseline; color: rgb=
(48, 51, 54);">}</span></code></pre></div><div><br></div><div><br></div><di=
v>When an optional-returning function does not return, return {} should be =
implied. Not anymore a compiler warning or an undefined behaviour.</div><di=
v><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/f7ed2560-e332-4f44-9926-e1e80e8b898e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f7ed2560-e332-4f44-9926-e1e80e8b898e=
%40isocpp.org</a>.<br />
------=_Part_3186_398730088.1513637335683--
------=_Part_3185_1211799655.1513637335683--
.
Author: Patrice Roy <patricer@gmail.com>
Date: Mon, 18 Dec 2017 18:25:16 -0500
Raw View
--001a114f219ec3d56d0560a5a9a9
Content-Type: text/plain; charset="UTF-8"
And why should there be such a special case instead of simply adding
return{}; before the closing brace? Since you're asking for very special
behavor where there's a very simple solution, justification might be in
order...
2017-12-18 17:48 GMT-05:00 <windowssnt@gmail.com>:
> // C++ 17#include <iostream>#include <optional>using namespace std;
> optional<string> foo(){
> if (false)
> return "Hello"; }
> int main(){
> auto rv = foo();
> cout << rv.value_or("dada"); }
>
>
>
> When an optional-returning function does not return, return {} should be
> implied. Not anymore a compiler warning or an undefined behaviour.
>
> --
> 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/f7ed2560-e332-4f44-
> 9926-e1e80e8b898e%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f7ed2560-e332-4f44-9926-e1e80e8b898e%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/CAKiZDp2M7aKwSUZoUJr6CzX0NK2ba5xrcrrEi-7FaqrqqVU%3DBg%40mail.gmail.com.
--001a114f219ec3d56d0560a5a9a9
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">And why should there be such a special case instead of sim=
ply adding return{}; before the closing brace? Since you're asking for =
very special behavor where there's a very simple solution, justificatio=
n might be in order...<br></div><div class=3D"gmail_extra"><br><div class=
=3D"gmail_quote">2017-12-18 17:48 GMT-05:00 <span dir=3D"ltr"><<a href=
=3D"mailto:windowssnt@gmail.com" target=3D"_blank">windowssnt@gmail.com</a>=
></span>:<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"><div><pre c=
lass=3D"m_-6356540232015133550lang-cpp m_-6356540232015133550prettyprint m_=
-6356540232015133550prettyprinted" style=3D"padding:5px;font-variant-numeri=
c:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:=
inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","=
Liberation Mono","DejaVu Sans Mono","Bitstream Vera San=
s Mono","Courier New",monospace,sans-serif;vertical-align:ba=
seline;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,2=
40,241);color:rgb(57,51,24);word-wrap:normal"><code style=3D"font-style:inh=
erit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-hei=
ght:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console",&q=
uot;Liberation Mono","DejaVu Sans Mono","Bitstream Vera=
Sans Mono","Courier New",monospace,sans-serif;vertical-alig=
n:baseline;white-space:inherit"><span class=3D"m_-6356540232015133550com" s=
tyle=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-st=
retch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ver=
tical-align:baseline;color:rgb(133,140,147)">// C++ 17</span><span class=3D=
"m_-6356540232015133550pln" style=3D"font-style:inherit;font-variant:inheri=
t;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:in=
herit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550com" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(133,140,147)">#include</span><span class=3D"m_-6356540232015133550pln=
" style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font=
-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;=
vertical-align:baseline;color:rgb(48,51,54)"> </span><span class=3D"m_-6356=
540232015133550str" style=3D"font-style:inherit;font-variant:inherit;font-w=
eight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;color:rgb(125,39,39)"><iostrea=
m></span><span class=3D"m_-6356540232015133550pln" style=3D"font-style:i=
nherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-s=
ize:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline=
;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550com" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(133,140,147)">#include</span><span class=3D"m_-6356540232015133550pln=
" style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font=
-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;=
vertical-align:baseline;color:rgb(48,51,54)"> </span><span class=3D"m_-6356=
540232015133550str" style=3D"font-style:inherit;font-variant:inherit;font-w=
eight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;color:rgb(125,39,39)"><optiona=
l></span><span class=3D"m_-6356540232015133550pln" style=3D"font-style:i=
nherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-s=
ize:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline=
;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550kwd" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(16,16,148)">using</span><span class=3D"m_-6356540232015133550pln" sty=
le=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stre=
tch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;verti=
cal-align:baseline;color:rgb(48,51,54)"> </span><span class=3D"m_-635654023=
2015133550kwd" style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(16,16,148)">namespace</span>=
<span class=3D"m_-6356540232015133550pln" style=3D"font-style:inherit;font-=
variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;=
line-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(4=
8,51,54)"> std</span><span class=3D"m_-6356540232015133550pun" style=3D"fon=
t-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inher=
it;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align=
:baseline;color:rgb(48,51,54)">;</span><span class=3D"m_-635654023201513355=
0pln" style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;=
font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inhe=
rit;vertical-align:baseline;color:rgb(48,51,54)">
optional</span><span class=3D"m_-6356540232015133550str" style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(125,39,39)"><string></span><span class=3D"m_-6356540232=
015133550pln" style=3D"font-style:inherit;font-variant:inherit;font-weight:=
inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fam=
ily:inherit;vertical-align:baseline;color:rgb(48,51,54)"> foo</span><span c=
lass=3D"m_-6356540232015133550pun" style=3D"font-style:inherit;font-variant=
:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-he=
ight:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54=
)">()</span><span class=3D"m_-6356540232015133550pln" style=3D"font-style:i=
nherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-s=
ize:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline=
;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550pun" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(48,51,54)">{</span><span class=3D"m_-6356540232015133550pln" style=3D=
"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:i=
nherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-a=
lign:baseline;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550kwd" style=3D"font-style:in=
herit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-si=
ze:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;=
color:rgb(16,16,148)">if</span><span class=3D"m_-6356540232015133550pln" st=
yle=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-str=
etch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vert=
ical-align:baseline;color:rgb(48,51,54)"> </span><span class=3D"m_-63565402=
32015133550pun" style=3D"font-style:inherit;font-variant:inherit;font-weigh=
t:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-f=
amily:inherit;vertical-align:baseline;color:rgb(48,51,54)">(</span><span cl=
ass=3D"m_-6356540232015133550kwd" style=3D"font-style:inherit;font-variant:=
inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-hei=
ght:inherit;font-family:inherit;vertical-align:baseline;color:rgb(16,16,148=
)">false</span><span class=3D"m_-6356540232015133550pun" style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(48,51,54)">)</span><span class=3D"m_-6356540232015133550pln" =
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-s=
tretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ve=
rtical-align:baseline;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550kwd" style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(16,16,148)">return</span><span class=3D"m_-635654023201513355=
0pln" style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;=
font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inhe=
rit;vertical-align:baseline;color:rgb(48,51,54)"> </span><span class=3D"m_-=
6356540232015133550str" style=3D"font-style:inherit;font-variant:inherit;fo=
nt-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inheri=
t;font-family:inherit;vertical-align:baseline;color:rgb(125,39,39)">"H=
ello"</span><span class=3D"m_-6356540232015133550pun" style=3D"font-st=
yle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;f=
ont-size:inherit;line-height:inherit;font-family:inherit;vertical-align:bas=
eline;color:rgb(48,51,54)">;</span><span class=3D"m_-6356540232015133550pln=
" style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font=
-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;=
vertical-align:baseline;color:rgb(48,51,54)"> =20
</span><span class=3D"m_-6356540232015133550pun" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(48,51,54)">}</span><span class=3D"m_-6356540232015133550pln" style=3D=
"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:i=
nherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-a=
lign:baseline;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550typ" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(43,145,175)">int</span><span class=3D"m_-6356540232015133550pln" styl=
e=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stret=
ch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertic=
al-align:baseline;color:rgb(48,51,54)"> main</span><span class=3D"m_-635654=
0232015133550pun" style=3D"font-style:inherit;font-variant:inherit;font-wei=
ght:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font=
-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">()</span><span=
class=3D"m_-6356540232015133550pln" style=3D"font-style:inherit;font-varia=
nt:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-=
height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,=
54)">
</span><span class=3D"m_-6356540232015133550pun" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(48,51,54)">{</span><span class=3D"m_-6356540232015133550pln" style=3D=
"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:i=
nherit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-a=
lign:baseline;color:rgb(48,51,54)">
</span><span class=3D"m_-6356540232015133550kwd" style=3D"font-style:inhe=
rit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size=
:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;co=
lor:rgb(16,16,148)">auto</span><span class=3D"m_-6356540232015133550pln" st=
yle=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-str=
etch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vert=
ical-align:baseline;color:rgb(48,51,54)"> rv </span><span class=3D"m_-63565=
40232015133550pun" style=3D"font-style:inherit;font-variant:inherit;font-we=
ight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fon=
t-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">=3D</span><sp=
an class=3D"m_-6356540232015133550pln" style=3D"font-style:inherit;font-var=
iant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;lin=
e-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,5=
1,54)"> foo</span><span class=3D"m_-6356540232015133550pun" style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">();</span><span class=3D"m_-6356540232015133550=
pln" style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)">
cout </span><span class=3D"m_-6356540232015133550pun" style=3D"font-style=
:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font=
-size:inherit;line-height:inherit;font-family:inherit;vertical-align:baseli=
ne;color:rgb(48,51,54)"><<</span><span class=3D"m_-635654023201513355=
0pln" style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;=
font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inhe=
rit;vertical-align:baseline;color:rgb(48,51,54)"> rv</span><span class=3D"m=
_-6356540232015133550pun" style=3D"font-style:inherit;font-variant:inherit;=
font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inhe=
rit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">.</spa=
n><span class=3D"m_-6356540232015133550pln" style=3D"font-style:inherit;fon=
t-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inheri=
t;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb=
(48,51,54)">value_or</span><span class=3D"m_-6356540232015133550pun" style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">(</span><span class=3D"m_-63565402320=
15133550str" style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(125,39,39)">"dada"</=
span><span class=3D"m_-6356540232015133550pun" style=3D"font-style:inherit;=
font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inh=
erit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:=
rgb(48,51,54)">);</span><span class=3D"m_-6356540232015133550pln" style=3D"=
font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:in=
herit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-al=
ign:baseline;color:rgb(48,51,54)">=20
</span><span class=3D"m_-6356540232015133550pun" style=3D"font-style:inheri=
t;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:i=
nherit;line-height:inherit;font-family:inherit;vertical-align:baseline;colo=
r:rgb(48,51,54)">}</span></code></pre></div><div><br></div><div><br></div><=
div>When an optional-returning function does not return, return {} should b=
e implied. Not anymore a compiler warning or an undefined behaviour.</div><=
span class=3D"HOEnZb"><font color=3D"#888888"><div><br></div></font></span>=
</div><span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f7ed2560-e332-4f44-9926-e1e80e8b898e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/f7ed=
2560-e332-4f44-<wbr>9926-e1e80e8b898e%40isocpp.org</a><wbr>.<br>
</font></span></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" 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/CAKiZDp2M7aKwSUZoUJr6CzX0NK2ba5xrcrrE=
i-7FaqrqqVU%3DBg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAKiZDp2M7aKwSU=
ZoUJr6CzX0NK2ba5xrcrrEi-7FaqrqqVU%3DBg%40mail.gmail.com</a>.<br />
--001a114f219ec3d56d0560a5a9a9--
.
Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Mon, 18 Dec 2017 23:26:24 +0000
Raw View
--001a11495e18ca81d10560a5ad17
Content-Type: text/plain; charset="UTF-8"
That's a little tricky, purely because functions that return on one branch
but not on another cause undefined behaviour in the latter branch in the
general case (e.g. with clang, optimised, it chooses another branch, even
if that branch would normally not be entered). This would thus require
special behaviour for the "optional" template - in which case, this special
behaviour should probably be the focus here, giving people a way of
applying it in more general cases. That's the more important detail IMO.
Optional could just be an example of this, returning {} by default. Perhaps
a defaults_to(value) modifier, though this would have to be written
explicitly in foo() if this were to be the case, and that's more effort
than just writing "return value;".
I'm not in favour of having a behaviour with optional that would otherwise
cause UB in all other situations. It needs to be explained how it works,
why it does it, how to tell the compiler what to do and how to apply it to
other things. Otherwise, the average user could easily end up getting
confused about what's going on. I'd sooner favour a proposal to make a
non-returning branch a compilation error than allowing special behaviour in
one situation (this is something I suggested in another thread but Nicol
Bolas provided an example of why it doesn't always apply - when a loop will
always return for one of the values - which I kind of agree with upon
reflection).
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCN8XxY9Rkm5mpK-7yFrSWeW6Smx2gq4rkpsuWaNJfnktw%40mail.gmail.com.
--001a11495e18ca81d10560a5ad17
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto">That's a little tricky, purely because functions that=
return on one branch but not on another cause undefined behaviour in the l=
atter branch in the general case (e.g. with clang, optimised, it chooses an=
other branch, even if that branch would normally not be entered). This woul=
d thus require special behaviour for the "optional" template - in=
which case, this special behaviour should probably be the focus here, givi=
ng people a way of applying it in more general cases. That's the more i=
mportant detail IMO. Optional could just be an example of this, returning {=
} by default. Perhaps a defaults_to(value) modifier, though this would have=
to be written explicitly in foo() if this were to be the case, and that=
9;s more effort than just writing "return value;".<div dir=3D"aut=
o"><br></div><div dir=3D"auto">I'm not in favour of having a behaviour =
with optional that would otherwise cause UB in all other situations. It nee=
ds to be explained how it works, why it does it, how to tell the compiler w=
hat to do and how to apply it to other things. Otherwise, the average user =
could easily end up getting confused about what's going on. I'd soo=
ner favour a proposal to make a non-returning branch a compilation error th=
an allowing special behaviour in one situation (this is something I suggest=
ed in another thread but Nicol Bolas provided an example of why it doesn=
9;t always apply - when a loop will always return for one of the values - w=
hich I kind of agree with upon reflection).</div><div class=3D"gmail_extra"=
dir=3D"auto"><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/CAC%2B0CCN8XxY9Rkm5mpK-7yFrSWeW6Smx2g=
q4rkpsuWaNJfnktw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCN8XxY9=
Rkm5mpK-7yFrSWeW6Smx2gq4rkpsuWaNJfnktw%40mail.gmail.com</a>.<br />
--001a11495e18ca81d10560a5ad17--
.
Author: windowssnt@gmail.com
Date: Mon, 18 Dec 2017 15:28:15 -0800 (PST)
Raw View
------=_Part_7182_223887325.1513639695698
Content-Type: text/plain; charset="UTF-8"
Because that supports the optional behavior. Simply return {} when you have nothing to return means that you are forced to write something that contains nothing.
return {} should be implied by the compiler when the function returns a std::optional.
--
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/e05a0781-103a-4dc6-8faf-8f8fcf5d23a6%40isocpp.org.
------=_Part_7182_223887325.1513639695698--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 18 Dec 2017 15:28:18 -0800 (PST)
Raw View
------=_Part_22977_932985468.1513639698102
Content-Type: multipart/alternative;
boundary="----=_Part_22978_1309339011.1513639698103"
------=_Part_22978_1309339011.1513639698103
Content-Type: text/plain; charset="UTF-8"
On Monday, December 18, 2017 at 5:48:55 PM UTC-5, windo...@gmail.com wrote:
>
> // C++ 17#include <iostream>#include <optional>using namespace std;
> optional<string> foo(){
> if (false)
> return "Hello"; }
> int main(){
> auto rv = foo();
> cout << rv.value_or("dada"); }
>
>
>
> When an optional-returning function does not return, return {} should be
> implied.
>
No, it should not. If you want to return `std::nullopt` or `{}`, that's up
to you. But we shouldn't change basic rules about the language based solely
on whether you're using a specific type like this.
`void` and `nullopt` aren't the same thing.
--
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/d7d0df30-05b4-45c5-b7e6-14bbb8d0f2e2%40isocpp.org.
------=_Part_22978_1309339011.1513639698103
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Monday, December 18, 2017 at 5:48:55 PM UTC-5, =
windo...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin:=
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div =
dir=3D"ltr"><div><pre style=3D"padding:5px;font-stretch:inherit;line-height=
:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","=
;Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sa=
ns Mono","Courier New",monospace,sans-serif;vertical-align:b=
aseline;width:auto;max-height:600px;overflow:auto;background-color:rgb(239,=
240,241);color:rgb(57,51,24);word-wrap:normal"><code style=3D"font-style:in=
herit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-he=
ight:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console",&=
quot;Liberation Mono","DejaVu Sans Mono","Bitstream Ver=
a Sans Mono","Courier New",monospace,sans-serif;vertical-ali=
gn:baseline;white-space:inherit"><span style=3D"font-style:inherit;font-var=
iant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;lin=
e-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(133,=
140,147)">// C++ 17</span><span style=3D"font-style:inherit;font-variant:in=
herit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-heigh=
t:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><iostream></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><optional></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(16,16,148)">using</span><span =
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-s=
tretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ve=
rtical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(16,16,148)">namespace</span><span style=3D"font-style:inherit=
;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:in=
herit;line-height:inherit;font-family:inherit;vertical-align:baseline;color=
:rgb(48,51,54)"> std</span><span style=3D"font-style:inherit;font-variant:i=
nherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-heig=
ht:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"=
>;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
optional</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(125,39,39)"><string=
></span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(48,51,54)"> foo</span><spa=
n style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font=
-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;=
vertical-align:baseline;color:rgb(48,51,54)">()</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(16,16,148)">if</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-sty=
le:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fo=
nt-size:inherit;line-height:inherit;font-family:inherit;vertical-align:base=
line;color:rgb(48,51,54)">(</span><span style=3D"font-style:inherit;font-va=
riant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;li=
ne-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(16,=
16,148)">false</span><span style=3D"font-style:inherit;font-variant:inherit=
;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inh=
erit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">)</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(16,16,148)">return</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"=
font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:in=
herit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-al=
ign:baseline;color:rgb(125,39,39)">"Hello"</span><span style=3D"f=
ont-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inh=
erit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-ali=
gn:baseline;color:rgb(48,51,54)">;</span><span style=3D"font-style:inherit;=
font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inh=
erit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:=
rgb(48,51,54)"> =20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(43,145,175)">int</span><span s=
tyle=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-st=
retch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ver=
tical-align:baseline;color:rgb(48,51,54)"> main</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">()</span><span style=3D"font-style:inherit;font=
-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit=
;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(=
48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(16,16,148)">auto</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> rv </span><span style=3D"font-=
style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit=
;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:b=
aseline;color:rgb(48,51,54)">=3D</span><span style=3D"font-style:inherit;fo=
nt-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inher=
it;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rg=
b(48,51,54)"> foo</span><span style=3D"font-style:inherit;font-variant:inhe=
rit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:=
inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">()=
;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:=
inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fam=
ily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
cout </span><span style=3D"font-style:inherit;font-variant:inherit;font-w=
eight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"><<</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> rv</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">.</span><span style=3D"font-style:inh=
erit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-siz=
e:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;c=
olor:rgb(48,51,54)">value_or</span><span style=3D"font-style:inherit;font-v=
ariant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;l=
ine-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48=
,51,54)">(</span><span style=3D"font-style:inherit;font-variant:inherit;fon=
t-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit=
;font-family:inherit;vertical-align:baseline;color:rgb(125,39,39)">"da=
da"</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">);</span><s=
pan style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;fo=
nt-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inheri=
t;vertical-align:baseline;color:rgb(48,51,54)">=20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span></code></pr=
e></div><div><br></div><div><br></div><div>When an optional-returning funct=
ion does not return, return {} should be implied.</div></div></blockquote><=
div><br></div><div>No, it should not. If you want to return `std::nullopt` =
or `{}`, that's up to you. But we shouldn't change basic rules abou=
t the language based solely on whether you're using a specific type lik=
e this.</div><div><br></div><div>`void` and `nullopt` aren't the same t=
hing.</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/d7d0df30-05b4-45c5-b7e6-14bbb8d0f2e2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d7d0df30-05b4-45c5-b7e6-14bbb8d0f2e2=
%40isocpp.org</a>.<br />
------=_Part_22978_1309339011.1513639698103--
------=_Part_22977_932985468.1513639698102--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 19 Dec 2017 02:04:32 +0200
Raw View
On 19 December 2017 at 01:28, Nicol Bolas <jmckesson@gmail.com> wrote:
>
>
> On Monday, December 18, 2017 at 5:48:55 PM UTC-5, windo...@gmail.com wrote:
>>
>> // C++ 17
>> #include <iostream>
>> #include <optional>
>> using namespace std;
>> optional<string> foo()
>> {
>> if (false)
>> return "Hello";
>> }
>>
>> int main()
>> {
>> auto rv = foo();
>> cout << rv.value_or("dada");
>> }
>>
>>
>>
>> When an optional-returning function does not return, return {} should be
>> implied.
>
>
> No, it should not. If you want to return `std::nullopt` or `{}`, that's up
> to you. But we shouldn't change basic rules about the language based solely
> on whether you're using a specific type like this.
>
> `void` and `nullopt` aren't the same thing.
Well said, fully agreed.
--
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/CAFk2RUZKmi8Oo0WCa_35-zZwMnGx5mZmX2nQ56%2BcGE%3DYxzmy7A%40mail.gmail.com.
.
Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Tue, 19 Dec 2017 00:23:56 +0000
Raw View
--f403043e9f808e54910560a67b4e
Content-Type: text/plain; charset="UTF-8"
On 18 Dec 2017 23:28, <windowssnt@gmail.com> wrote:
Because that supports the optional behavior. Simply return {} when you have
nothing to return means that you are forced to write something that
contains nothing.
It doesn't contain nothing. Not at all. It in fact contains information
about the result - that it is not set. Optional is a fairly
simple-to-implement template class, not a piece of magic. The compiler
certainly doesn't treat it specially.
return {} should be implied by the compiler when the function returns a
std::optional.
That's a lot of work for little benefit. Again, optional is not special,
and making a compiler treat it that way simply for this use case isn't
enough.
That's why I suggest trying to generalise it so that it isn't a special
condition. What you're asking for is both a change to the standard library
and a change to the language itself, because the standard library is
written IN the language (hence no special conditions).
Make a convincing argument about how it can be changed in the language
first, THEN how this could be beneficial in the standard library, and it
might make more sense to people. They still may not like it, but how well
you convince them will depend how much time and effort you put into
researching the impacts. A change in the language is not taken lightly.
Perhaps this is a much bigger change than you first imagined.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMPoz4g4ajAzrPB53v80Cs1m4oOi%3DKsq0U94HbtvEh4Aw%40mail.gmail.com.
--f403043e9f808e54910560a67b4e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto"><div><br><div class=3D"gmail_extra"><br><div class=3D"gma=
il_quote">On 18 Dec 2017 23:28, <<a href=3D"mailto:windowssnt@gmail.com=
">windowssnt@gmail.com</a>> wrote:<br type=3D"attribution"><blockquote c=
lass=3D"quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;paddin=
g-left:1ex">Because that supports the optional behavior. Simply return {} w=
hen you have nothing to return means that you are forced to write something=
that contains nothing.<br></blockquote></div></div></div><div dir=3D"auto"=
><br></div><div dir=3D"auto"><div class=3D"gmail_extra"><div class=3D"gmail=
_quote"><blockquote class=3D"quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex"></blockquote></div></div></div><div dir=3D=
"auto">It doesn't contain nothing. Not at all. It in fact contains info=
rmation about the result - that it is not set. Optional is a fairly simple-=
to-implement template class, not a piece of magic. The compiler certainly d=
oesn't treat it specially.</div><div dir=3D"auto"><br></div><div dir=3D=
"auto"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><blockquote cl=
ass=3D"quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex">return {} should be implied by the compiler when the function re=
turns a std::optional.<br></blockquote></div></div></div><div dir=3D"auto">=
<br></div><div dir=3D"auto">That's a lot of work for little benefit. Ag=
ain, optional is not special, and making a compiler treat it that way simpl=
y for this use case isn't enough.</div><div dir=3D"auto"><br></div><div=
dir=3D"auto">That's why I suggest trying to generalise it so that it i=
sn't a special condition. What you're asking for is both a change t=
o the standard library and a change to the language itself, because the sta=
ndard library is written IN the language (hence no special conditions).</di=
v><div dir=3D"auto"><br></div><div dir=3D"auto">Make a convincing argument =
about how it can be changed in the language first, THEN how this could be b=
eneficial in the standard library, and it might make more sense to people. =
They still may not like it, but how well you convince them will depend how =
much time and effort you put into researching the impacts. A change in the =
language is not taken lightly.</div><div dir=3D"auto"><br></div><div dir=3D=
"auto">Perhaps this is a much bigger change than you first imagined.</div><=
/div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/CAC%2B0CCMPoz4g4ajAzrPB53v80Cs1m4oOi%=
3DKsq0U94HbtvEh4Aw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCMPoz=
4g4ajAzrPB53v80Cs1m4oOi%3DKsq0U94HbtvEh4Aw%40mail.gmail.com</a>.<br />
--f403043e9f808e54910560a67b4e--
.
Author: adrian.hawryluk@gmail.com
Date: Mon, 18 Dec 2017 20:40:25 -0800 (PST)
Raw View
------=_Part_7295_2072508503.1513658425815
Content-Type: multipart/alternative;
boundary="----=_Part_7296_1426418425.1513658425815"
------=_Part_7296_1426418425.1513658425815
Content-Type: text/plain; charset="UTF-8"
On Monday, December 18, 2017 at 5:48:55 PM UTC-5, windo...@gmail.com wrote:
>
> // C++ 17#include <iostream>#include <optional>using namespace std;
> optional<string> foo(){
> if (false)
> return "Hello"; }
> int main(){
> auto rv = foo();
> cout << rv.value_or("dada"); }
>
>
>
> When an optional-returning function does not return, return {} should be
> implied. Not anymore a compiler warning or an undefined behaviour.
>
> This would be a bad idea as you would not be sure if the return was left
out deliberately or by accident. I know just from experience, accidentally
leaving out a return statement is not uncommon, especially when there are
multiple paths. If you don't want to type in multiple returns, then you
can always have the return variable initialized near the top and have that
object returned at the bottom of the function, thus only having one exit.
This is usually the preferable idiom anyway, as it ensures it to be easy to
follow, but certain circumstances can have some reasons for breaking it.
However, having a path not have a return is just asking for trouble.
--
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/05ba1c4a-8ffc-4e1d-88cd-748758cf59e3%40isocpp.org.
------=_Part_7296_1426418425.1513658425815
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, December 18, 2017 at 5:48:55 PM UTC-5, windo...=
@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div><pre style=3D"padding:5px;font-stretch:inherit;line-height:inherit=
;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberat=
ion Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono&=
quot;,"Courier New",monospace,sans-serif;vertical-align:baseline;=
width:auto;max-height:600px;overflow:auto;background-color:rgb(239,240,241)=
;color:rgb(57,51,24);word-wrap:normal"><code style=3D"font-style:inherit;fo=
nt-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inh=
erit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Lib=
eration Mono","DejaVu Sans Mono","Bitstream Vera Sans M=
ono","Courier New",monospace,sans-serif;vertical-align:basel=
ine;white-space:inherit"><span style=3D"font-style:inherit;font-variant:inh=
erit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height=
:inherit;font-family:inherit;vertical-align:baseline;color:rgb(133,140,147)=
">// C++ 17</span><span style=3D"font-style:inherit;font-variant:inherit;fo=
nt-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inheri=
t;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><iostream></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><optional></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(16,16,148)">using</span><span =
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-s=
tretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ve=
rtical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(16,16,148)">namespace</span><span style=3D"font-style:inherit=
;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:in=
herit;line-height:inherit;font-family:inherit;vertical-align:baseline;color=
:rgb(48,51,54)"> std</span><span style=3D"font-style:inherit;font-variant:i=
nherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-heig=
ht:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"=
>;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
optional</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(125,39,39)"><string=
></span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(48,51,54)"> foo</span><spa=
n style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font=
-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;=
vertical-align:baseline;color:rgb(48,51,54)">()</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(16,16,148)">if</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-sty=
le:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fo=
nt-size:inherit;line-height:inherit;font-family:inherit;vertical-align:base=
line;color:rgb(48,51,54)">(</span><span style=3D"font-style:inherit;font-va=
riant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;li=
ne-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(16,=
16,148)">false</span><span style=3D"font-style:inherit;font-variant:inherit=
;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inh=
erit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">)</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(16,16,148)">return</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"=
font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:in=
herit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-al=
ign:baseline;color:rgb(125,39,39)">"Hello"</span><span style=3D"f=
ont-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inh=
erit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-ali=
gn:baseline;color:rgb(48,51,54)">;</span><span style=3D"font-style:inherit;=
font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inh=
erit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:=
rgb(48,51,54)"> =20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(43,145,175)">int</span><span s=
tyle=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-st=
retch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ver=
tical-align:baseline;color:rgb(48,51,54)"> main</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">()</span><span style=3D"font-style:inherit;font=
-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit=
;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(=
48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(16,16,148)">auto</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> rv </span><span style=3D"font-=
style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit=
;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:b=
aseline;color:rgb(48,51,54)">=3D</span><span style=3D"font-style:inherit;fo=
nt-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inher=
it;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rg=
b(48,51,54)"> foo</span><span style=3D"font-style:inherit;font-variant:inhe=
rit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:=
inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">()=
;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:=
inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fam=
ily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
cout </span><span style=3D"font-style:inherit;font-variant:inherit;font-w=
eight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"><<</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> rv</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">.</span><span style=3D"font-style:inh=
erit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-siz=
e:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;c=
olor:rgb(48,51,54)">value_or</span><span style=3D"font-style:inherit;font-v=
ariant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;l=
ine-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48=
,51,54)">(</span><span style=3D"font-style:inherit;font-variant:inherit;fon=
t-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit=
;font-family:inherit;vertical-align:baseline;color:rgb(125,39,39)">"da=
da"</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">);</span><s=
pan style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;fo=
nt-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inheri=
t;vertical-align:baseline;color:rgb(48,51,54)">=20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span></code></pr=
e></div><div><br></div><div><br></div><div>When an optional-returning funct=
ion does not return, return {} should be implied. Not anymore a compiler wa=
rning or an undefined behaviour.</div><div><br></div></div></blockquote><di=
v>This would be a bad idea as you would not be sure if the return was left =
out deliberately or by accident.=C2=A0 I know just from experience, acciden=
tally leaving out a return statement is not uncommon, especially when there=
are multiple paths.=C2=A0 If you don't want to type in multiple return=
s, then you can always have the return variable initialized near the top an=
d have that object returned at the bottom of the function, thus only having=
one exit.=C2=A0 This is usually the preferable idiom anyway, as it ensures=
it to be easy to follow, but certain circumstances can have some reasons f=
or breaking it.=C2=A0 However, having a path not have a return is just aski=
ng for trouble.</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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/05ba1c4a-8ffc-4e1d-88cd-748758cf59e3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/05ba1c4a-8ffc-4e1d-88cd-748758cf59e3=
%40isocpp.org</a>.<br />
------=_Part_7296_1426418425.1513658425815--
------=_Part_7295_2072508503.1513658425815--
.
Author: Chris DeVisser <chris.n.devisser@gmail.com>
Date: Mon, 1 Jan 2018 21:18:09 -0800 (PST)
Raw View
------=_Part_37270_420486750.1514870289204
Content-Type: multipart/alternative;
boundary="----=_Part_37271_1714722787.1514870289205"
------=_Part_37271_1714722787.1514870289205
Content-Type: text/plain; charset="UTF-8"
On Monday, December 18, 2017 at 11:40:26 PM UTC-5, Jack Adrian Zappa wrote:
>
> On Monday, December 18, 2017 at 5:48:55 PM UTC-5, windo...@gmail.com
> wrote:
>>
>> // C++ 17#include <iostream>#include <optional>using namespace std;
>> optional<string> foo(){
>> if (false)
>> return "Hello"; }
>> int main(){
>> auto rv = foo();
>> cout << rv.value_or("dada"); }
>>
>>
>>
>> When an optional-returning function does not return, return {} should be
>> implied. Not anymore a compiler warning or an undefined behaviour.
>>
>> This would be a bad idea as you would not be sure if the return was left
> out deliberately or by accident. I know just from experience, accidentally
> leaving out a return statement is not uncommon, especially when there are
> multiple paths. If you don't want to type in multiple returns, then you
> can always have the return variable initialized near the top and have that
> object returned at the bottom of the function, thus only having one exit.
> This is usually the preferable idiom anyway, as it ensures it to be easy to
> follow, but certain circumstances can have some reasons for breaking it.
> However, having a path not have a return is just asking for trouble.
>
I spontaneously had this idea of a default return value at work one day.
Regarding the problem of accidental return statement omission, I would make
the default return explicit:
int foo() { // assume this has been given a default return value
if (something) {
return 2;
}
return; // Returns default value; leaving this out and flowing off the
end is UB as normal
}
There's no conflict there unless the return type is something like auto.
Now that's not to say I necessarily agree with the idea in the first place.
However, were it to be added, it could be useful for reducing duplication
in return values. Forgive the unfamiliar example
<https://msdn.microsoft.com/en-us/library/windows/desktop/ms644985%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396>,
but this callback is a real use case I've run into:
LRESULT CALLBACK keyboard_hook_proc(int code, WPARAM msg, LPARAM data)
default return CallNextHookEx(code, msg, data) { // Strawman syntax
if (code < 0) { return; }
if (!can_handle_msg(msg)) { return; }
if (want_to_block_event(msg, data)) { return 1; } // Example of
realistically wanting to return something else
// Handle other cases
return;
}
I've been known to create a local closure that returns the proper value to
avoid the duplication in the return statement. This seems like a reasonable
use of the language feature to me, although the requirements for the return
value could be considered the real problem. Going from the existing
discussion, it might also be useful to be able to add this to a type so
that it applies to all functions returning that type. There might also be
uses for a function that users can implement according to a
concept/interface, but I haven't thought of anything compelling there.
Either way, I'm not yet convinced this is a good addition to the language,
and my opinion is certainly no for something that applies to std::optional
and nothing else.
--
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/efdea8b4-c072-490b-b6c5-50e3c6481c3b%40isocpp.org.
------=_Part_37271_1714722787.1514870289205
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, December 18, 2017 at 11:40:26 PM UTC-5, Jack Ad=
rian Zappa wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">On Monday, December 18, 2017 at 5:48:55 PM UTC-5, <a>windo...@gmail.com=
</a> 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><p=
re style=3D"padding:5px;font-stretch:inherit;line-height:inherit;font-famil=
y:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono&qu=
ot;,"DejaVu Sans Mono","Bitstream Vera Sans Mono","=
;Courier New",monospace,sans-serif;vertical-align:baseline;width:auto;=
max-height:600px;overflow:auto;background-color:rgb(239,240,241);color:rgb(=
57,51,24);word-wrap:normal"><code style=3D"font-style:inherit;font-variant:=
inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-f=
amily:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mon=
o","DejaVu Sans Mono","Bitstream Vera Sans Mono",&=
quot;Courier New",monospace,sans-serif;vertical-align:baseline;white-s=
pace:inherit"><span style=3D"font-style:inherit;font-variant:inherit;font-w=
eight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;color:rgb(133,140,147)">// C++ 17=
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><iostream></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><optional></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(16,16,148)">using</span><span =
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-s=
tretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ve=
rtical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(16,16,148)">namespace</span><span style=3D"font-style:inherit=
;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:in=
herit;line-height:inherit;font-family:inherit;vertical-align:baseline;color=
:rgb(48,51,54)"> std</span><span style=3D"font-style:inherit;font-variant:i=
nherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-heig=
ht:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"=
>;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
optional</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(125,39,39)"><string=
></span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(48,51,54)"> foo</span><spa=
n style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font=
-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;=
vertical-align:baseline;color:rgb(48,51,54)">()</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(16,16,148)">if</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-sty=
le:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fo=
nt-size:inherit;line-height:inherit;font-family:inherit;vertical-align:base=
line;color:rgb(48,51,54)">(</span><span style=3D"font-style:inherit;font-va=
riant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;li=
ne-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(16,=
16,148)">false</span><span style=3D"font-style:inherit;font-variant:inherit=
;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inh=
erit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">)</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(16,16,148)">return</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"=
font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:in=
herit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-al=
ign:baseline;color:rgb(125,39,39)">"Hello"</span><span style=3D"f=
ont-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inh=
erit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-ali=
gn:baseline;color:rgb(48,51,54)">;</span><span style=3D"font-style:inherit;=
font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inh=
erit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:=
rgb(48,51,54)"> =20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(43,145,175)">int</span><span s=
tyle=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-st=
retch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ver=
tical-align:baseline;color:rgb(48,51,54)"> main</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">()</span><span style=3D"font-style:inherit;font=
-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit=
;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(=
48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(16,16,148)">auto</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> rv </span><span style=3D"font-=
style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit=
;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:b=
aseline;color:rgb(48,51,54)">=3D</span><span style=3D"font-style:inherit;fo=
nt-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inher=
it;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rg=
b(48,51,54)"> foo</span><span style=3D"font-style:inherit;font-variant:inhe=
rit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:=
inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">()=
;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:=
inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fam=
ily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
cout </span><span style=3D"font-style:inherit;font-variant:inherit;font-w=
eight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"><<</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> rv</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">.</span><span style=3D"font-style:inh=
erit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-siz=
e:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;c=
olor:rgb(48,51,54)">value_or</span><span style=3D"font-style:inherit;font-v=
ariant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;l=
ine-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48=
,51,54)">(</span><span style=3D"font-style:inherit;font-variant:inherit;fon=
t-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit=
;font-family:inherit;vertical-align:baseline;color:rgb(125,39,39)">"da=
da"</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">);</span><s=
pan style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;fo=
nt-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inheri=
t;vertical-align:baseline;color:rgb(48,51,54)">=20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span></code></pr=
e></div><div><br></div><div><br></div><div>When an optional-returning funct=
ion does not return, return {} should be implied. Not anymore a compiler wa=
rning or an undefined behaviour.</div><div><br></div></div></blockquote><di=
v>This would be a bad idea as you would not be sure if the return was left =
out deliberately or by accident.=C2=A0 I know just from experience, acciden=
tally leaving out a return statement is not uncommon, especially when there=
are multiple paths.=C2=A0 If you don't want to type in multiple return=
s, then you can always have the return variable initialized near the top an=
d have that object returned at the bottom of the function, thus only having=
one exit.=C2=A0 This is usually the preferable idiom anyway, as it ensures=
it to be easy to follow, but certain circumstances can have some reasons f=
or breaking it.=C2=A0 However, having a path not have a return is just aski=
ng for trouble.</div></div></blockquote><div><br></div><div>I spontaneously=
had this idea of a default return value at work one day. Regarding the pro=
blem of accidental return statement omission, I would make the default retu=
rn explicit:</div><div><br></div><div class=3D"prettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prett=
yprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D=
"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> foo</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">// assume this has been giv=
en a default return value</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">if</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">so=
mething</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n 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 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">return=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// Returns default value; leaving this out and=
flowing off the end is UB as normal</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">}</span></div></code></div><div><br></div><div>There=
9;s no conflict there unless the return type is something like <font face=
=3D"courier new, monospace">auto</font>. Now that's not to say I necess=
arily agree with the idea in the first place. However, were it to be added,=
it could be useful for reducing duplication in return values. Forgive the =
<a href=3D"https://msdn.microsoft.com/en-us/library/windows/desktop/ms64498=
5%28v=3Dvs.85%29.aspx?f=3D255&MSPPError=3D-2147217396">unfamiliar examp=
le</a>, but this callback is a real use case I've run into:</div><div><=
br></div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250=
, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width=
: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">LRE=
SULT CALLBACK keyboard_hook_proc</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> code</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> WPARA=
M msg</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> LPARAM data</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">default</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">CallNextHookEx</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify">code</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> msg</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> data=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">// Strawman syntax</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">if</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">code </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify"><</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify"=
>0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">return</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">if</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(!</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">can_handle_ms=
g</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">msg</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">))</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">return</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">if</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">want_to_block_event</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">msg</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> data</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">))</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">return</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pret=
tify">// Example of realistically wanting to return something else </span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// Han=
dle other cases</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">return</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}<=
/span></div></code></div><div><br></div><div>I've been known to create =
a local closure that returns the proper value to avoid the duplication in t=
he return statement. This seems like a reasonable use of the language featu=
re to me, although the requirements for the return value could be considere=
d the real problem. Going from the existing discussion, it might also be us=
eful to be able to add this to a type so that it applies to all functions r=
eturning that type. There might also be uses for a function that users can =
implement according to a concept/interface, but I haven't thought of an=
ything compelling there. Either way, I'm not yet convinced this is a go=
od addition to the language, and my opinion is certainly no for something t=
hat applies to <font face=3D"courier new, monospace">std::optional</font> a=
nd nothing else.</div><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" 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/efdea8b4-c072-490b-b6c5-50e3c6481c3b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/efdea8b4-c072-490b-b6c5-50e3c6481c3b=
%40isocpp.org</a>.<br />
------=_Part_37271_1714722787.1514870289205--
------=_Part_37270_420486750.1514870289204--
.
Author: Richard Hodges <hodges.r@gmail.com>
Date: Tue, 2 Jan 2018 09:30:23 +0100
Raw View
--001a114aad780419890561c6e924
Content-Type: text/plain; charset="UTF-8"
> When an optional-returning function does not return, return {} should be
implied. Not anymore a compiler warning or an undefined behaviour.
For my part I think the initial premise is against the ideology of
preferring explicitness and clarity. I for one do not want the compiler to
be more permissive. I want it to be less permissive because that means I am
forced to state exactly what I want, which in turn reduces the
probability of writing incorrect logic by accident.
My opinions on omitting a return path without explicit notification of
intention to do so are well known - it should be a hard error, no excuses.
No warnings, no UB, error.
I stand firmly against this proposal, or any like it that seeks to
magically write logic for me.
On 2 January 2018 at 06:18, Chris DeVisser <chris.n.devisser@gmail.com>
wrote:
> On Monday, December 18, 2017 at 11:40:26 PM UTC-5, Jack Adrian Zappa wrote:
>>
>> On Monday, December 18, 2017 at 5:48:55 PM UTC-5, windo...@gmail.com
>> wrote:
>>>
>>> // C++ 17#include <iostream>#include <optional>using namespace std;
>>> optional<string> foo(){
>>> if (false)
>>> return "Hello"; }
>>> int main(){
>>> auto rv = foo();
>>> cout << rv.value_or("dada"); }
>>>
>>>
>>>
>>> When an optional-returning function does not return, return {} should be
>>> implied. Not anymore a compiler warning or an undefined behaviour.
>>>
>>> This would be a bad idea as you would not be sure if the return was left
>> out deliberately or by accident. I know just from experience, accidentally
>> leaving out a return statement is not uncommon, especially when there are
>> multiple paths. If you don't want to type in multiple returns, then you
>> can always have the return variable initialized near the top and have that
>> object returned at the bottom of the function, thus only having one exit.
>> This is usually the preferable idiom anyway, as it ensures it to be easy to
>> follow, but certain circumstances can have some reasons for breaking it.
>> However, having a path not have a return is just asking for trouble.
>>
>
> I spontaneously had this idea of a default return value at work one day.
> Regarding the problem of accidental return statement omission, I would make
> the default return explicit:
>
> int foo() { // assume this has been given a default return value
> if (something) {
> return 2;
> }
>
> return; // Returns default value; leaving this out and flowing off
> the end is UB as normal
> }
>
> There's no conflict there unless the return type is something like auto.
> Now that's not to say I necessarily agree with the idea in the first place.
> However, were it to be added, it could be useful for reducing duplication
> in return values. Forgive the unfamiliar example
> <https://msdn.microsoft.com/en-us/library/windows/desktop/ms644985%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396>,
> but this callback is a real use case I've run into:
>
> LRESULT CALLBACK keyboard_hook_proc(int code, WPARAM msg, LPARAM data)
> default return CallNextHookEx(code, msg, data) { // Strawman syntax
> if (code < 0) { return; }
>
> if (!can_handle_msg(msg)) { return; }
> if (want_to_block_event(msg, data)) { return 1; } // Example of
> realistically wanting to return something else
>
> // Handle other cases
>
> return;
> }
>
> I've been known to create a local closure that returns the proper value to
> avoid the duplication in the return statement. This seems like a reasonable
> use of the language feature to me, although the requirements for the return
> value could be considered the real problem. Going from the existing
> discussion, it might also be useful to be able to add this to a type so
> that it applies to all functions returning that type. There might also be
> uses for a function that users can implement according to a
> concept/interface, but I haven't thought of anything compelling there.
> Either way, I'm not yet convinced this is a good addition to the language,
> and my opinion is certainly no for something that applies to std::optional
> and nothing else.
>
> --
> 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/efdea8b4-c072-490b-
> b6c5-50e3c6481c3b%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/efdea8b4-c072-490b-b6c5-50e3c6481c3b%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/CALvx3hatUr2hJ0Fn%3DOE_r%2B%2BZY7zmA4PgJEGVnb8zf8kHgLg%3DkA%40mail.gmail.com.
--001a114aad780419890561c6e924
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">>=C2=A0<span style=3D"font-size:12.8px">When an optiona=
l-returning function does not return, return {} should be implied. Not anym=
ore a compiler warning or an undefined behaviour.</span><br><br><span style=
=3D"font-size:12.8px">For my part I think the initial premise is against th=
e ideology of preferring explicitness and clarity. I for one do not want th=
e compiler to be more permissive. I want it to be less permissive because t=
hat means I am forced to state exactly what I want, which in turn reduces t=
he probability=C2=A0of writing incorrect logic by accident.</span><div><spa=
n style=3D"font-size:12.8px"><br></span></div><div><span style=3D"font-size=
:12.8px">My opinions on omitting a return path without explicit notificatio=
n of intention to do so are well known - it should be a hard error, no excu=
ses. No warnings, no UB, error.</span></div><div><span style=3D"font-size:1=
2.8px"><br></span></div><div><span style=3D"font-size:12.8px">I stand firml=
y against this proposal, or any like it that seeks to magically write logic=
for me.</span></div><div><span style=3D"font-size:12.8px"><br></span></div=
><div><span style=3D"font-size:12.8px"><br></span></div></div><div class=3D=
"gmail_extra"><br><div class=3D"gmail_quote">On 2 January 2018 at 06:18, Ch=
ris DeVisser <span dir=3D"ltr"><<a href=3D"mailto:chris.n.devisser@gmail=
..com" target=3D"_blank">chris.n.devisser@gmail.com</a>></span> wrote:<br=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D"">On Monday=
, December 18, 2017 at 11:40:26 PM UTC-5, Jack Adrian Zappa wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Monday, December 18, 201=
7 at 5:48:55 PM UTC-5, <a>windo...@gmail.com</a> wrote:<blockquote class=3D=
"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr"><div><pre style=3D"padding:5px;font-st=
retch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"L=
ucida Console","Liberation Mono","DejaVu Sans Mono"=
;,"Bitstream Vera Sans Mono","Courier New",monospace,sa=
ns-serif;vertical-align:baseline;width:auto;max-height:600px;overflow:auto;=
background-color:rgb(239,240,241);color:rgb(57,51,24);word-wrap:normal"><co=
de style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;fon=
t-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,&qu=
ot;Lucida Console","Liberation Mono","DejaVu Sans Mono&=
quot;,"Bitstream Vera Sans Mono","Courier New",monospac=
e,sans-serif;vertical-align:baseline;white-space:inherit"><span style=3D"fo=
nt-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inhe=
rit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-alig=
n:baseline;color:rgb(133,140,147)">// C++ 17</span><span style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><iostream></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(133,140,147)">#include</span><=
span style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;f=
ont-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inher=
it;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font=
-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inheri=
t;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:=
baseline;color:rgb(125,39,39)"><optional></span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(16,16,148)">using</span><span =
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-s=
tretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ve=
rtical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-styl=
e:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fon=
t-size:inherit;line-height:inherit;font-family:inherit;vertical-align:basel=
ine;color:rgb(16,16,148)">namespace</span><span style=3D"font-style:inherit=
;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:in=
herit;line-height:inherit;font-family:inherit;vertical-align:baseline;color=
:rgb(48,51,54)"> std</span><span style=3D"font-style:inherit;font-variant:i=
nherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-heig=
ht:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"=
>;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
optional</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(125,39,39)"><string=
></span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(48,51,54)"> foo</span><spa=
n style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font=
-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;=
vertical-align:baseline;color:rgb(48,51,54)">()</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weig=
ht:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-=
family:inherit;vertical-align:baseline;color:rgb(16,16,148)">if</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"font-sty=
le:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;fo=
nt-size:inherit;line-height:inherit;font-family:inherit;vertical-align:base=
line;color:rgb(48,51,54)">(</span><span style=3D"font-style:inherit;font-va=
riant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;li=
ne-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(16,=
16,148)">false</span><span style=3D"font-style:inherit;font-variant:inherit=
;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inh=
erit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">)</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(16,16,148)">return</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> </span><span style=3D"=
font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:in=
herit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-al=
ign:baseline;color:rgb(125,39,39)">"Hello"</span><span style=3D"f=
ont-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inh=
erit;font-size:inherit;line-height:inherit;font-family:inherit;vertical-ali=
gn:baseline;color:rgb(48,51,54)">;</span><span style=3D"font-style:inherit;=
font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inh=
erit;line-height:inherit;font-family:inherit;vertical-align:baseline;color:=
rgb(48,51,54)"> =20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(43,145,175)">int</span><span s=
tyle=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-st=
retch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;ver=
tical-align:baseline;color:rgb(48,51,54)"> main</span><span style=3D"font-s=
tyle:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;=
font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:ba=
seline;color:rgb(48,51,54)">()</span><span style=3D"font-style:inherit;font=
-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit=
;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(=
48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">{</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight=
:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fa=
mily:inherit;vertical-align:baseline;color:rgb(16,16,148)">auto</span><span=
style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-=
stretch:inherit;font-size:inherit;line-height:inherit;font-family:inherit;v=
ertical-align:baseline;color:rgb(48,51,54)"> rv </span><span style=3D"font-=
style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit=
;font-size:inherit;line-height:inherit;font-family:inherit;vertical-align:b=
aseline;color:rgb(48,51,54)">=3D</span><span style=3D"font-style:inherit;fo=
nt-variant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inher=
it;line-height:inherit;font-family:inherit;vertical-align:baseline;color:rg=
b(48,51,54)"> foo</span><span style=3D"font-style:inherit;font-variant:inhe=
rit;font-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:=
inherit;font-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">()=
;</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:=
inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fam=
ily:inherit;vertical-align:baseline;color:rgb(48,51,54)">
cout </span><span style=3D"font-style:inherit;font-variant:inherit;font-w=
eight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;fo=
nt-family:inherit;vertical-align:baseline;color:rgb(48,51,54)"><<</sp=
an><span style=3D"font-style:inherit;font-variant:inherit;font-weight:inher=
it;font-stretch:inherit;font-size:inherit;line-height:inherit;font-family:i=
nherit;vertical-align:baseline;color:rgb(48,51,54)"> rv</span><span style=
=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretc=
h:inherit;font-size:inherit;line-height:inherit;font-family:inherit;vertica=
l-align:baseline;color:rgb(48,51,54)">.</span><span style=3D"font-style:inh=
erit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;font-siz=
e:inherit;line-height:inherit;font-family:inherit;vertical-align:baseline;c=
olor:rgb(48,51,54)">value_or</span><span style=3D"font-style:inherit;font-v=
ariant:inherit;font-weight:inherit;font-stretch:inherit;font-size:inherit;l=
ine-height:inherit;font-family:inherit;vertical-align:baseline;color:rgb(48=
,51,54)">(</span><span style=3D"font-style:inherit;font-variant:inherit;fon=
t-weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit=
;font-family:inherit;vertical-align:baseline;color:rgb(125,39,39)">"da=
da"</span><span style=3D"font-style:inherit;font-variant:inherit;font-=
weight:inherit;font-stretch:inherit;font-size:inherit;line-height:inherit;f=
ont-family:inherit;vertical-align:baseline;color:rgb(48,51,54)">);</span><s=
pan style=3D"font-style:inherit;font-variant:inherit;font-weight:inherit;fo=
nt-stretch:inherit;font-size:inherit;line-height:inherit;font-family:inheri=
t;vertical-align:baseline;color:rgb(48,51,54)">=20
</span><span style=3D"font-style:inherit;font-variant:inherit;font-weight:i=
nherit;font-stretch:inherit;font-size:inherit;line-height:inherit;font-fami=
ly:inherit;vertical-align:baseline;color:rgb(48,51,54)">}</span></code></pr=
e></div><div><br></div><div><br></div><div>When an optional-returning funct=
ion does not return, return {} should be implied. Not anymore a compiler wa=
rning or an undefined behaviour.</div><div><br></div></div></blockquote><di=
v>This would be a bad idea as you would not be sure if the return was left =
out deliberately or by accident.=C2=A0 I know just from experience, acciden=
tally leaving out a return statement is not uncommon, especially when there=
are multiple paths.=C2=A0 If you don't want to type in multiple return=
s, then you can always have the return variable initialized near the top an=
d have that object returned at the bottom of the function, thus only having=
one exit.=C2=A0 This is usually the preferable idiom anyway, as it ensures=
it to be easy to follow, but certain circumstances can have some reasons f=
or breaking it.=C2=A0 However, having a path not have a return is just aski=
ng for trouble.</div></div></blockquote><div><br></div></span><div>I sponta=
neously had this idea of a default return value at work one day. Regarding =
the problem of accidental return statement omission, I would make the defau=
lt return explicit:</div><div><br></div><div class=3D"m_-677558942224709004=
5prettyprint" style=3D"background-color:rgb(250,250,250);border-color:rgb(1=
87,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code=
class=3D"m_-6775589422247090045prettyprint"><div class=3D"m_-6775589422247=
090045subprettyprint"><span style=3D"color:#008" class=3D"m_-67755894222470=
90045styled-by-prettify">int</span><span style=3D"color:#000" class=3D"m_-6=
775589422247090045styled-by-prettify"> foo</span><span style=3D"color:#660"=
class=3D"m_-6775589422247090045styled-by-prettify">()</span><span style=3D=
"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"> </span><sp=
an style=3D"color:#660" class=3D"m_-6775589422247090045styled-by-prettify">=
{</span><span style=3D"color:#000" class=3D"m_-6775589422247090045styled-by=
-prettify"> </span><span style=3D"color:#800" class=3D"m_-67755894222470900=
45styled-by-prettify">// assume this has been given a default return value<=
/span><span style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-p=
rettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_-67=
75589422247090045styled-by-prettify">if</span><span style=3D"color:#000" cl=
ass=3D"m_-6775589422247090045styled-by-prettify"> </span><span style=3D"col=
or:#660" class=3D"m_-6775589422247090045styled-by-prettify">(</span><span s=
tyle=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify">some=
thing</span><span style=3D"color:#660" class=3D"m_-6775589422247090045style=
d-by-prettify">)</span><span style=3D"color:#000" class=3D"m_-6775589422247=
090045styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_-67=
75589422247090045styled-by-prettify">{</span><span style=3D"color:#000" cla=
ss=3D"m_-6775589422247090045styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 </span><span style=3D"color:#008" class=3D"m_-6775589422247090045sty=
led-by-prettify">return</span><span style=3D"color:#000" class=3D"m_-677558=
9422247090045styled-by-prettify"> </span><span style=3D"color:#066" class=
=3D"m_-6775589422247090045styled-by-prettify">2</span><span style=3D"color:=
#660" class=3D"m_-6775589422247090045styled-by-prettify">;</span><span styl=
e=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"><br>=C2=
=A0 =C2=A0 </span><span style=3D"color:#660" class=3D"m_-677558942224709004=
5styled-by-prettify">}</span><span style=3D"color:#000" class=3D"m_-6775589=
422247090045styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D=
"color:#008" class=3D"m_-6775589422247090045styled-by-prettify">return</spa=
n><span style=3D"color:#660" class=3D"m_-6775589422247090045styled-by-prett=
ify">;</span><span style=3D"color:#000" class=3D"m_-6775589422247090045styl=
ed-by-prettify"> </span><span style=3D"color:#800" class=3D"m_-677558942224=
7090045styled-by-prettify">// Returns default value; leaving this out and f=
lowing off the end is UB as normal</span><span style=3D"color:#000" class=
=3D"m_-6775589422247090045styled-by-prettify"><br></span><span style=3D"col=
or:#660" class=3D"m_-6775589422247090045styled-by-prettify">}</span></div><=
/code></div><div><br></div><div>There's no conflict there unless the re=
turn type is something like <font face=3D"courier new, monospace">auto</fon=
t>. Now that's not to say I necessarily agree with the idea in the firs=
t place. However, were it to be added, it could be useful for reducing dupl=
ication in return values. Forgive the <a href=3D"https://msdn.microsoft.com=
/en-us/library/windows/desktop/ms644985%28v=3Dvs.85%29.aspx?f=3D255&MSP=
PError=3D-2147217396" target=3D"_blank">unfamiliar example</a>, but this ca=
llback is a real use case I've run into:</div><div><br></div><div class=
=3D"m_-6775589422247090045prettyprint" style=3D"background-color:rgb(250,25=
0,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;wo=
rd-wrap:break-word"><code class=3D"m_-6775589422247090045prettyprint"><div =
class=3D"m_-6775589422247090045subprettyprint"><span style=3D"color:#000" c=
lass=3D"m_-6775589422247090045styled-by-prettify">LRESULT CALLBACK keyboard=
_hook_proc</span><span style=3D"color:#660" class=3D"m_-6775589422247090045=
styled-by-prettify">(</span><span style=3D"color:#008" class=3D"m_-67755894=
22247090045styled-by-prettify">int</span><span style=3D"color:#000" class=
=3D"m_-6775589422247090045styled-by-prettify"> code</span><span style=3D"co=
lor:#660" class=3D"m_-6775589422247090045styled-by-prettify">,</span><span =
style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"> WP=
ARAM msg</span><span style=3D"color:#660" class=3D"m_-6775589422247090045st=
yled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_-6775589422=
247090045styled-by-prettify"> LPARAM data</span><span style=3D"color:#660" =
class=3D"m_-6775589422247090045styled-by-prettify">)</span><span style=3D"c=
olor:#000" class=3D"m_-6775589422247090045styled-by-prettify"><br>=C2=A0 </=
span><span style=3D"color:#008" class=3D"m_-6775589422247090045styled-by-pr=
ettify">default</span><span style=3D"color:#000" class=3D"m_-67755894222470=
90045styled-by-prettify"> </span><span style=3D"color:#008" class=3D"m_-677=
5589422247090045styled-by-prettify">return</span><span style=3D"color:#000"=
class=3D"m_-6775589422247090045styled-by-prettify"> </span><span style=3D"=
color:#606" class=3D"m_-6775589422247090045styled-by-prettify">CallNextHook=
Ex</span><span style=3D"color:#660" class=3D"m_-6775589422247090045styled-b=
y-prettify">(</span><span style=3D"color:#000" class=3D"m_-6775589422247090=
045styled-by-prettify">code</span><span style=3D"color:#660" class=3D"m_-67=
75589422247090045styled-by-prettify">,</span><span style=3D"color:#000" cla=
ss=3D"m_-6775589422247090045styled-by-prettify"> msg</span><span style=3D"c=
olor:#660" class=3D"m_-6775589422247090045styled-by-prettify">,</span><span=
style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"> d=
ata</span><span style=3D"color:#660" class=3D"m_-6775589422247090045styled-=
by-prettify">)</span><span style=3D"color:#000" class=3D"m_-677558942224709=
0045styled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_-6775=
589422247090045styled-by-prettify">{</span><span style=3D"color:#000" class=
=3D"m_-6775589422247090045styled-by-prettify"> </span><span style=3D"color:=
#800" class=3D"m_-6775589422247090045styled-by-prettify">// Strawman syntax=
</span><span style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-=
prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_-6=
775589422247090045styled-by-prettify">if</span><span style=3D"color:#000" c=
lass=3D"m_-6775589422247090045styled-by-prettify"> </span><span style=3D"co=
lor:#660" class=3D"m_-6775589422247090045styled-by-prettify">(</span><span =
style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify">cod=
e </span><span style=3D"color:#660" class=3D"m_-6775589422247090045styled-b=
y-prettify"><</span><span style=3D"color:#000" class=3D"m_-6775589422247=
090045styled-by-prettify"> </span><span style=3D"color:#066" class=3D"m_-67=
75589422247090045styled-by-prettify">0</span><span style=3D"color:#660" cla=
ss=3D"m_-6775589422247090045styled-by-prettify">)</span><span style=3D"colo=
r:#000" class=3D"m_-6775589422247090045styled-by-prettify"> </span><span st=
yle=3D"color:#660" class=3D"m_-6775589422247090045styled-by-prettify">{</sp=
an><span style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-pret=
tify"> </span><span style=3D"color:#008" class=3D"m_-6775589422247090045sty=
led-by-prettify">return</span><span style=3D"color:#660" class=3D"m_-677558=
9422247090045styled-by-prettify">;</span><span style=3D"color:#000" class=
=3D"m_-6775589422247090045styled-by-prettify"> </span><span style=3D"color:=
#660" class=3D"m_-6775589422247090045styled-by-prettify">}</span><span styl=
e=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"><br><br=
>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m_-67755894222470=
90045styled-by-prettify">if</span><span style=3D"color:#000" class=3D"m_-67=
75589422247090045styled-by-prettify"> </span><span style=3D"color:#660" cla=
ss=3D"m_-6775589422247090045styled-by-prettify">(!</span><span style=3D"col=
or:#000" class=3D"m_-6775589422247090045styled-by-prettify">can_handle_msg<=
/span><span style=3D"color:#660" class=3D"m_-6775589422247090045styled-by-p=
rettify">(</span><span style=3D"color:#000" class=3D"m_-6775589422247090045=
styled-by-prettify">msg</span><span style=3D"color:#660" class=3D"m_-677558=
9422247090045styled-by-prettify">))</span><span style=3D"color:#000" class=
=3D"m_-6775589422247090045styled-by-prettify"> </span><span style=3D"color:=
#660" class=3D"m_-6775589422247090045styled-by-prettify">{</span><span styl=
e=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"> </span=
><span style=3D"color:#008" class=3D"m_-6775589422247090045styled-by-pretti=
fy">return</span><span style=3D"color:#660" class=3D"m_-6775589422247090045=
styled-by-prettify">;</span><span style=3D"color:#000" class=3D"m_-67755894=
22247090045styled-by-prettify"> </span><span style=3D"color:#660" class=3D"=
m_-6775589422247090045styled-by-prettify">}</span><span style=3D"color:#000=
" class=3D"m_-6775589422247090045styled-by-prettify"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color:#008" class=3D"m_-6775589422247090045styled-by-pret=
tify">if</span><span style=3D"color:#000" class=3D"m_-6775589422247090045st=
yled-by-prettify"> </span><span style=3D"color:#660" class=3D"m_-6775589422=
247090045styled-by-prettify">(</span><span style=3D"color:#000" class=3D"m_=
-6775589422247090045styled-by-prettify">want_to_block_event</span><span sty=
le=3D"color:#660" class=3D"m_-6775589422247090045styled-by-prettify">(</spa=
n><span style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prett=
ify">msg</span><span style=3D"color:#660" class=3D"m_-6775589422247090045st=
yled-by-prettify">,</span><span style=3D"color:#000" class=3D"m_-6775589422=
247090045styled-by-prettify"> data</span><span style=3D"color:#660" class=
=3D"m_-6775589422247090045styled-by-prettify">))</span><span style=3D"color=
:#000" class=3D"m_-6775589422247090045styled-by-prettify"> </span><span sty=
le=3D"color:#660" class=3D"m_-6775589422247090045styled-by-prettify">{</spa=
n><span style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prett=
ify"> </span><span style=3D"color:#008" class=3D"m_-6775589422247090045styl=
ed-by-prettify">return</span><span style=3D"color:#000" class=3D"m_-6775589=
422247090045styled-by-prettify"> </span><span style=3D"color:#066" class=3D=
"m_-6775589422247090045styled-by-prettify">1</span><span style=3D"color:#66=
0" class=3D"m_-6775589422247090045styled-by-prettify">;</span><span style=
=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"> </span>=
<span style=3D"color:#660" class=3D"m_-6775589422247090045styled-by-prettif=
y">}</span><span style=3D"color:#000" class=3D"m_-6775589422247090045styled=
-by-prettify"> </span><span style=3D"color:#800" class=3D"m_-67755894222470=
90045styled-by-prettify">// Example of realistically wanting to return some=
thing else </span><span style=3D"color:#000" class=3D"m_-677558942224709004=
5styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#800=
" class=3D"m_-6775589422247090045styled-by-prettify">// Handle other cases<=
/span><span style=3D"color:#000" class=3D"m_-6775589422247090045styled-by-p=
rettify"><br><br>=C2=A0 =C2=A0 </span><span style=3D"color:#008" class=3D"m=
_-6775589422247090045styled-by-prettify">return</span><span style=3D"color:=
#660" class=3D"m_-6775589422247090045styled-by-prettify">;</span><span styl=
e=3D"color:#000" class=3D"m_-6775589422247090045styled-by-prettify"><br></s=
pan><span style=3D"color:#660" class=3D"m_-6775589422247090045styled-by-pre=
ttify">}</span></div></code></div><div><br></div><div>I've been known t=
o create a local closure that returns the proper value to avoid the duplica=
tion in the return statement. This seems like a reasonable use of the langu=
age feature to me, although the requirements for the return value could be =
considered the real problem. Going from the existing discussion, it might a=
lso be useful to be able to add this to a type so that it applies to all fu=
nctions returning that type. There might also be uses for a function that u=
sers can implement according to a concept/interface, but I haven't thou=
ght of anything compelling there. Either way, I'm not yet convinced thi=
s is a good addition to the language, and my opinion is certainly no for so=
mething that applies to <font face=3D"courier new, monospace">std::optional=
</font> and nothing else.</div><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" 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/efdea8b4-c072-490b-b6c5-50e3c6481c3b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/efde=
a8b4-c072-490b-<wbr>b6c5-50e3c6481c3b%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" 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/CALvx3hatUr2hJ0Fn%3DOE_r%2B%2BZY7zmA4=
PgJEGVnb8zf8kHgLg%3DkA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hat=
Ur2hJ0Fn%3DOE_r%2B%2BZY7zmA4PgJEGVnb8zf8kHgLg%3DkA%40mail.gmail.com</a>.<br=
/>
--001a114aad780419890561c6e924--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 02 Jan 2018 08:40:35 -0200
Raw View
On Tuesday, 2 January 2018 06:30:23 -02 Richard Hodges wrote:
> My opinions on omitting a return path without explicit notification of
> intention to do so are well known - it should be a hard error, no excuses.
> No warnings, no UB, error.
And we all agreed it should be like that around 2030. That leaves the
dsicussion on what to do for the next 10 years.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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/10467094.RfLJsVWTT3%40tjmaciei-mobl1.
.
Author: Jake Arkinstall <jake.arkinstall@gmail.com>
Date: Tue, 2 Jan 2018 13:14:56 +0000
Raw View
--001a113f00249d6f360561cae2aa
Content-Type: text/plain; charset="UTF-8"
On 2 Jan 2018 10:40, "Thiago Macieira" <thiago@macieira.org> wrote:
On Tuesday, 2 January 2018 06:30:23 -02 Richard Hodges wrote:
> My opinions on omitting a return path without explicit notification of
> intention to do so are well known - it should be a hard error, no excuses.
> No warnings, no UB, error.
And we all agreed it should be like that around 2030. That leaves the
dsicussion on what to do for the next 10 years.
Making a non-returner well defined during the interim is only going to make
that more awkward.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCOwRtODwgWqKH40DTKM%2B1QjK7ZUHwrk80frMnX-x9mw2A%40mail.gmail.com.
--001a113f00249d6f360561cae2aa
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"auto"><div class=3D"gmail_extra" dir=3D"auto"><div class=3D"gma=
il_quote">On 2 Jan 2018 10:40, "Thiago Macieira" <<a href=3D"m=
ailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.org</a>> wr=
ote:<br type=3D"attribution"><blockquote class=3D"m_1229961616860666114quot=
e" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">=
<div class=3D"m_1229961616860666114quoted-text">On Tuesday, 2 January 2018 =
06:30:23 -02 Richard Hodges wrote:<br>
> My opinions on omitting a return path without explicit notification of=
<br>
> intention to do so are well known - it should be a hard error, no excu=
ses.<br>
> No warnings, no UB, error.<br>
<br>
</div>And we all agreed it should be like that around 2030. That leaves the=
<br>
dsicussion on what to do for the next 10 years.<br></blockquote></div></div=
><div dir=3D"auto"><br></div><div dir=3D"auto">Making a non-returner well d=
efined during the interim is only going to make that more awkward.</div><di=
v class=3D"gmail_extra" dir=3D"auto"><div class=3D"gmail_quote"><blockquote=
class=3D"m_1229961616860666114quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"></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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCOwRtODwgWqKH40DTKM%2B1QjK7ZU=
Hwrk80frMnX-x9mw2A%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAC%2B0CCOwRt=
ODwgWqKH40DTKM%2B1QjK7ZUHwrk80frMnX-x9mw2A%40mail.gmail.com</a>.<br />
--001a113f00249d6f360561cae2aa--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Tue, 2 Jan 2018 16:15:58 -0500
Raw View
On 2017-12-18 17:48, windowssnt@gmail.com wrote:
> When an optional-returning function does not return, return {} should be
> implied. Not anymore a compiler warning or an undefined behaviour.
No, it shouldn't. That would be the compiler assuming that you *meant*
to return a disengaged optional, as opposed to you forgot the `return`.
That's a *dangerous* assumption.
--
Matthew
--
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/c27ba2e7-ae85-20c7-29a7-7fbcaa5d531a%40gmail.com.
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 02 Jan 2018 19:37:09 -0200
Raw View
On Tuesday, 2 January 2018 11:14:56 -02 Jake Arkinstall wrote:
> On 2 Jan 2018 10:40, "Thiago Macieira" <thiago@macieira.org> wrote:
>
> On Tuesday, 2 January 2018 06:30:23 -02 Richard Hodges wrote:
> > My opinions on omitting a return path without explicit notification of
> > intention to do so are well known - it should be a hard error, no excuses.
> > No warnings, no UB, error.
>
> And we all agreed it should be like that around 2030. That leaves the
> dsicussion on what to do for the next 10 years.
>
>
> Making a non-returner well defined during the interim is only going to make
> that more awkward.
Which is why the pragmatic solution is to keep status quo (UB) until we're
ready to change it to require std::unreachable.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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/6007441.ikQqMyOK5U%40tjmaciei-mobl1.
.
Author: Richard Hodges <hodges.r@gmail.com>
Date: Tue, 2 Jan 2018 22:53:48 +0100
Raw View
--001a1141be5c3e4b090561d2225f
Content-Type: text/plain; charset="UTF-8"
> Which is why the pragmatic solution is to keep status quo (UB) until we're
> ready to change it to require std::unreachable.
Out of you and me, I am ready today. In this random study, that's 50% of
the user base. ;-)
On 2 January 2018 at 22:37, Thiago Macieira <thiago@macieira.org> wrote:
> On Tuesday, 2 January 2018 11:14:56 -02 Jake Arkinstall wrote:
> > On 2 Jan 2018 10:40, "Thiago Macieira" <thiago@macieira.org> wrote:
> >
> > On Tuesday, 2 January 2018 06:30:23 -02 Richard Hodges wrote:
> > > My opinions on omitting a return path without explicit notification of
> > > intention to do so are well known - it should be a hard error, no
> excuses.
> > > No warnings, no UB, error.
> >
> > And we all agreed it should be like that around 2030. That leaves the
> > dsicussion on what to do for the next 10 years.
> >
> >
> > Making a non-returner well defined during the interim is only going to
> make
> > that more awkward.
>
> Which is why the pragmatic solution is to keep status quo (UB) until we're
> ready to change it to require std::unreachable.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel Open Source Technology Center
>
> --
> 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/6007441.ikQqMyOK5U%40tjmaciei-mobl1.
>
--
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/CALvx3hYYi2eAEJTxNpQqGvC4axZveKqVJ1KCd74%2BgFmMRhJ93g%40mail.gmail.com.
--001a1141be5c3e4b090561d2225f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">>=C2=A0<span style=3D"font-size:12.8px">Which is why th=
e pragmatic solution is to keep status quo (UB) until we're</span><br s=
tyle=3D"font-size:12.8px"><span style=3D"font-size:12.8px">> ready to ch=
ange it to require std::unreachable.<br><br>Out of you and me, I am ready t=
oday. In this random study, that's 50% of the user base. ;-)</span><div=
><span style=3D"font-size:12.8px"><br><br><br></span></div></div><div class=
=3D"gmail_extra"><br><div class=3D"gmail_quote">On 2 January 2018 at 22:37,=
Thiago Macieira <span dir=3D"ltr"><<a href=3D"mailto:thiago@macieira.or=
g" target=3D"_blank">thiago@macieira.org</a>></span> wrote:<br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex"><span class=3D"">On Tuesday, 2 January 2018 11:14:56 =
-02 Jake Arkinstall wrote:<br>
> On 2 Jan 2018 10:40, "Thiago Macieira" <<a href=3D"mailto=
:thiago@macieira.org">thiago@macieira.org</a>> wrote:<br>
><br>
> On Tuesday, 2 January 2018 06:30:23 -02 Richard Hodges wrote:<br>
> > My opinions on omitting a return path without explicit notificati=
on of<br>
> > intention to do so are well known - it should be a hard error, no=
excuses.<br>
> > No warnings, no UB, error.<br>
><br>
> And we all agreed it should be like that around 2030. That leaves the<=
br>
> dsicussion on what to do for the next 10 years.<br>
><br>
><br>
> Making a non-returner well defined during the interim is only going to=
make<br>
> that more awkward.<br>
<br>
</span>Which is why the pragmatic solution is to keep status quo (UB) until=
we're<br>
ready to change it to require std::unreachable.<br>
<span class=3D""><br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" rel=3D"noref=
errer" target=3D"_blank">macieira.info</a> - thiago (AT) <a href=3D"http://=
kde.org" rel=3D"noreferrer" target=3D"_blank">kde.org</a><br>
=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center<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" 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/6007441.ikQqMyOK5U%40tjmaciei-=
mobl1" rel=3D"noreferrer" target=3D"_blank">https://groups.google.com/a/<wb=
r>isocpp.org/d/msgid/std-<wbr>proposals/6007441.ikQqMyOK5U%<wbr>40tjmaciei-=
mobl1</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" 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/CALvx3hYYi2eAEJTxNpQqGvC4axZveKqVJ1KC=
d74%2BgFmMRhJ93g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CALvx3hYYi2eAEJ=
TxNpQqGvC4axZveKqVJ1KCd74%2BgFmMRhJ93g%40mail.gmail.com</a>.<br />
--001a1141be5c3e4b090561d2225f--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 02 Jan 2018 20:12:30 -0200
Raw View
On Tuesday, 2 January 2018 19:53:48 -02 Richard Hodges wrote:
> > Which is why the pragmatic solution is to keep status quo (UB) until we're
> > ready to change it to require std::unreachable.
>
> Out of you and me, I am ready today. In this random study, that's 50% of
> the user base. ;-)
We can talk when that approaches 99%.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
--
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/2645110.SUEiuzt9OM%40tjmaciei-mobl1.
.