Topic: Using the underscore for unused identifiers


Author: Stack Machine <stackmachine@hotmail.com>
Date: Fri, 7 Mar 2014 00:07:05 -0800 (PST)
Raw View
------=_Part_272_1708364.1394179625885
Content-Type: text/plain; charset=UTF-8

Idea: Give a single underscore "_" a special meaning in contexts where an
identifier is expected. It means that the thing being defined is unused.
Examples:
std::lock_guard<std::mutex> _(mtx);
auto _ = finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs a
function at scope exit

void foo(int _);

struct _ { ... } my_single_object;
etc. etc.

This feature has been used extensively in functional languages. It solves
the problem of unused variables nicely while being very explicit at the
same time.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_272_1708364.1394179625885
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Idea: Give a single underscore "_" a special meaning in co=
ntexts where an identifier is expected. It means that the thing being defin=
ed is unused.<br>Examples:<br><div class=3D"prettyprint" style=3D"backgroun=
d-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style=
: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypr=
int"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">lock_guard</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">mutex</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> _</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">mtx</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> _ </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">finally</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">([]{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"sty=
led-by-prettify">"scope exit\n"</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">});</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">// 'finally' =
runs a function at scope exit</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> _</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> _ </span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"st=
yled-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"> my_sin=
gle_object</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n></div></code></div>etc. etc.<br><br>This feature has been used extensivel=
y in functional languages. It solves the problem of unused variables nicely=
 while being very explicit at the same time.<br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_272_1708364.1394179625885--

.


Author: David Krauss <potswa@gmail.com>
Date: Fri, 7 Mar 2014 16:53:43 +0800
Raw View
--Apple-Mail=_5A08694B-E647-41DF-9BD3-888AFB5DB01C
Content-Type: text/plain; charset=ISO-8859-1

I was just having this exact same thought. I'm currently writing a scope guards proposal and plan to include the idea, but only as a peripheral kind of suggestion.

Boost.ScopeExit generates "unnamed" guards by capturing the line number. You can already accomplish the task with

#define CAT_LITERAL( A, B ) A ## B
#define CAT( A, B ) CAT_LITERAL( A, B )
#define _ CAT( anonymous_, __LINE__ )

Of course, this fails as soon as you try to declare two of them on the same line. (NB: Do not use __COUNTER__ for this, at least not in a header file, as that is incompatible with the one-definition rule.)

 - D

On 2014-03-07, at 4:07 PM, Stack Machine <stackmachine@hotmail.com> wrote:

> Idea: Give a single underscore "_" a special meaning in contexts where an identifier is expected. It means that the thing being defined is unused.
> Examples:
> std::lock_guard<std::mutex> _(mtx);
> auto _ = finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs a function at scope exit
>
> void foo(int _);
>
> struct _ { ... } my_single_object;
> etc. etc.
>
> This feature has been used extensively in functional languages. It solves the problem of unused variables nicely while being very explicit at the same time.
>
> --
>
> ---
> 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.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--Apple-Mail=_5A08694B-E647-41DF-9BD3-888AFB5DB01C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;">I was just having this=
 exact same thought. I&rsquo;m currently writing a scope guards proposal an=
d plan to include the idea, but only as a peripheral kind of suggestion.<di=
v><br></div><div>Boost.ScopeExit generates &ldquo;unnamed&rdquo; guards by =
capturing the line number. You can already accomplish the task with</div><d=
iv><br></div><div><font face=3D"Courier">#define CAT_LITERAL( A, B ) A ## B=
</font></div><div><font face=3D"Courier">#define CAT( A, B ) CAT_LITERAL( A=
, B )</font></div><div><font face=3D"Courier">#define _ CAT( anonymous_, __=
LINE__ )<br></font><div><br></div><div>Of course, this fails as soon as you=
 try to declare two of them on the same line. (NB: Do not use <font face=3D=
"Courier">__COUNTER__</font> for this, at least not in a header file, as th=
at is incompatible with the one-definition rule.)</div><div><br></div><div>=
<span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>- D<br><di=
v><br><div><div>On 2014&ndash;03&ndash;07, at 4:07 PM, Stack Machine &lt;<a=
 href=3D"mailto:stackmachine@hotmail.com">stackmachine@hotmail.com</a>&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><blockquote type=3D"cit=
e"><div dir=3D"ltr">Idea: Give a single underscore "_" a special meaning in=
 contexts where an identifier is expected. It means that the thing being de=
fined is unused.<br>Examples:<br><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">std<span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an>lock_guard<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;=
</span>std<span style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n>mutex<span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span=
> _<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>mtx<sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">);</span><br><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">auto</span> _ <span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">=3D</span> <span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">finally</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">([]{</span> std<span style=3D"color:=
 #660;" class=3D"styled-by-prettify">::</span>cout <span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&lt;&lt;</span> <span style=3D"color: #08=
0;" class=3D"styled-by-prettify">"scope exit\n"</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">;</span> <span style=3D"color: #660;" =
class=3D"styled-by-prettify">});</span> <span style=3D"color: #800;" class=
=3D"styled-by-prettify">// 'finally' runs a function at scope exit</span><b=
r><br><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span>=
 foo<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: #008;" class=3D"styled-by-prettify">int</span> _<span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">);</span><br><br><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">struct</span> _ <span style=
=3D"color: #660;" class=3D"styled-by-prettify">{</span> <span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">...</span> <span style=3D"color: #66=
0;" class=3D"styled-by-prettify">}</span> my_single_object<span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><br></code></div>etc. etc.=
<br><br>This feature has been used extensively in functional languages. It =
solves the problem of unused variables nicely while being very explicit at =
the same time.<br></div><div><br class=3D"webkit-block-placeholder"></div>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br>
</blockquote></div><br></div></div></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_5A08694B-E647-41DF-9BD3-888AFB5DB01C--

.


Author: morwenn29@gmail.com
Date: Fri, 7 Mar 2014 01:09:25 -0800 (PST)
Raw View
------=_Part_127_25761366.1394183365681
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

This would probably not play well with the gettext utility which makes an=
=20
extensive use of _ as a translation function.

Le vendredi 7 mars 2014 09:07:05 UTC+1, Stack Machine a =C3=A9crit :
>
> Idea: Give a single underscore "_" a special meaning in contexts where an=
=20
> identifier is expected. It means that the thing being defined is unused.
> Examples:
> std::lock_guard<std::mutex> _(mtx);
> auto _ =3D finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs=
 a=20
> function at scope exit
>
> void foo(int _);
>
> struct _ { ... } my_single_object;
> etc. etc.
>
> This feature has been used extensively in functional languages. It solves=
=20
> the problem of unused variables nicely while being very explicit at the=
=20
> same time.
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_127_25761366.1394183365681
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This would probably not play well with the gettext utility=
 which makes an extensive use of _ as a translation function.<br><br>Le ven=
dredi 7 mars 2014 09:07:05 UTC+1, Stack Machine a =C3=A9crit&nbsp;:<blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Idea: Give a single u=
nderscore "_" a special meaning in contexts where an identifier is expected=
.. It means that the thing being defined is unused.<br>Examples:<br><div sty=
le=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);borde=
r-style:solid;border-width:1px;word-wrap:break-word"><code><div><span style=
=3D"color:#000">std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">lock_guard</span><span style=3D"color:#660">&lt;</span><spa=
n style=3D"color:#000">std</span><span style=3D"color:#660">::</span><span =
style=3D"color:#000">mutex</span><span style=3D"color:#660">&gt;</span><spa=
n style=3D"color:#000"> _</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">mtx</span><span style=3D"color:#660">);</span><span styl=
e=3D"color:#000"><br></span><span style=3D"color:#008">auto</span><span sty=
le=3D"color:#000"> _ </span><span style=3D"color:#660">=3D</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">finally</span><span sty=
le=3D"color:#660">([]{</span><span style=3D"color:#000"> std</span><span st=
yle=3D"color:#660">::</span><span style=3D"color:#000">cout </span><span st=
yle=3D"color:#660">&lt;&lt;</span><span style=3D"color:#000"> </span><span =
style=3D"color:#080">"scope exit\n"</span><span style=3D"color:#660">;</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">});</span><=
span style=3D"color:#000"> </span><span style=3D"color:#800">// 'finally' r=
uns a function at scope exit</span><span style=3D"color:#000"><br><br></spa=
n><span style=3D"color:#008">void</span><span style=3D"color:#000"> foo</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#008">int</span>=
<span style=3D"color:#000"> _</span><span style=3D"color:#660">);</span><sp=
an style=3D"color:#000"><br><br></span><span style=3D"color:#008">struct</s=
pan><span style=3D"color:#000"> _ </span><span style=3D"color:#660">{</span=
><span style=3D"color:#000"> </span><span style=3D"color:#660">...</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#660">}</span><span s=
tyle=3D"color:#000"> my_single_object</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"><br></span></div></code></div>etc. etc.<br><=
br>This feature has been used extensively in functional languages. It solve=
s the problem of unused variables nicely while being very explicit at the s=
ame time.<br></div></blockquote></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_127_25761366.1394183365681--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 7 Mar 2014 11:10:24 +0200
Raw View
On 7 March 2014 10:53, David Krauss <potswa@gmail.com> wrote:
> I was just having this exact same thought. I'm currently writing a scope
> guards proposal and plan to include the idea, but only as a peripheral kind
> of suggestion.

Regarding unused identifiers, see
http://cplusplus.github.io/EWG/ewg-active.html#35

Regarding scope guards, see
http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3949.pdf

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: David Krauss <potswa@gmail.com>
Date: Fri, 7 Mar 2014 17:27:57 +0800
Raw View
On 2014-03-07, at 5:10 PM, Ville Voutilainen <ville.voutilainen@gmail.com> =
wrote:

> On 7 March 2014 10:53, David Krauss <potswa@gmail.com> wrote:
>> I was just having this exact same thought. I'm currently writing a scope
>> guards proposal and plan to include the idea, but only as a peripheral k=
ind
>> of suggestion.
>=20
> Regarding unused identifiers, see
> http://cplusplus.github.io/EWG/ewg-active.html#35

Summary: the need was identified about a year ago; needs further study.

There are major issues, e.g. that a declarator for a totally inaccessible e=
ntity is nearly a contradiction in terms. Yes, functional languages have go=
od reason to do it, but the rationale there doesn't match C++. It may be be=
tter to weigh unused names against alternative solutions for each use case,=
 and it's only in that context that I plan to cover the subject.

> Regarding scope guards, see
> http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3949.pdf

Yes... I am taking a more analytical approach, examining the precedents and=
 the enumerating the design decisions, so as to converge upon an optimum wi=
th less iteration and general argumentation.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Fri, 7 Mar 2014 10:03:44 -0600
Raw View
--089e010d89e05d0ab304f40668f4
Content-Type: text/plain; charset=ISO-8859-1

On 7 March 2014 02:07, Stack Machine <stackmachine@hotmail.com> wrote:

> Idea: Give a single underscore "_" a special meaning in contexts where an
> identifier is expected.
>

That would be a breaking change, which significantly reduces the chance
that the committee will ever approve it.
--
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--089e010d89e05d0ab304f40668f4
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 7 March 2014 02:07, Stack Machine <span dir=3D"ltr">&lt=
;<a href=3D"mailto:stackmachine@hotmail.com" target=3D"_blank">stackmachine=
@hotmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=
=3D"gmail_quote">

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Idea: Give a single undersc=
ore &quot;_&quot; a special meaning in contexts where an identifier is expe=
cted.</div>

</blockquote><div><br></div><div>That would be a breaking change, which sig=
nificantly reduces the chance that the committee will ever approve it.<br c=
lear=3D"all"></div></div>-- <br>=A0Nevin &quot;:-)&quot; Liber=A0 &lt;mailt=
o:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@evilove=
rlord.com</a>&gt;=A0 (847) 691-1404
</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--089e010d89e05d0ab304f40668f4--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 07 Mar 2014 11:15:20 -0500
Raw View
On 2014-03-07 03:07, Stack Machine wrote:
> Idea: Give a single underscore "_" a special meaning in contexts where an
> identifier is expected. It means that the thing being defined is unused.
> Examples:
> std::lock_guard<std::mutex> _(mtx);
> auto _ = finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs a
> function at scope exit

I assume this also implies that the "actual" name of the variable is
anonymous?

IOW:

   auto _ = ...; // okay
   auto _ = ...; // NOT a duplicate declaration

Aside: I wonder if it would be acceptable to use e.g. '#' for this
purpose, so that there is no possible collision with existing
identifiers. (Also it would be that much more obvious that the name is
'special', since of course '#' isn't otherwise a valid identifier.)

As an added bonus we could maybe then allow writing e.g. 'auto# = ...',
which some people might find desirable.

> void foo(int _);

Not needed, already you can just omit the name entirely. Unlike giving
it a name and them later doing '(void)param' (which documents the
purpose of the parameter and/or is useful if the parameter is used e.g.
depending on some preprocessor condition), I don't see anything gained
by giving it an anonymous name versus simply omitting the name.

--
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Zhihao Yuan <zy@miator.net>
Date: Fri, 7 Mar 2014 11:30:09 -0500
Raw View
On Fri, Mar 7, 2014 at 11:03 AM, Nevin Liber <nevin@eviloverlord.com> wrote:
> On 7 March 2014 02:07, Stack Machine <stackmachine@hotmail.com> wrote:
>>
>> Idea: Give a single underscore "_" a special meaning in contexts where an
>> identifier is expected.
>
>
> That would be a breaking change, which significantly reduces the chance that
> the committee will ever approve it.

Let throw one of my old suggestion here again:

  with (make_scope_guard(...))  // tune the name or the syntax rule
  {
  }  // lifetime the temporary ends here

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Stack Machine <stackmachine@hotmail.com>
Date: Fri, 7 Mar 2014 08:42:19 -0800 (PST)
Raw View
------=_Part_484_12327267.1394210539908
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



Am Freitag, 7. M=C3=A4rz 2014 17:03:44 UTC+1 schrieb Nevin ":-)" Liber:
>
> On 7 March 2014 02:07, Stack Machine <stackm...@hotmail.com <javascript:>=
>wrote:
>
>> Idea: Give a single underscore "_" a special meaning in contexts where a=
n=20
>> identifier is expected.
>>
>
> That would be a breaking change, which significantly reduces the chance=
=20
> that the committee will ever approve it.
> --=20
>  Nevin ":-)" Liber  <mailto:ne...@eviloverlord.com <javascript:>>  (847)=
=20
> 691-1404=20
>

Yes, but how relevant is it in practise? I do not see any good reason, why=
=20
you would want to use _ as an identifier.
I haven't used gettext so far, so I am going to take a look at it. But I=20
think even then, it's worth the trade-off.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_484_12327267.1394210539908
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>Am Freitag, 7. M=C3=A4rz 2014 17:03:44 UTC+1 schri=
eb Nevin ":-)" Liber:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On 7 March 2014 02:07, Stack Machine <span dir=3D"ltr">&lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"ARPwzLkmLxwJ" o=
nmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=
=3D'javascript:';return true;">stackm...@hotmail.com</a>&gt;</span> wrote:<=
br><div><div class=3D"gmail_quote">

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Idea: Give a single undersc=
ore "_" a special meaning in contexts where an identifier is expected.</div=
>

</blockquote><div><br></div><div>That would be a breaking change, which sig=
nificantly reduces the chance that the committee will ever approve it.<br c=
lear=3D"all"></div></div>-- <br>&nbsp;Nevin ":-)" Liber&nbsp; &lt;mailto:<a=
 href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"ARPwzLkmLx=
wJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.=
href=3D'javascript:';return true;">ne...@eviloverlord.com</a><wbr>&gt;&nbsp=
; (847) 691-1404
</div></div></blockquote><div><br>Yes, but how relevant is it in practise? =
I do not see any good reason, why you would want to use _ as an identifier.=
<br>I haven't used gettext so far, so I am going to take a look at it. But =
I think even then, it's worth the trade-off.<br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_484_12327267.1394210539908--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 7 Mar 2014 18:46:16 +0200
Raw View
On 7 March 2014 18:42, Stack Machine <stackmachine@hotmail.com> wrote:
> Am Freitag, 7. M=E4rz 2014 17:03:44 UTC+1 schrieb Nevin ":-)" Liber:
>>
>> On 7 March 2014 02:07, Stack Machine <stackm...@hotmail.com> wrote:
>>>
>>> Idea: Give a single underscore "_" a special meaning in contexts where =
an
>>> identifier is expected.
>> That would be a breaking change, which significantly reduces the chance
>> that the committee will ever approve it.
> Yes, but how relevant is it in practise? I do not see any good reason, wh=
y
> you would want to use _ as an identifier.
> I haven't used gettext so far, so I am going to take a look at it. But I
> think even then, it's worth the trade-off.


There is existing code where people use _ as an identifier, precisely to ex=
press
that the variable exists only to be destroyed.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Stack Machine <stackmachine@hotmail.com>
Date: Fri, 7 Mar 2014 08:50:38 -0800 (PST)
Raw View
------=_Part_217_18979097.1394211038811
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



Am Freitag, 7. M=C3=A4rz 2014 17:46:16 UTC+1 schrieb Ville Voutilainen:
>
> On 7 March 2014 18:42, Stack Machine <stackm...@hotmail.com <javascript:>=
>=20
> wrote:=20
> > Am Freitag, 7. M=C3=A4rz 2014 17:03:44 UTC+1 schrieb Nevin ":-)" Liber:=
=20
> >>=20
> >> On 7 March 2014 02:07, Stack Machine <stackm...@hotmail.com> wrote:=20
> >>>=20
> >>> Idea: Give a single underscore "_" a special meaning in contexts wher=
e=20
> an=20
> >>> identifier is expected.=20
> >> That would be a breaking change, which significantly reduces the chanc=
e=20
> >> that the committee will ever approve it.=20
> > Yes, but how relevant is it in practise? I do not see any good reason,=
=20
> why=20
> > you would want to use _ as an identifier.=20
> > I haven't used gettext so far, so I am going to take a look at it. But =
I=20
> > think even then, it's worth the trade-off.=20
>
>
> There is existing code where people use _ as an identifier, precisely to=
=20
> express=20
> that the variable exists only to be destroyed.=20
>

These cases will continue to compiler, provided that the variable is not=20
accessed anywhere. But in that case, I'd rather give it a proper name=20
anyways.=20

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_217_18979097.1394211038811
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>Am Freitag, 7. M=C3=A4rz 2014 17:46:16 UTC+1 schri=
eb Ville Voutilainen:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 7 Marc=
h 2014 18:42, Stack Machine &lt;<a href=3D"javascript:" target=3D"_blank" g=
df-obfuscated-mailto=3D"YL7ANMShz5UJ" onmousedown=3D"this.href=3D'javascrip=
t:';return true;" onclick=3D"this.href=3D'javascript:';return true;">stackm=
....@hotmail.com</a>&gt; wrote:
<br>&gt; Am Freitag, 7. M=C3=A4rz 2014 17:03:44 UTC+1 schrieb Nevin ":-)" L=
iber:
<br>&gt;&gt;
<br>&gt;&gt; On 7 March 2014 02:07, Stack Machine &lt;<a>stackm...@hotmail.=
com</a>&gt; wrote:
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; Idea: Give a single underscore "_" a special meaning in co=
ntexts where an
<br>&gt;&gt;&gt; identifier is expected.
<br>&gt;&gt; That would be a breaking change, which significantly reduces t=
he chance
<br>&gt;&gt; that the committee will ever approve it.
<br>&gt; Yes, but how relevant is it in practise? I do not see any good rea=
son, why
<br>&gt; you would want to use _ as an identifier.
<br>&gt; I haven't used gettext so far, so I am going to take a look at it.=
 But I
<br>&gt; think even then, it's worth the trade-off.
<br>
<br>
<br>There is existing code where people use _ as an identifier, precisely t=
o express
<br>that the variable exists only to be destroyed.
<br></blockquote><div><br>These cases will continue to compiler, provided t=
hat the variable is not accessed anywhere. But in that case, I'd rather giv=
e it a proper name anyways. <br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_217_18979097.1394211038811--

.


Author: Stack Machine <stackmachine@hotmail.com>
Date: Fri, 7 Mar 2014 08:51:26 -0800 (PST)
Raw View
------=_Part_496_31845736.1394211087186
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



Am Freitag, 7. M=C3=A4rz 2014 17:46:16 UTC+1 schrieb Ville Voutilainen:
>
> On 7 March 2014 18:42, Stack Machine <stackm...@hotmail.com <javascript:>=
>=20
> wrote:=20
> > Am Freitag, 7. M=C3=A4rz 2014 17:03:44 UTC+1 schrieb Nevin ":-)" Liber:=
=20
> >>=20
> >> On 7 March 2014 02:07, Stack Machine <stackm...@hotmail.com> wrote:=20
> >>>=20
> >>> Idea: Give a single underscore "_" a special meaning in contexts wher=
e=20
> an=20
> >>> identifier is expected.=20
> >> That would be a breaking change, which significantly reduces the chanc=
e=20
> >> that the committee will ever approve it.=20
> > Yes, but how relevant is it in practise? I do not see any good reason,=
=20
> why=20
> > you would want to use _ as an identifier.=20
> > I haven't used gettext so far, so I am going to take a look at it. But =
I=20
> > think even then, it's worth the trade-off.=20
>
>
> There is existing code where people use _ as an identifier, precisely to=
=20
> express=20
> that the variable exists only to be destroyed.=20
>

These cases will continue to compile, provided that the variable is not=20
accessed anywhere. But in that case I'd rather give it a proper name=20
anyways.=20

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_496_31845736.1394211087186
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>Am Freitag, 7. M=C3=A4rz 2014 17:46:16 UTC+1 schri=
eb Ville Voutilainen:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 7 Marc=
h 2014 18:42, Stack Machine &lt;<a href=3D"javascript:" target=3D"_blank" g=
df-obfuscated-mailto=3D"YL7ANMShz5UJ" onmousedown=3D"this.href=3D'javascrip=
t:';return true;" onclick=3D"this.href=3D'javascript:';return true;">stackm=
....@hotmail.com</a>&gt; wrote:
<br>&gt; Am Freitag, 7. M=C3=A4rz 2014 17:03:44 UTC+1 schrieb Nevin ":-)" L=
iber:
<br>&gt;&gt;
<br>&gt;&gt; On 7 March 2014 02:07, Stack Machine &lt;<a>stackm...@hotmail.=
com</a>&gt; wrote:
<br>&gt;&gt;&gt;
<br>&gt;&gt;&gt; Idea: Give a single underscore "_" a special meaning in co=
ntexts where an
<br>&gt;&gt;&gt; identifier is expected.
<br>&gt;&gt; That would be a breaking change, which significantly reduces t=
he chance
<br>&gt;&gt; that the committee will ever approve it.
<br>&gt; Yes, but how relevant is it in practise? I do not see any good rea=
son, why
<br>&gt; you would want to use _ as an identifier.
<br>&gt; I haven't used gettext so far, so I am going to take a look at it.=
 But I
<br>&gt; think even then, it's worth the trade-off.
<br>
<br>
<br>There is existing code where people use _ as an identifier, precisely t=
o express
<br>that the variable exists only to be destroyed.
<br></blockquote><div><br>These cases will continue to compile, provided th=
at the variable is not accessed anywhere. But in that case I'd rather give =
it a proper name anyways. <br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_496_31845736.1394211087186--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Fri, 7 Mar 2014 11:00:14 -0600
Raw View
--047d7bea39f46d56ee04f407327e
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On 7 March 2014 10:42, Stack Machine <stackmachine@hotmail.com> wrote:

> Am Freitag, 7. M=E4rz 2014 17:03:44 UTC+1 schrieb Nevin ":-)" Liber:
>>
>> On 7 March 2014 02:07, Stack Machine <stackm...@hotmail.com> wrote:
>>
>>> Idea: Give a single underscore "_" a special meaning in contexts where
>>> an identifier is expected.
>>>
>> That would be a breaking change, which significantly reduces the chance
>> that the committee will ever approve it.
>>
>> Yes, but how relevant is it in practise? I do not see any good reason,
>> why you would want to use _ as an identifier.
>>
>
It seems unlikely the committee will break 16+ years of saying that _ is a
valid identifier just because you personally want to use it for something
else.


> I haven't used gettext so far, so I am going to take a look at it. But I
>> think even then, it's worth the trade-off.
>>
>
People who don't have to pay the price always seem to think it's worth the
trade-off...
--=20
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--047d7bea39f46d56ee04f407327e
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On 7 March 2014 10:42, Stack Machine <span dir=3D"ltr">&lt=
;<a href=3D"mailto:stackmachine@hotmail.com" target=3D"_blank">stackmachine=
@hotmail.com</a>&gt;</span> wrote:<br><div class=3D"gmail_extra"><div class=
=3D"gmail_quote">

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Am Freitag, 7. M=E4rz 2014 =
17:03:44 UTC+1 schrieb Nevin &quot;:-)&quot; Liber:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left:1ex">

<div dir=3D"ltr"><div class=3D"">On 7 March 2014 02:07, Stack Machine <span=
 dir=3D"ltr">&lt;<a>stackm...@hotmail.com</a>&gt;</span> wrote:<br></div><d=
iv><div><div class=3D"gmail_quote">

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Idea: Give a single undersc=
ore &quot;_&quot; a special meaning in contexts where an identifier is expe=
cted.</div>



</blockquote><div>That would be a breaking change, which significantly redu=
ces the chance that the committee will ever approve it.<br clear=3D"all"></=
div></div><br>Yes, but how relevant is it in practise? I do not see any goo=
d reason, why you would want to use _ as an identifier.<br>

</div></div></div></blockquote></div></blockquote><div><br></div><div>It se=
ems unlikely the committee will break 16+ years of saying that _ is a valid=
 identifier just because you personally want to use it for something else.<=
br>

</div><div>=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><blockq=
uote 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><div>I haven&#39;t used gettext so far, so I am going=
 to take a look at it. But I think even then, it&#39;s worth the trade-off.=
<br></div></div></div></blockquote></div></blockquote><div><br></div><div>

People who don&#39;t have to pay the price always seem to think it&#39;s wo=
rth the trade-off...<br clear=3D"all"></div></div>-- <br>=A0Nevin &quot;:-)=
&quot; Liber=A0 &lt;mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=
=3D"_blank">nevin@eviloverlord.com</a>&gt;=A0 (847) 691-1404
</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7bea39f46d56ee04f407327e--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 07 Mar 2014 12:02:40 -0500
Raw View
On 2014-03-07 11:30, Zhihao Yuan wrote:
> Let throw one of my old suggestion here again:
>
>    with (make_scope_guard(...))  // tune the name or the syntax rule
>    {
>    }  // lifetime the temporary ends here

If we do that, what about 'with (expr as name)'? Also I think this
should support multiple declarations (probably separated by ',').

FWIW I'd probably keep the ()'s for consistency.

I assume the braces are optional, having the same meaning as any other
scoping keyword? (I.e. if omitted, scope is next statement.)


You could almost implement this right now as a macro, e.g.:

   #define with(expr) if(with_t ANON = (expr))

....where with_t is a template helper class that binds an
rvalue-reference to anything and has an operator bool that always
returns true, and ANON is another macro to generate a unique,
"anonymous" name.

Of course this wouldn't support the 'as' syntax.


I definitely could see a use for 'with (expr as name)'; it's possible
right now with a bare scope, but those are ugly :-).


Such a syntax would also make it easy and convenient to create e.g.
'synchronized(object)' as a macro.

--
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 09:07:26 -0800
Raw View
Em sex 07 mar 2014, =E0s 11:15:20, Matthew Woehlke escreveu:
> > void foo(int _);
>=20
> Not needed, already you can just omit the name entirely. Unlike giving=20
> it a name and them later doing '(void)param' (which documents the=20
> purpose of the parameter and/or is useful if the parameter is used e.g.=
=20
> depending on some preprocessor condition), I don't see anything gained=20
> by giving it an anonymous name versus simply omitting the name.

On that light: would the following be too difficult to accept, according to=
 the=20
language grammar?

 auto =3D 1;
 auto =3D std::scope_guard(...);
 auto =3D std::lock_guard<std::mutex>(mtx);

Since the right side has no name, it should trigger an rvalue move to the l=
eft=20
side, thus allowing uncopyable types to be used. The language should also=
=20
allow the compiler to elide the move and optimise to a simple construction.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Stack Machine <stackmachine@hotmail.com>
Date: Fri, 7 Mar 2014 09:09:56 -0800 (PST)
Raw View
------=_Part_729_18648214.1394212196954
Content-Type: text/plain; charset=UTF-8

Correct me if I'm wrong, but as I understood it, _ is just a shorthand for
gettext and it looks like it can be replaced in source code by a regex
search & replace.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_729_18648214.1394212196954
Content-Type: text/html; charset=UTF-8

<div dir="ltr">Correct me if I'm wrong, but as I understood it, _ is just a shorthand for gettext and it looks like it can be replaced in source code by a regex search &amp; replace.<br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

------=_Part_729_18648214.1394212196954--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 09:21:11 -0800
Raw View
Em sex 07 mar 2014, =E0s 09:09:56, Stack Machine escreveu:
> Correct me if I'm wrong, but as I understood it, _ is just a shorthand fo=
r
> gettext and it looks like it can be replaced in source code by a regex
> search & replace.

Are you proposing we change tens of millions of lines of code using _ as a=
=20
translation shortcut?

Also note it's a #define, so I guess we won't break them, but they'll break=
=20
this feature instead.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Brent Friedman <fourthgeek@gmail.com>
Date: Fri, 7 Mar 2014 11:33:11 -0600
Raw View
--047d7b6da028dc34ed04f407a5f3
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

In a thread started here back on Oct 4 "Unnamed LValues", I suggested,
alternately, 'auto' or '?' as an unnamed-identifier.
? may cause some conflict with bitfields and the ternary operator.

int ? : 4; //bitfield or ternary?

auto doesn't seem to create any such potential ambiguity, and being a
keyword perhaps stands out better in the code.

int auto =3D 4;
lock_guard<mutex> auto;



On Fri, Mar 7, 2014 at 11:21 AM, Thiago Macieira <thiago@macieira.org>wrote=
:

> Em sex 07 mar 2014, =E0s 09:09:56, Stack Machine escreveu:
> > Correct me if I'm wrong, but as I understood it, _ is just a shorthand
> for
> > gettext and it looks like it can be replaced in source code by a regex
> > search & replace.
>
> Are you proposing we change tens of millions of lines of code using _ as =
a
> translation shortcut?
>
> Also note it's a #define, so I guess we won't break them, but they'll bre=
ak
> this feature instead.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>       PGP/GPG: 0x6EF45358; fingerprint:
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
> --
>
> ---
> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--047d7b6da028dc34ed04f407a5f3
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">In a thread started here back on Oct 4 &quot;Unnamed LValu=
es&quot;, I suggested, alternately, &#39;auto&#39; or &#39;?&#39; as an unn=
amed-identifier.=A0<div>? may cause some conflict with bitfields and the te=
rnary operator.=A0</div>
<div><br></div><div><div>int ? : 4; //bitfield or ternary?</div><div><br></=
div></div><div>auto doesn&#39;t seem to create any such potential ambiguity=
, and being a keyword perhaps stands out better in the code.<div><br></div>
<div>int auto =3D 4;</div><div>lock_guard&lt;mutex&gt; auto;</div><div><br>=
</div></div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_qu=
ote">On Fri, Mar 7, 2014 at 11:21 AM, Thiago Macieira <span dir=3D"ltr">&lt=
;<a href=3D"mailto:thiago@macieira.org" target=3D"_blank">thiago@macieira.o=
rg</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Em sex 07 mar 2014, =E0s 09:09:56, Stack Mac=
hine escreveu:<br>
<div class=3D"">&gt; Correct me if I&#39;m wrong, but as I understood it, _=
 is just a shorthand for<br>
&gt; gettext and it looks like it can be replaced in source code by a regex=
<br>
&gt; search &amp; replace.<br>
<br>
</div>Are you proposing we change tens of millions of lines of code using _=
 as a<br>
translation shortcut?<br>
<br>
Also note it&#39;s a #define, so I guess we won&#39;t break them, but they&=
#39;ll break<br>
this feature instead.<br>
<div class=3D"im HOEnZb"><br>
--<br>
Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=3D"_b=
lank">macieira.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"=
_blank">kde.org</a><br>
=A0 =A0Software Architect - Intel Open Source Technology Center<br>
=A0 =A0 =A0 PGP/GPG: 0x6EF45358; fingerprint:<br>
=A0 =A0 =A0 E067 918B B660 DBD1 105C =A0966C 33F5 F005 6EF4 5358<br>
<br>
</div><div class=3D"HOEnZb"><div class=3D"h5">--<br>
<br>
---<br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7b6da028dc34ed04f407a5f3--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 07 Mar 2014 12:44:22 -0500
Raw View
On 2014-03-07 12:33, Brent Friedman wrote:
> In a thread started here back on Oct 4 "Unnamed LValues", I suggested,
> alternately, 'auto' or '?' as an unnamed-identifier.
> ? may cause some conflict with bitfields and the ternary operator.
>
> int ? : 4; //bitfield or ternary?
>
> auto doesn't seem to create any such potential ambiguity, and being a
> keyword perhaps stands out better in the code.

'auto&& auto = expr'? That might be a little weird... :-)

What about '#'? AFAIK it is only used for preprocessor right now, so
there is no possible ambiguity with C++, and I believe all cases where
it would normally be used, it would be preceded by something. (And
otherwise, or in pathological cases, you can always use '/**/#'.)

I thought about '#' also because it is a comment specifier in many other
languages, which gives a little logic to using it for an "I don't care
about the name" identifier.

....or maybe '@', which I don't think is currently used at all?

I think either '#' or '@' would also stand out if only because they're
not otherwise used.

--
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Brent Friedman <fourthgeek@gmail.com>
Date: Fri, 7 Mar 2014 12:08:26 -0600
Raw View
--047d7bf0e93cef117204f4082305
Content-Type: text/plain; charset=ISO-8859-1

Yep, I'd be suggesting some form of auto auto = ...;

You'd have to add @ to the basic source character set which seems like a
big change for what should be a small feature. # may require modifications
to the preprocessor.


On Fri, Mar 7, 2014 at 11:44 AM, Matthew Woehlke <
mw_triad@users.sourceforge.net> wrote:

> On 2014-03-07 12:33, Brent Friedman wrote:
>
>> In a thread started here back on Oct 4 "Unnamed LValues", I suggested,
>> alternately, 'auto' or '?' as an unnamed-identifier.
>> ? may cause some conflict with bitfields and the ternary operator.
>>
>> int ? : 4; //bitfield or ternary?
>>
>> auto doesn't seem to create any such potential ambiguity, and being a
>> keyword perhaps stands out better in the code.
>>
>
> 'auto&& auto = expr'? That might be a little weird... :-)
>
> What about '#'? AFAIK it is only used for preprocessor right now, so there
> is no possible ambiguity with C++, and I believe all cases where it would
> normally be used, it would be preceded by something. (And otherwise, or in
> pathological cases, you can always use '/**/#'.)
>
> I thought about '#' also because it is a comment specifier in many other
> languages, which gives a little logic to using it for an "I don't care
> about the name" identifier.
>
> ...or maybe '@', which I don't think is currently used at all?
>
> I think either '#' or '@' would also stand out if only because they're not
> otherwise used.
>
> --
> 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.
> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
> proposals/.
>

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--047d7bf0e93cef117204f4082305
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Yep, I&#39;d be suggesting some form of auto auto =3D=
 ...;</div><div><br></div>You&#39;d have to add @ to the basic source chara=
cter set which seems like a big change for what should be a small feature. =
# may require modifications to the preprocessor.</div>
<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Fri, Mar 7=
, 2014 at 11:44 AM, Matthew Woehlke <span dir=3D"ltr">&lt;<a href=3D"mailto=
:mw_triad@users.sourceforge.net" target=3D"_blank">mw_triad@users.sourcefor=
ge.net</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div class=3D"">On 2014-03-07 12:33, Brent F=
riedman wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
In a thread started here back on Oct 4 &quot;Unnamed LValues&quot;, I sugge=
sted,<br>
alternately, &#39;auto&#39; or &#39;?&#39; as an unnamed-identifier.<br>
? may cause some conflict with bitfields and the ternary operator.<br>
<br>
int ? : 4; //bitfield or ternary?<br>
<br>
auto doesn&#39;t seem to create any such potential ambiguity, and being a<b=
r>
keyword perhaps stands out better in the code.<br>
</blockquote>
<br></div>
&#39;auto&amp;&amp; auto =3D expr&#39;? That might be a little weird... :-)=
<br>
<br>
What about &#39;#&#39;? AFAIK it is only used for preprocessor right now, s=
o there is no possible ambiguity with C++, and I believe all cases where it=
 would normally be used, it would be preceded by something. (And otherwise,=
 or in pathological cases, you can always use &#39;/**/#&#39;.)<br>

<br>
I thought about &#39;#&#39; also because it is a comment specifier in many =
other languages, which gives a little logic to using it for an &quot;I don&=
#39;t care about the name&quot; identifier.<br>
<br>
....or maybe &#39;@&#39;, which I don&#39;t think is currently used at all?<=
br>
<br>
I think either &#39;#&#39; or &#39;@&#39; would also stand out if only beca=
use they&#39;re not otherwise used.<span class=3D"HOEnZb"><font color=3D"#8=
88888"><br>
<br>
-- <br>
Matthew</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
<br>
-- <br>
<br>
--- You received this message because you are subscribed to the Google Grou=
ps &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@<u></u>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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7bf0e93cef117204f4082305--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 11:27:30 -0800
Raw View
Em sex 07 mar 2014, =E0s 11:33:11, Brent Friedman escreveu:
> In a thread started here back on Oct 4 "Unnamed LValues", I suggested,
> alternately, 'auto' or '?' as an unnamed-identifier.
> ? may cause some conflict with bitfields and the ternary operator.
>=20
> int ? : 4; //bitfield or ternary?

I don't think this one is a problem. First, a bitfield can only be declared=
 in=20
a structure, so with context you know that it isn't a ternary operator.

Second, bitfields already allow anonymous fields:

 int : 4;

> auto doesn't seem to create any such potential ambiguity, and being a
> keyword perhaps stands out better in the code.
>=20
> int auto =3D 4;
> lock_guard<mutex> auto;

Reminds me of:
 auto int x =3D 4;

How would you use automatic detection?
 auto auto =3D 4?

PS: I wonder if anyone has realised that "auto x =3D 4" is a valid B, C89 a=
nd=20
C++11 declaration.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Jeffrey Yasskin <jyasskin@google.com>
Date: Fri, 7 Mar 2014 11:39:59 -0800
Raw View
On Fri, Mar 7, 2014 at 8:03 AM, Nevin Liber <nevin@eviloverlord.com> wrote:
> On 7 March 2014 02:07, Stack Machine <stackmachine@hotmail.com> wrote:
>>
>> Idea: Give a single underscore "_" a special meaning in contexts where an
>> identifier is expected.
>
>
> That would be a breaking change, which significantly reduces the chance that
> the committee will ever approve it.

Although "__" (two underscores) is currently reserved, so it might be ok.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Zhihao Yuan <zy@miator.net>
Date: Fri, 7 Mar 2014 14:40:55 -0500
Raw View
On Fri, Mar 7, 2014 at 12:02 PM, Matthew Woehlke
<mw_triad@users.sourceforge.net> wrote:
> On 2014-03-07 11:30, Zhihao Yuan wrote:
>>
>> Let throw one of my old suggestion here again:
>>
>>    with (make_scope_guard(...))  // tune the name or the syntax rule
>>    {
>>    }  // lifetime the temporary ends here
>
>
> If we do that, what about 'with (expr as name)'? Also I think this should
> support multiple declarations (probably separated by ',').
>
> FWIW I'd probably keep the ()'s for consistency.
>
> I assume the braces are optional, having the same meaning as any other
> scoping keyword? (I.e. if omitted, scope is next statement.)

The braces are intended to be not optional, because I also want

  A(...) : with(lock), mA(...)
  { ... }

Just like the function/constructor try ... catch block.

; separated multiple declaration would be helpful.  But I'm not
very interested in `with (e as name)`, since what would be one
more keyword (and one more declaration style for user to
remember.  Unlike Python, which also uses `T as name` in
exception handling).

> You could almost implement this right now as a macro, e.g.:
>
>   #define with(expr) if(with_t ANON = (expr))
>
> ...where with_t is a template helper class that binds an rvalue-reference to
> anything and has an operator bool that always returns true, and ANON is
> another macro to generate a unique, "anonymous" name.

Yes, if (auto&& ...) is where this idea comes from (of course,
apart from Python).

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 11:49:44 -0800
Raw View
Em sex 07 mar 2014, =E0s 11:39:59, Jeffrey Yasskin escreveu:
> Although "__" (two underscores) is currently reserved, so it might be ok.

That doesn't mean it's unused.

V8 (the JS engine from Blink / Chromium) uses it for the assembler:

https://code.google.com/p/v8/codesearch#v8/trunk/src/codegen.cc&q=3D__&sq=
=3Dpackage:v8&type=3Dcs&l=3D43
https://code.google.com/p/v8/codesearch#v8/trunk/src/x64/debug-x64.cc&q=3D_=
_&sq=3Dpackage:v8&type=3Dcs&l=3D96

Etc.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 07 Mar 2014 15:20:23 -0500
Raw View
On 2014-03-07 14:40, Zhihao Yuan wrote:
> On Fri, Mar 7, 2014 at 12:02 PM, Matthew Woehlke wrote:
>> On 2014-03-07 11:30, Zhihao Yuan wrote:
>>> Let throw one of my old suggestion here again:
>>>
>>>     with (make_scope_guard(...))  // tune the name or the syntax rule
>>>     {
>>>     }  // lifetime the temporary ends here
>>
>> If we do that, what about 'with (expr as name)'? Also I think this shoul=
d
>> support multiple declarations (probably separated by ',').
>
> ; separated multiple declaration would be helpful.

Hmm... ';' seems a little odd, but I guess e.g. for() is precedence.=20
Anyway, that's an unimportant detail.

> But I'm not very interested in `with (e as name)`, since what would
> be one more keyword (and one more declaration style for user to
> remember.

I think it would be a real shame if we introduced 'with' but it *only*=20
supported unnamed temporaries. I'm not wedded to a particular syntax for=20
declarations, though, e.g.:

   with (a =3D foo(); b =3D bar(); one(); two())

....would also be fine.

>> I assume the braces are optional, having the same meaning as any other
>> scoping keyword? (I.e. if omitted, scope is next statement.)
>
> The braces are intended to be not optional, because I also want
>
>    A(...) : with(lock), mA(...)
>    { ... }
>
> Just like the function/constructor try ... catch block.

That's not quite the same, though. The braces in that case are related=20
to the ctor body. In fact I would argue this is a specific case of *not*=20
having braces for the with().

My point is I think I should be able to write:

   with (foo())
     statement; // no braces

....just like I can write:

   if (auto a =3D foo())
     statement; // no braces

(More pedantically, the syntax for 'with' should be that the so-declared=20
variables have scope for exactly the next =C2=ABstatement=C2=BB, where of c=
ourse a=20
=C2=ABcompound-statement=C2=BB is a type of =C2=ABstatement=C2=BB. This way=
 it's consistent=20
with e.g. if(), while(), for(), etc. The ctor-scope form would be an=20
alternate syntax.)


Anyway, don't you mean:

   A(...) with(lock) : ...initializer list...

....?

--=20
Matthew

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Zhihao Yuan <zy@miator.net>
Date: Fri, 7 Mar 2014 15:35:33 -0500
Raw View
On Fri, Mar 7, 2014 at 3:20 PM, Matthew Woehlke
<mw_triad@users.sourceforge.net> wrote:
> I think it would be a real shame if we introduced 'with' but it *only*
> supported unnamed temporaries. I'm not wedded to a particular syntax for
> declarations, though, e.g.:
>
>   with (a =3D foo(); b =3D bar(); one(); two())
>
> ...would also be fine.

=3D doesn't work, since you cannot disambiguate that from
an assignment expression.  Introducing tentative parsing
or interaction with semantics analyzing here is not acceptable
(precedence is generic lambda [](a, b) {} -- works, but failed
by the committee).

>> The braces are intended to be not optional, because I also want
>>
>>    A(...) : with(lock), mA(...)
>>    { ... }
>>
>> Just like the function/constructor try ... catch block.
>
>
> That's not quite the same, though. The braces in that case are related to
> the ctor body. In fact I would argue this is a specific case of *not* hav=
ing
> braces for the with().
>
> My point is I think I should be able to write:
>
>   with (foo())
>     statement; // no braces
>
> ...just like I can write:
>
>   if (auto a =3D foo())
>     statement; // no braces

You cannot write

  try
    statement;
  catch (...)
    ;

either.

> (More pedantically, the syntax for 'with' should be that the so-declared
> variables have scope for exactly the next =C2=ABstatement=C2=BB, where of=
 course a
> =C2=ABcompound-statement=C2=BB is a type of =C2=ABstatement=C2=BB. This w=
ay it's consistent with
> e.g. if(), while(), for(), etc. The ctor-scope form would be an alternate
> syntax.)
>
>
> Anyway, don't you mean:
>
>   A(...) with(lock) : ...initializer list...
>
> ...?

Yes, I mean that.  And I believe that with() should be
consistent with that of try...catch block.

--=20
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Fri, 7 Mar 2014 14:11:23 -0800 (PST)
Raw View
------=_Part_813_14458150.1394230283717
Content-Type: text/plain; charset=UTF-8

Hi Stack Machine,

Have you considered proposing emission of the identifier instead?

Like in the following:

std::lock_guard<std::mutex> = mtx;
auto = finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs a
function at scope exit

void foo(int);

struct { ... } my_single_object;

The last two cases are already well-formed and used to declare an unnamed
entity.

From this, there are a couple of ambiguities arising between expression
statements and declaration statements with no declarator-id.  These would
have to be resolved for backward-compatibility to the existing well-formed
meaning, but for those currently ill-formed cases that remain, they could
resolve to a declaration statement like you want.

Regards,
Andrew.


On Friday, March 7, 2014 9:07:05 AM UTC+1, Stack Machine wrote:
>
> Idea: Give a single underscore "_" a special meaning in contexts where an
> identifier is expected. It means that the thing being defined is unused.
> Examples:
> std::lock_guard<std::mutex> _(mtx);
> auto _ = finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs a
> function at scope exit
>
> void foo(int _);
>
> struct _ { ... } my_single_object;
> etc. etc.
>
> This feature has been used extensively in functional languages. It solves
> the problem of unused variables nicely while being very explicit at the
> same time.
>

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_813_14458150.1394230283717
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Stack Machine,<div><br></div><div>Have you considered p=
roposing emission of the identifier instead?<div><br></div><div>Like in the=
 following:</div><div><br></div><div><div style=3D"border: 1px solid rgb(18=
7, 187, 187); background-color: rgb(250, 250, 250); word-wrap: break-word;"=
><code><span style=3D"color: rgb(0, 0, 0);">std</span><span style=3D"color:=
 rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">lock_guar=
d</span><span style=3D"color: rgb(102, 102, 0);">&lt;</span><span style=3D"=
color: rgb(0, 0, 0);">std</span><span style=3D"color: rgb(102, 102, 0);">::=
</span><span style=3D"color: rgb(0, 0, 0);">mutex</span><span style=3D"colo=
r: rgb(102, 102, 0);">&gt;</span><span style=3D"color: rgb(0, 0, 0);">&nbsp=
;=3D&nbsp;</span><span style=3D"color: rgb(0, 0, 0);">mtx</span><span style=
=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);">=
<br></span><span style=3D"color: rgb(0, 0, 136);">auto</span><span style=3D=
"color: rgb(0, 0, 0);">&nbsp;</span><span style=3D"color: rgb(102, 102, 0);=
">=3D</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=
=3D"color: rgb(0, 0, 136);">finally</span><span style=3D"color: rgb(102, 10=
2, 0);">([]{</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;std</span><sp=
an style=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0,=
 0, 0);">cout&nbsp;</span><span style=3D"color: rgb(102, 102, 0);">&lt;&lt;=
</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=3D"col=
or: rgb(0, 136, 0);">"scope exit\n"</span><span style=3D"color: rgb(102, 10=
2, 0);">;</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span sty=
le=3D"color: rgb(102, 102, 0);">});</span><span style=3D"color: rgb(0, 0, 0=
);">&nbsp;</span><span style=3D"color: rgb(136, 0, 0);">// 'finally' runs a=
 function at scope exit</span><span style=3D"color: rgb(0, 0, 0);"><br><br>=
</span><span style=3D"color: rgb(0, 0, 136);">void</span><span style=3D"col=
or: rgb(0, 0, 0);">&nbsp;foo</span><span style=3D"color: rgb(102, 102, 0);"=
>(</span><span style=3D"color: rgb(0, 0, 136);">int</span><span style=3D"co=
lor: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"><br><=
br></span><span style=3D"color: rgb(0, 0, 136);">struct</span><font color=
=3D"#000000">&nbsp;</font><span style=3D"color: rgb(102, 102, 0);">{</span>=
<span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span style=3D"color: rgb=
(102, 102, 0);">...</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span=
><span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb=
(0, 0, 0);">&nbsp;my_single_object</span><span style=3D"color: rgb(102, 102=
, 0);">;</span><span style=3D"color: rgb(0, 0, 0);"><br></span></code></div=
><div><br></div><div>The last two cases are already well-formed and used to=
 declare an unnamed entity.</div><div><br></div><div>From this, there are a=
 couple of ambiguities arising between expression statements and declaratio=
n statements with no declarator-id. &nbsp;These would have to be resolved f=
or backward-compatibility to the existing well-formed meaning, but for thos=
e currently ill-formed cases that remain, they could resolve to a declarati=
on statement like you want.</div><div><br></div><div>Regards,</div><div>And=
rew.</div><div><br></div><div><br></div>On Friday, March 7, 2014 9:07:05 AM=
 UTC+1, Stack Machine wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv dir=3D"ltr">Idea: Give a single underscore "_" a special meaning in cont=
exts where an identifier is expected. It means that the thing being defined=
 is unused.<br>Examples:<br><div style=3D"background-color:rgb(250,250,250)=
;border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wra=
p:break-word"><code><div><span style=3D"color:#000">std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">lock_guard</span><span =
style=3D"color:#660">&lt;</span><span style=3D"color:#000">std</span><span =
style=3D"color:#660">::</span><span style=3D"color:#000">mutex</span><span =
style=3D"color:#660">&gt;</span><span style=3D"color:#000"> _</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#000">mtx</span><span styl=
e=3D"color:#660">);</span><span style=3D"color:#000"><br></span><span style=
=3D"color:#008">auto</span><span style=3D"color:#000"> _ </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D=
"color:#008">finally</span><span style=3D"color:#660">([]{</span><span styl=
e=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#080">"scope exit\n"</sp=
an><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">});</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#800">// 'finally' runs a function at scope exit</span><spa=
n style=3D"color:#000"><br><br></span><span style=3D"color:#008">void</span=
><span style=3D"color:#000"> foo</span><span style=3D"color:#660">(</span><=
span style=3D"color:#008">int</span><span style=3D"color:#000"> _</span><sp=
an style=3D"color:#660">);</span><span style=3D"color:#000"><br><br></span>=
<span style=3D"color:#008">struct</span><span style=3D"color:#000"> _ </spa=
n><span style=3D"color:#660">{</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">...</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">}</span><span style=3D"color:#000"> my_single_object</=
span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br></sp=
an></div></code></div>etc. etc.<br><br>This feature has been used extensive=
ly in functional languages. It solves the problem of unused variables nicel=
y while being very explicit at the same time.<br></div></blockquote></div><=
/div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_813_14458150.1394230283717--

.


Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Fri, 7 Mar 2014 14:16:48 -0800 (PST)
Raw View
------=_Part_999_8242373.1394230608822
Content-Type: text/plain; charset=UTF-8

Errata: I mean "omission" not "emission" of course. :)

On Friday, March 7, 2014 11:11:23 PM UTC+1, Andrew Tomazos wrote:
>
> Hi Stack Machine,
>
> Have you considered proposing emission of the identifier instead?
>
> Like in the following:
>
> std::lock_guard<std::mutex> = mtx;
> auto = finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs a
> function at scope exit
>
> void foo(int);
>
> struct { ... } my_single_object;
>
> The last two cases are already well-formed and used to declare an unnamed
> entity.
>
> From this, there are a couple of ambiguities arising between expression
> statements and declaration statements with no declarator-id.  These would
> have to be resolved for backward-compatibility to the existing well-formed
> meaning, but for those currently ill-formed cases that remain, they could
> resolve to a declaration statement like you want.
>
> Regards,
> Andrew.
>
>
> On Friday, March 7, 2014 9:07:05 AM UTC+1, Stack Machine wrote:
>>
>> Idea: Give a single underscore "_" a special meaning in contexts where an
>> identifier is expected. It means that the thing being defined is unused.
>> Examples:
>> std::lock_guard<std::mutex> _(mtx);
>> auto _ = finally([]{ std::cout << "scope exit\n"; }); // 'finally' runs
>> a function at scope exit
>>
>> void foo(int _);
>>
>> struct _ { ... } my_single_object;
>> etc. etc.
>>
>> This feature has been used extensively in functional languages. It solves
>> the problem of unused variables nicely while being very explicit at the
>> same time.
>>
>

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_999_8242373.1394230608822
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Errata: I mean "omission" not "emission" of course. :)<div=
><br>On Friday, March 7, 2014 11:11:23 PM UTC+1, Andrew Tomazos wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Hi Stack Machine,<=
div><br></div><div>Have you considered proposing emission of the identifier=
 instead?<div><br></div><div>Like in the following:</div><div><br></div><di=
v><div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,=
250,250);word-wrap:break-word"><code><span style=3D"color:rgb(0,0,0)">std</=
span><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb=
(0,0,0)">lock_guard</span><span style=3D"color:rgb(102,102,0)">&lt;</span><=
span style=3D"color:rgb(0,0,0)">std</span><span style=3D"color:rgb(102,102,=
0)">::</span><span style=3D"color:rgb(0,0,0)">mutex</span><span style=3D"co=
lor:rgb(102,102,0)">&gt;</span><span style=3D"color:rgb(0,0,0)">&nbsp;=3D&n=
bsp;</span><span style=3D"color:rgb(0,0,0)"><wbr>mtx</span><span style=3D"c=
olor:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br></span><s=
pan style=3D"color:rgb(0,0,136)">auto</span><span style=3D"color:rgb(0,0,0)=
">&nbsp;</span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=
=3D"color:rgb(0,0,0)">&nbsp;</span><span style=3D"color:rgb(0,0,136)">final=
ly</span><span style=3D"color:rgb(102,102,0)">([]{</span><span style=3D"col=
or:rgb(0,0,0)">&nbsp;std</span><span style=3D"color:rgb(102,102,0)">::</spa=
n><span style=3D"color:rgb(0,0,0)">cout&nbsp;</span><span style=3D"color:rg=
b(102,102,0)">&lt;<wbr>&lt;</span><span style=3D"color:rgb(0,0,0)">&nbsp;</=
span><span style=3D"color:rgb(0,136,0)">"scope exit\n"</span><span style=3D=
"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)">&nbsp;</spa=
n><span style=3D"color:rgb(102,102,0)">});</span><span style=3D"color:rgb(0=
,0,0)">&nbsp;</span><span style=3D"color:rgb(136,0,0)">// 'finally' runs a =
function at scope exit</span><span style=3D"color:rgb(0,0,0)"><br><br></spa=
n><span style=3D"color:rgb(0,0,136)">void</span><span style=3D"color:rgb(0,=
0,0)">&nbsp;foo</span><span style=3D"color:rgb(102,102,0)">(</span><span st=
yle=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(102,102,0)">)=
;</span><span style=3D"color:rgb(0,0,0)"><br><br></span><span style=3D"colo=
r:rgb(0,0,136)">struct</span><font color=3D"#000000">&nbsp;</font><span sty=
le=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)">&nbsp;=
</span><span style=3D"color:rgb(102,102,0)">...</span><span style=3D"color:=
rgb(0,0,0)">&nbsp;</span><span style=3D"color:rgb(102,102,0)">}</span><span=
 style=3D"color:rgb(0,0,0)">&nbsp;my_single_<wbr>object</span><span style=
=3D"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br></sp=
an></code></div><div><br></div><div>The last two cases are already well-for=
med and used to declare an unnamed entity.</div><div><br></div><div>From th=
is, there are a couple of ambiguities arising between expression statements=
 and declaration statements with no declarator-id. &nbsp;These would have t=
o be resolved for backward-compatibility to the existing well-formed meanin=
g, but for those currently ill-formed cases that remain, they could resolve=
 to a declaration statement like you want.</div><div><br></div><div>Regards=
,</div><div>Andrew.</div><div><br></div><div><br></div>On Friday, March 7, =
2014 9:07:05 AM UTC+1, Stack Machine wrote:<blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr">Idea: Give a single underscore "_" a special meani=
ng in contexts where an identifier is expected. It means that the thing bei=
ng defined is unused.<br>Examples:<br><div style=3D"background-color:rgb(25=
0,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1p=
x;word-wrap:break-word"><code><div><span style=3D"color:#000">std</span><sp=
an style=3D"color:#660">::</span><span style=3D"color:#000">lock_guard</spa=
n><span style=3D"color:#660">&lt;</span><span style=3D"color:#000">std</spa=
n><span style=3D"color:#660">::</span><span style=3D"color:#000">mutex</spa=
n><span style=3D"color:#660">&gt;</span><span style=3D"color:#000"> _</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">mtx</span><s=
pan style=3D"color:#660">);</span><span style=3D"color:#000"><br></span><sp=
an style=3D"color:#008">auto</span><span style=3D"color:#000"> _ </span><sp=
an style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span><span =
style=3D"color:#008">finally</span><span style=3D"color:#660">([]{</span><s=
pan style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><sp=
an style=3D"color:#000">cout </span><span style=3D"color:#660">&lt;&lt;</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#080">"scope exi=
t\n"</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#660">});</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#800">// 'finally' runs a function at scope exit</s=
pan><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">vo=
id</span><span style=3D"color:#000"> foo</span><span style=3D"color:#660">(=
</span><span style=3D"color:#008">int</span><span style=3D"color:#000"> _</=
span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br><br=
></span><span style=3D"color:#008">struct</span><span style=3D"color:#000">=
 _ </span><span style=3D"color:#660">{</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">...</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">}</span><span style=3D"color:#000"> my_single_=
object</span><span style=3D"color:#660">;</span><span style=3D"color:#000">=
<br></span></div></code></div>etc. etc.<br><br>This feature has been used e=
xtensively in functional languages. It solves the problem of unused variabl=
es nicely while being very explicit at the same time.<br></div></blockquote=
></div></div></div></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_999_8242373.1394230608822--

.


Author: David Krauss <potswa@gmail.com>
Date: Fri, 7 Mar 2014 17:02:51 -0800 (PST)
Raw View
------=_Part_2_31157749.1394240571788
Content-Type: text/plain; charset=UTF-8



On Saturday, March 8, 2014 12:03:44 AM UTC+8, Nevin ":-)" Liber wrote:
>
> On 7 March 2014 02:07, Stack Machine <stackm...@hotmail.com <javascript:>>wrote:
>
>> Idea: Give a single underscore "_" a special meaning in contexts where an
>> identifier is expected.
>>
>
> That would be a breaking change, which significantly reduces the chance
> that the committee will ever approve it.
>

Not to personally endorse anything, but breakage can be avoided completely
by making the rule an allowance to redeclare _ in the same scope, not to
cease recognizing it as an id-expression.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_2_31157749.1394240571788
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, March 8, 2014 12:03:44 AM UTC+8, Nevi=
n ":-)" Liber wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On 7 March 2014 02:07, Stack Machine <span dir=3D"ltr">&lt;<a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"ARPwzLkmLxwJ" o=
nmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=
=3D'javascript:';return true;">stackm...@hotmail.com</a>&gt;</span> wrote:<=
br><div><div class=3D"gmail_quote">

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Idea: Give a single undersc=
ore "_" a special meaning in contexts where an identifier is expected.</div=
>

</blockquote><div><br></div><div>That would be a breaking change, which sig=
nificantly reduces the chance that the committee will ever approve it.<br c=
lear=3D"all"></div></div></div></div></blockquote><div><br></div><div>Not t=
o personally endorse anything, but breakage can be avoided completely by ma=
king the rule an allowance to redeclare _ in the same scope, not to cease r=
ecognizing it as an id-expression.<br><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2_31157749.1394240571788--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 17:06:09 -0800
Raw View
Em sex 07 mar 2014, =E0s 17:02:51, David Krauss escreveu:
> On Saturday, March 8, 2014 12:03:44 AM UTC+8, Nevin ":-)" Liber wrote:
> > On 7 March 2014 02:07, Stack Machine <stackm...@hotmail.com=20
<javascript:>>wrote:
> >> Idea: Give a single underscore "_" a special meaning in contexts where=
 an
> >> identifier is expected.
> >=20
> > That would be a breaking change, which significantly reduces the chance
> > that the committee will ever approve it.
>=20
> Not to personally endorse anything, but breakage can be avoided completel=
y
> by making the rule an allowance to redeclare _ in the same scope, not to
> cease recognizing it as an id-expression.

How do you deal with

#define _ gettext

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: morwenn29@gmail.com
Date: Fri, 7 Mar 2014 17:32:06 -0800 (PST)
Raw View
------=_Part_1189_24896789.1394242326158
Content-Type: text/plain; charset=UTF-8

Here is how I would use the keyword with:

    with (auto foo: expr)
    {
        // do something with foo...
    }

The syntax would be consistent with the range-base foor loop syntax.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_1189_24896789.1394242326158
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Here is how I would use the keyword with:<br><br>&nbsp;&nb=
sp;&nbsp; with (auto foo: expr)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp; // do something with foo...<br>&nbsp;&nbsp;&nbsp=
; }<br><br>The syntax would be consistent with the range-base foor loop syn=
tax.<br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1189_24896789.1394242326158--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 08 Mar 2014 02:52:42 +0100
Raw View
This is a multi-part message in MIME format.
--------------060109070900000108030600
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 07/03/14 09:07, Stack Machine a =C3=A9crit :
> Idea: Give a single underscore "_" a special meaning in contexts where=20
> an identifier is expected. It means that the thing being defined is=20
> unused.
> Examples:
> |
> std::lock_guard<std::mutex>_(mtx);
> auto_ =3Dfinally([]{std::cout <<"scope exit\n";});// 'finally' runs a=20
> function at scope exit
>
> voidfoo(int_);
>
> struct_ {...}my_single_object;
> |
> etc. etc.
>
> This feature has been used extensively in functional languages. It=20
> solves the problem of unused variables nicely while being very=20
> explicit at the same time.
>
Hi,

some time ago I proposed in this ML something similar " let-in=20
statements and anonymous variables" (see [1])
This covers the with expression proposed in another post in this thread =20
and the anonymous variable.  Instead of using a new keyword 'with' I=20
proposed to use : to separate the declaration and the statement. IMO,=20
the best name for an anonymous variable is nothing.

The following

   auto  =3D expression : statement

will be equivalent to

   {
     const auto __uid__=3D expression; statement
   }

where __uid__ is a new unique identifier generated by the compiler.

Vicente

[1]=20
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/BfAtczj8=
1Kg

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 07/03/14 09:07, Stack Machine a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:a5361346-87f3-4d91-9555-2f5a5295ccc2@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">Idea: Give a single underscore "_" a special
        meaning in contexts where an identifier is expected. It means
        that the thing being defined is unused.<br>
        Examples:<br>
        <div class=3D"prettyprint" style=3D"background-color: rgb(250, 250,
          250); border-color: rgb(187, 187, 187); border-style: solid;
          border-width: 1px; word-wrap: break-word;"><code
            class=3D"prettyprint">
            <div class=3D"subprettyprint"><span style=3D"color: #000;"
                class=3D"styled-by-prettify">std</span><span style=3D"color=
:
                #660;" class=3D"styled-by-prettify">::</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify">lock_gu=
ard</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify">std</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">mutex</=
span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> _</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify">mtx</sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
              </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">auto</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> _ </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">finally=
</span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">([]{</s=
pan><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify">cout </=
span><span
                style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt=
;</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #080;" class=3D"styled-by-prettify">"scope
                exit\n"</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">});</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #800;" class=3D"styled-by-prettify">//
                'finally' runs a function at scope exit</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
              </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">void</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> foo</s=
pan><span
                style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span
                style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> _</spa=
n><span
                style=3D"color: #660;" class=3D"styled-by-prettify">);</spa=
n><span
                style=3D"color: #000;" class=3D"styled-by-prettify"><br>
                <br>
              </span><span style=3D"color: #008;"
                class=3D"styled-by-prettify">struct</span><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> _ </sp=
an><span
                style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span
                style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
                style=3D"color: #660;" class=3D"styled-by-prettify">...</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">
                my_single_object</span><span style=3D"color: #660;"
                class=3D"styled-by-prettify">;</span><span style=3D"color:
                #000;" class=3D"styled-by-prettify"><br>
              </span></div>
          </code></div>
        etc. etc.<br>
        <br>
        This feature has been used extensively in functional languages.
        It solves the problem of unused variables nicely while being
        very explicit at the same time.<br>
      </div>
      <br>
    </blockquote>
    Hi,<br>
    <br>
    some time ago I proposed in this ML something similar "
    <meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF-8=
">
    <span id=3D"t-t" class=3D"GB-CK03DM5B">let-in statements and anonymous
      variables" (see </span>
    <meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF-8=
">
    [1]) <br>
    This covers the with expression proposed in another post in this
    thread=C2=A0 and the anonymous variable.=C2=A0 Instead of using a new k=
eyword
    'with' I proposed to use : to separate the declaration and the
    statement. IMO, the best name for an anonymous variable is nothing.<br>
    <br>
    <meta http-equiv=3D"content-type" content=3D"text/html; charset=3DUTF-8=
">
    The following<br>
    <br>
    =C2=A0 auto=C2=A0 =3D expression : statement<br>
    <br>
    will be equivalent to<br>
    <br>
    =C2=A0 {<br>
    =C2=A0=C2=A0=C2=A0 const auto __uid__=3D expression; statement<br>
    =C2=A0 }<br>
    <br>
    where __uid__ is a new unique identifier generated by the compiler.<br>
    <br>
    Vicente<br>
    <br>
    [1]
<a class=3D"moz-txt-link-freetext" href=3D"https://groups.google.com/a/isoc=
pp.org/forum/#!topic/std-proposals/BfAtczj81Kg">https://groups.google.com/a=
/isocpp.org/forum/#!topic/std-proposals/BfAtczj81Kg</a><br>
  </body>
</html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--------------060109070900000108030600--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 8 Mar 2014 12:18:31 +0800
Raw View
On 2014-03-08, at 9:06 AM, Thiago Macieira <thiago@macieira.org> wrote:

> Em sex 07 mar 2014, =E0s 17:02:51, David Krauss escreveu:
>> Not to personally endorse anything, but breakage can be avoided complete=
ly
>> by making the rule an allowance to redeclare _ in the same scope, not to
>> cease recognizing it as an id-expression.
>=20
> How do you deal with
>=20
> #define _ gettext

Usage of the gettext library wouldn't be affected, because the compiler wou=
ld never see _ appear in a declaration in the first place. Effectively the =
macro would override the special underscore semantics by hiding the undersc=
ore token completely. Of course, the user could opt to #undef it.

The library-provided _ macro would break other libraries which want that id=
entifier, but that is nothing new! It's obviously dangerous, so they should=
 have had the common sense to optionally disable it, or at least warn users=
 that it should be included only after other potentially sensitive headers =
which might use the _ token.

Again, I don't want to suggest that it's a really good idea, but it's certa=
inly workable. It might exacerbate, but it does not introduce a problem tha=
t didn't already exist.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 8 Mar 2014 12:23:47 +0800
Raw View
On 2014-03-08, at 9:52 AM, Vicente J. Botet Escriba <vicente.botet@wanadoo.=
fr> wrote:

> some time ago I proposed in this ML something similar " let-in statements=
 and anonymous variables" (see [1])=20

We already have unnamed parameters, whose lifetime duration is that of the =
function, and discarded-value expressions. What is proposed is only a handl=
e to adjust the lifetime of a discarded value object that exists in any cas=
e. This cannot be related to functional semantics, because in functional la=
nguages variables do not have lifetimes.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 20:27:05 -0800
Raw View
Em s=E1b 08 mar 2014, =E0s 12:18:31, David Krauss escreveu:
> The library-provided _ macro would break other libraries which want that
> identifier, but that is nothing new! It's obviously dangerous, so they
> should have had the common sense to optionally disable it, or at least wa=
rn
> users that it should be included only after other potentially sensitive
> headers which might use the _ token.

That also means you may never use the special _ in a header.
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 8 Mar 2014 12:34:01 +0800
Raw View
On 2014-03-08, at 12:27 PM, Thiago Macieira <thiago@macieira.org> wrote:

> Em s=E1b 08 mar 2014, =E0s 12:18:31, David Krauss escreveu:
>> The library-provided _ macro would break other libraries which want that
>> identifier, but that is nothing new! It's obviously dangerous, so they
>> should have had the common sense to optionally disable it, or at least w=
arn
>> users that it should be included only after other potentially sensitive
>> headers which might use the _ token.
>=20
> That also means you may never use the special _ in a header.

I don't understand. If you use gettext, then every declaration of _ will be=
 munged to a declaration of gettext. This doesn't change; the proposal mere=
ly makes the _ identifier more desirable. Anyway, either gettext provides a=
 flag to disable that macro, or you can #undef it yourself.

If libraries besides gettext define macros named _, then they are all mutua=
lly incompatible. What do we care about such boneheaded interfaces?

My suggestion to allow declarations of _ to hide preceding declarations in =
the same scope is not a breaking change, because such declarations are ill-=
formed. Corner cases like overloading and elaborated-type-specifiers would =
need to be resolved somehow, but that's immaterial.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 20:40:40 -0800
Raw View
Em s=E1b 08 mar 2014, =E0s 12:34:01, David Krauss escreveu:
> On 2014-03-08, at 12:27 PM, Thiago Macieira <thiago@macieira.org> wrote:
> > Em s=E1b 08 mar 2014, =E0s 12:18:31, David Krauss escreveu:
> >> The library-provided _ macro would break other libraries which want th=
at
> >> identifier, but that is nothing new! It's obviously dangerous, so they
> >> should have had the common sense to optionally disable it, or at least
> >> warn
> >> users that it should be included only after other potentially sensitiv=
e
> >> headers which might use the _ token.
> >=20
> > That also means you may never use the special _ in a header.
>=20
> I don't understand. If you use gettext, then every declaration of _ will =
be
> munged to a declaration of gettext. This doesn't change; the proposal
> merely makes the _ identifier more desirable. Anyway, either gettext
> provides a flag to disable that macro, or you can #undef it yourself.

You missed the point.

If I'm writing a header, I don't know whether my header will be included af=
ter=20
the header that #defines _. If it is included after, then I can't use _ sin=
ce=20
it will expand to gettext, which is not a special identifier.

Therefore, I may never use this feature in headers. Ever.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 8 Mar 2014 14:10:06 +0800
Raw View
--Apple-Mail=_8B1184B5-077C-42BE-929C-FD1C5DE745EA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-03-08, at 12:40 PM, Thiago Macieira <thiago@macieira.org> wrote:

> You missed the point.
>=20
> If I'm writing a header, I don't know whether my header will be included =
after=20
> the header that #defines _. If it is included after, then I can't use _ s=
ince=20
> it will expand to gettext, which is not a special identifier.
>=20
> Therefore, I may never use this feature in headers. Ever.

Every time you use any identifier, you tacitly assume it hasn't been define=
d to something by a header. Such conflicts do occur, but the sky isn't fall=
ing.

Rather than arguing this further though, consider this example:

    make_scope_guard( [&] { t.rollback(); } ); // Expression-statement; no =
declaration.

This is a very dangerous kind of error.

The line immediately executes the guard body, but because that is a destruc=
tor (and noexcept), it probably doesn't have very dramatic side effects. Mo=
st likely, it just deallocates some resources. But since it is executing at=
 the earliest possible opportunity, there are likely to be no resources yet=
 to deallocate, so it's a complete no-op. But the correct usage also produc=
es a no-op at this point, so there's no detectable failure yet.

When we get to the end of the scope, we might do something like t.commit().=
 But that is also likely to free the same resources, and in most cases a tr=
ansaction guard is supposed to be a no-op after a commit.

In the end, the guard protects nothing, and the software behaves fine until=
 an actual exceptional condition occurs. There is no diagnosable error in t=
he function call. At best a platform could provide an unportable [noignore]=
 attribute, or give warnings specifically for the std:: facility, which the=
n surprisingly vanish when it is encapsulated somehow.

This is totally unacceptable for a utility intended for reliable programmin=
g. Once this more serious issue is resolved, the motivation for unused iden=
tifiers might just go away. Or, it might not. But right now I think the foc=
us is on the wrong problem.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_8B1184B5-077C-42BE-929C-FD1C5DE745EA
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;03&ndash;08, at 12:40 PM, Thiago Macieira &lt;<a href=3D"mailto:thiag=
o@macieira.org">thiago@macieira.org</a>&gt; wrote:</div><br class=3D"Apple-=
interchange-newline"><blockquote type=3D"cite"><div style=3D"font-size: 12p=
x; font-style: normal; font-variant: normal; font-weight: normal; letter-sp=
acing: normal; line-height: normal; orphans: auto; text-align: start; text-=
indent: 0px; text-transform: none; white-space: normal; widows: auto; word-=
spacing: 0px; -webkit-text-stroke-width: 0px;">You missed the point.<br><br=
>If I'm writing a header, I don't know whether my header will be included a=
fter<span class=3D"Apple-converted-space">&nbsp;</span><br>the header that =
#defines _. If it is included after, then I can't use _ since<span class=3D=
"Apple-converted-space">&nbsp;</span><br>it will expand to gettext, which i=
s not a special identifier.<br><br>Therefore, I may never use this feature =
in headers. Ever.<br></div></blockquote><div><br></div><div>Every time you =
use any identifier, you tacitly assume it hasn&rsquo;t been defined to some=
thing by a header. Such conflicts do occur, but the sky isn&rsquo;t falling=
..</div><div><br></div></div><div>Rather than arguing this further though, c=
onsider this example:</div><div><br></div><div><font face=3D"Courier">&nbsp=
; &nbsp; make_scope_guard( [&amp;] { t.rollback(); } ); // Expression-state=
ment; no declaration.</font></div><div><br></div><div>This is a very danger=
ous kind of error.</div><div><br></div><div>The line immediately executes t=
he guard body, but because that is a destructor (and <font face=3D"Courier"=
>noexcept</font>), it probably doesn&rsquo;t have very dramatic side effect=
s. Most likely, it just deallocates some resources. But since it is executi=
ng at the earliest possible opportunity, there are likely to be no resource=
s yet to deallocate, so it&rsquo;s a complete no-op. But the correct usage =
also produces a no-op at this point, so there&rsquo;s no detectable failure=
 yet.</div><div><br></div><div>When we get to the end of the scope, we migh=
t do something like <font face=3D"Courier">t.commit()</font>. But that is a=
lso likely to free the same resources, and in most cases a transaction guar=
d is supposed to be a no-op after a commit.</div><div><br></div><div>In the=
 end, the guard protects nothing, and the software behaves fine until an ac=
tual exceptional condition occurs. There is no diagnosable error in the fun=
ction call. At best a platform could provide an unportable <font face=3D"Co=
urier">[noignore]</font> attribute, or give warnings specifically for the <=
font face=3D"Courier">std::</font> facility, which then surprisingly vanish=
 when it is encapsulated somehow.</div><div><br></div><div>This is totally =
unacceptable for a utility intended for reliable programming. Once this mor=
e serious issue is resolved, the motivation for unused identifiers might ju=
st go away. Or, it might not. But right now I think the focus is on the wro=
ng problem.</div><div><br></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_8B1184B5-077C-42BE-929C-FD1C5DE745EA--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 07 Mar 2014 22:31:33 -0800
Raw View
Em s=E1b 08 mar 2014, =E0s 14:10:06, David Krauss escreveu:
> On 2014-03-08, at 12:40 PM, Thiago Macieira <thiago@macieira.org> wrote:
> > You missed the point.
> >=20
> > If I'm writing a header, I don't know whether my header will be include=
d
> > after the header that #defines _. If it is included after, then I can't
> > use _ since it will expand to gettext, which is not a special identifie=
r.
> >=20
> > Therefore, I may never use this feature in headers. Ever.
>=20
> Every time you use any identifier, you tacitly assume it hasn't been defi=
ned
> to something by a header. Such conflicts do occur, but the sky isn't
> falling.

Indeed.

But usually I also take care not to name my variables after identifiers tha=
t=20
are usually #defined to something. That's why you never call your variables=
=20
O_RDONLY, interface, sun, linux, s6_addr, sa_handler, m_volume, or _.

> This is totally unacceptable for a utility intended for reliable
> programming. Once this more serious issue is resolved, the motivation for
> unused identifiers might just go away. Or, it might not. But right now I
> think the focus is on the wrong problem.

I think there's a valid use-case in this thread for anonymous variables, ju=
st=20
like we can have anonymous parameters and anonymous fields in a bitfield. I=
'm=20
simply arguing against using _ as a special identifier.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 8 Mar 2014 15:24:03 +0800
Raw View
--Apple-Mail=_BA4F776B-DF58-42FD-8361-DFA0BE654070
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-03-08, at 2:31 PM, Thiago Macieira <thiago@macieira.org> wrote:

> But usually I also take care not to name my variables after identifiers t=
hat=20
> are usually #defined to something. That's why you never call your variabl=
es=20
> O_RDONLY, interface, sun, linux, s6_addr, sa_handler, m_volume, or _.

Libraries which use identifiers named _ or M or interface or noexcept or wh=
atever put themselves in harm's way, and libraries which define such things=
 as macros much more so. There is such a thing as obsolescence due to poor =
interface design, and the death knell always comes down to some degree of b=
ad luck.

This is probably the most pressing issue under the "modules" umbrella, give=
n the preponderance of complex header libraries, and hopefully it will be s=
olved.

Most things that define _ can probably be classified as domain-specific lan=
guages, and migration is always more complicated for such code, but the pro=
blem may at least be isolated to sources actually using the DSL. How often =
do implementations vary the ABI with the language dialect? A source compile=
d with -std=3Dc++11 should link with a -std=3Dc++14 one from the exact same=
 compiler, right? Of course this is implementation-dependent but it seems l=
ike common sense.

> I think there's a valid use-case in this thread for anonymous variables, =
just=20
> like we can have anonymous parameters and anonymous fields in a bitfield.=
 I'm=20
> simply arguing against using _ as a special identifier.

I went and scanned the entire thread, and I don't see any real use case ill=
ustrated besides guards. What's missing?

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_BA4F776B-DF58-42FD-8361-DFA0BE654070
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;03&ndash;08, at 2:31 PM, Thiago Macieira &lt;<a href=3D"mailto:thiago=
@macieira.org">thiago@macieira.org</a>&gt; wrote:</div><br class=3D"Apple-i=
nterchange-newline"><blockquote type=3D"cite">But usually I also take care =
not to name my variables after identifiers that <br>are usually #defined to=
 something. That's why you never call your variables <br>O_RDONLY, interfac=
e, sun, linux, s6_addr, sa_handler, m_volume, or _.<br></blockquote><div><b=
r></div><div>Libraries which use identifiers named _ or M or interface or n=
oexcept or whatever put themselves in harm&rsquo;s way, and libraries which=
 define such things as macros much more so. There is such a thing as obsole=
scence due to poor interface design, and the death knell always comes down =
to some degree of bad luck.</div><div><br></div><div>This is probably the m=
ost pressing issue under the &ldquo;modules&rdquo; umbrella, given the prep=
onderance of complex header libraries, and hopefully it will be solved.</di=
v><div><br></div><div>Most things that define _ can probably be classified =
as domain-specific languages, and migration is always more complicated for =
such code, but the problem may at least be isolated to sources actually usi=
ng the DSL. How often do implementations vary the ABI with the language dia=
lect? A source compiled with <font face=3D"Courier">-std=3Dc++11</font> sho=
uld link with a <font face=3D"Courier">-std=3Dc++14</font> one from the exa=
ct same compiler, right? Of course this is implementation-dependent but it =
seems like common sense.</div><br><blockquote type=3D"cite">I think there's=
 a valid use-case in this thread for anonymous variables, just <br>like we =
can have anonymous parameters and anonymous fields in a bitfield. I'm <br>s=
imply arguing against using _ as a special identifier.<br></blockquote><div=
><br></div></div>I went and scanned the entire thread, and I don&rsquo;t se=
e any real use case illustrated besides guards. What&rsquo;s missing?<div><=
br></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_BA4F776B-DF58-42FD-8361-DFA0BE654070--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Mon, 10 Mar 2014 11:46:16 -0400
Raw View
On 2014-03-08 01:10, David Krauss wrote:
> Rather than arguing this further though, consider this example:
>
>      make_scope_guard( [&] { t.rollback(); } ); // Expression-statement; no declaration.
>
> This is a very dangerous kind of error.

....isn't that solved by making make_scope_guard warn if the return value
is unused? (And don't we already have facilities for doing that sort of
thing?)

--
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 11 Mar 2014 07:43:25 +0800
Raw View
--Apple-Mail=_30C753FB-D5CF-4A58-AC14-A50E25F6F60E
Content-Type: text/plain; charset=ISO-8859-1


On 2014-03-10, at 11:46 PM, Matthew Woehlke <mw_triad@users.sourceforge.net> wrote:

> On 2014-03-08 01:10, David Krauss wrote:
>> Rather than arguing this further though, consider this example:
>>
>>     make_scope_guard( [&] { t.rollback(); } ); // Expression-statement; no declaration.
>>
>> This is a very dangerous kind of error.
>
> ...isn't that solved by making make_scope_guard warn if the return value is unused? (And don't we already have facilities for doing that sort of thing?)

No facility that I'm aware of. I explore the problem in my forthcoming paper, with three solutions:

1. explicit operator void() discard operator prevents discarding the return value -- non-breaking core language change, with application to expression templates.
2. class & guard { class-head value category restriction specifier prevents the guard from being a temporary -- non-breaking core language change, with a different application to expression templates.
3. class guard : std::guard_base { -- the compiler knows about std::guard_base and warns if a derived class is a discarded value. No language extension needed. Derivation from guard_base may be useful for other reasons as well.

So far, I plan to recommend #3 as an immediate, compatible solution, but it still requires (optional) compiler support be added, because no similar facility exists. The others are superior and hopefully those changes can be included in C++17.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--Apple-Mail=_30C753FB-D5CF-4A58-AC14-A50E25F6F60E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;03&ndash;10, at 11:46 PM, Matthew Woehlke &lt;<a href=3D"mailto:mw_tr=
iad@users.sourceforge.net">mw_triad@users.sourceforge.net</a>&gt; wrote:</d=
iv><br class=3D"Apple-interchange-newline"><blockquote type=3D"cite">On 201=
4-03-08 01:10, David Krauss wrote:<br><blockquote type=3D"cite">Rather than=
 arguing this further though, consider this example:<br><br> &nbsp;&nbsp;&n=
bsp;&nbsp;make_scope_guard( [&amp;] { t.rollback(); } ); // Expression-stat=
ement; no declaration.<br><br>This is a very dangerous kind of error.<br></=
blockquote><br>...isn't that solved by making make_scope_guard warn if the =
return value is unused? (And don't we already have facilities for doing tha=
t sort of thing?)<br></blockquote><div><br></div>No facility that I&rsquo;m=
 aware of. I explore the problem in my forthcoming paper, with three soluti=
ons:</div><div><br></div><div>1. <font face=3D"Courier">explicit operator v=
oid()</font> discard operator prevents discarding the return value &mdash; =
non-breaking core language change, with application to expression templates=
..</div><div>2. <font face=3D"Courier">class &amp; guard {</font>&nbsp;class=
-head value category restriction specifier prevents the guard from being a =
temporary &mdash; non-breaking core language change, with a different appli=
cation to expression templates.</div><div>3. <font face=3D"Courier">class g=
uard : std::guard_base {</font>&nbsp;&mdash; the compiler knows about <font=
 face=3D"Courier">std::guard_base</font> and warns if a derived class is a =
discarded value. No language extension needed. Derivation from&nbsp;<font f=
ace=3D"Courier">guard_base</font>&nbsp;may be useful for other reasons as w=
ell.</div><div><br></div><div>So far, I plan to recommend #3 as an immediat=
e, compatible solution, but it still requires (optional) compiler support b=
e added, because no similar facility exists. The others are superior and ho=
pefully those changes can be included in C++17.</div><div><br></div></body>=
</html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_30C753FB-D5CF-4A58-AC14-A50E25F6F60E--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Tue, 11 Mar 2014 11:45:29 -0400
Raw View
On 2014-03-10 19:43, David Krauss wrote:
> On 2014-03-10, at 11:46 PM, Matthew Woehlke wrote:
>> On 2014-03-08 01:10, David Krauss wrote:
>>> Rather than arguing this further though, consider this example:
>>>
>>>      make_scope_guard( [&] { t.rollback(); } ); // Expression-statement; no declaration.
>>>
>>> This is a very dangerous kind of error.
>>
>> ...isn't that solved by making make_scope_guard warn if the return
>> value is unused? (And don't we already have facilities for doing
>> that sort of thing?)
>
> No facility that I'm aware of.

....then what does __attribute__((warn_unused_result)) do? As I
understood it is *exactly* dealing with cases such as the above.

Although it doesn't address the case:

   scope_guard{...};

....though I would be somewhat surprised if that isn't already warned about.

That said...

> 1. explicit operator void() discard operator prevents discarding the
> return value -- non-breaking core language change, with application
> to expression templates.

....this sounds like it would be an interesting addition. (I take it this
would make failure to assign such a class to a named identifier an error?)

--
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: David Krauss <potswa@gmail.com>
Date: Wed, 12 Mar 2014 00:35:15 +0800
Raw View
--Apple-Mail=_63148564-A320-4EEE-91D7-D6BE52C5B75E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-03-11, at 11:45 PM, Matthew Woehlke <mw_triad@users.sourceforge.net=
> wrote:

> ...then what does __attribute__((warn_unused_result)) do? As I understood=
 it is *exactly* dealing with cases such as the above.

You seem to presume I know something :v) . Thanks for the info. But, a quic=
k search suggests that a significant number of users may disable that warni=
ng, because it is used for return values that are merely insecure if ignore=
d, not utterly wrong. A bit more contrived, the user could pass the result =
of make_guard to something, e.g. std::move( make_guard( ... ) ).

Apparently MSVC lacks an equivalent feature. I think it would be better to =
standardize this, and not leave it to QOI.

> Although it doesn't address the case:
>=20
>  scope_guard{...};
>=20
> ...though I would be somewhat surprised if that isn't already warned abou=
t.

I see nothing there to generate a warning, but it's a non-issue because we =
can assume the factory is the only useful handle.

Actually, one avenue I'll explore is an implementation-defined guard class.=
 I don't think the user needs to be able to name it at all. Boost.ScopeExit=
 hides both the class and the object.

> That said...
>=20
>> 1. explicit operator void() discard operator prevents discarding the
>> return value -- non-breaking core language change, with application
>> to expression templates.
>=20
> ...this sounds like it would be an interesting addition. (I take it this =
would make failure to assign such a class to a named identifier an error?)

That describes the second alternative. Here is a preview of the relevant se=
ction:

> Alternative solutions, requiring core language changes, may be explored. =
Here are two.
>=20
> 2.1.1. Discarded value operator
>=20
> As a purely diagnostic measure, the guard class could be forbidden from f=
orming a discarded value expression. Another case where trapping discarded =
values is useful is a matrix expression template involving multiple assignm=
ent operations. Currently, an expression template must decay at each assign=
ment operation, ignoring some loop interleavings. The relevance here is tha=
t such a feature would not be dedicated to guard safety.
>=20
> The natural discarded value operator is operator void(). An expression-st=
atement with type T could be considered as an implicit conversion from T to=
 void, therefore a guard class would only need to declare explicit operator=
 void() {} to give the example an illegal implicit conversion. Explicitly c=
asting a guard object to void would still be legal.
>=20
> 2.1.2. Restriction of class value category
>=20
> The class could be forbidden from forming a prvalue expression. This woul=
d forbid the guard ever being an anonymous, discarded object. Function retu=
rn values are always of category prvalue though, so the best middle ground =
is to also permit a lifetime-extended temporary.
>=20
> The restriction could be expressed by a class-head decorator such as &. T=
he corresponding && decorator would conversely express that instances canno=
t be named (or lifetime-extended), such as expression template specializati=
ons. Inheritance of this decorator is a difficult question. One simple solu=
tion is to make them class-virt-specifiers implying final, thus prohibiting=
 derivation.
>=20
> This rather elegantly removes the danger, but it does not improve conveni=
ence. The ideal solution would simply fix the bare function call expression=
 to be correct. Such a & specifier may be sufficiently expressive to allow =
the language to surmise that a discarded prvalue, rather than being ill-for=
med, should be interpreted as being bound to an anonymous reference.
>=20

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_63148564-A320-4EEE-91D7-D6BE52C5B75E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;03&ndash;11, at 11:45 PM, Matthew Woehlke &lt;<a href=3D"mailto:mw_tr=
iad@users.sourceforge.net">mw_triad@users.sourceforge.net</a>&gt; wrote:</d=
iv><br class=3D"Apple-interchange-newline"><blockquote type=3D"cite">...the=
n what does __attribute__((warn_unused_result)) do? As I understood it is *=
exactly* dealing with cases such as the above.<br></blockquote><div><br></d=
iv><div>You seem to presume I know something :v) . Thanks for the info. But=
, a quick search&nbsp;<a href=3D"http://gcc.gnu.org/bugzilla/show_bug.cgi?i=
d=3D25509">suggests</a>&nbsp;that a significant number of users may disable=
 that warning, because it is used for return values that are merely insecur=
e if ignored, not utterly wrong. A bit more contrived, the user could&nbsp;=
pass the result of&nbsp;<font face=3D"Courier">make_guard</font>&nbsp;to so=
mething, e.g.&nbsp;<font face=3D"Courier">std::move( make_guard( &hellip; )=
 )</font>.</div><div><br></div><div><a href=3D"http://stackoverflow.com/q/4=
226308/153285">Apparently</a>&nbsp;MSVC lacks an equivalent feature. I thin=
k it would be better to standardize this, and not leave it to QOI.</div><di=
v><br></div><blockquote type=3D"cite">Although it doesn't address the case:=
<br><br> &nbsp;scope_guard{...};<br><br>...though I would be somewhat surpr=
ised if that isn't already warned about.<br></blockquote><div><br></div><di=
v>I see nothing there to generate a warning, but it&rsquo;s a non-issue bec=
ause we can assume the factory is the only useful handle.</div><div><br></d=
iv><div>Actually, one avenue I&rsquo;ll explore is an implementation-define=
d guard class. I don&rsquo;t think the user needs to be able to name it at =
all. Boost.ScopeExit hides both the class and the object.</div><div><br></d=
iv><blockquote type=3D"cite">That said...<br><br><blockquote type=3D"cite">=
1. explicit operator void() discard operator prevents discarding the<br>ret=
urn value -- non-breaking core language change, with application<br>to expr=
ession templates.<br></blockquote><br>...this sounds like it would be an in=
teresting addition. (I take it this would make failure to assign such a cla=
ss to a named identifier an error?)<br></blockquote><div><br></div>That des=
cribes the second alternative. Here is a preview of the relevant section:</=
div><div><br></div><div><blockquote type=3D"cite"><p style=3D"margin: 0px 0=
px 16px;"><span style=3D"letter-spacing: 0.0px">Alternative solutions, requ=
iring core language changes, may be explored. Here are two.</span></p><p st=
yle=3D"margin: 0px 0px 8px; font-size: 13px;"><span style=3D"letter-spacing=
: 0.2px">2.1.1. Discarded value operator</span></p><p style=3D"margin: 0px =
0px 6px;"><span style=3D"letter-spacing: 0.0px">As a purely diagnostic meas=
ure, the guard class could be forbidden from forming a discarded value expr=
ession. Another case where trapping discarded values is useful is a matrix =
expression template involving multiple assignment operations. Currently, an=
 expression template must decay at each assignment operation, ignoring some=
 loop interleavings. The relevance here is that such a feature would not be=
 dedicated to guard safety.</span></p><p style=3D"margin: 0px 0px 16px;"><s=
pan style=3D"letter-spacing: 0.0px">The natural discarded value operator is=
 </span><span style=3D"font-family: Courier; letter-spacing: 0px;">operator=
 void()</span><span style=3D"letter-spacing: 0.0px">. An expression-stateme=
nt with type </span><span style=3D"font-family: Courier; letter-spacing: 0p=
x;">T</span><span style=3D"letter-spacing: 0.0px"> could be considered as a=
n implicit conversion from </span><span style=3D"font-family: Courier; lett=
er-spacing: 0px;">T</span><span style=3D"letter-spacing: 0.0px"> to </span>=
<span style=3D"font-family: Courier; letter-spacing: 0px;">void</span><span=
 style=3D"letter-spacing: 0.0px">, therefore a guard class would only need =
to declare </span><span style=3D"font-family: Courier; letter-spacing: 0px;=
">explicit operator void() {}</span><span style=3D"letter-spacing: 0.0px"> =
to give the example an illegal implicit conversion. Explicitly casting a gu=
ard object to </span><span style=3D"font-family: Courier; letter-spacing: 0=
px;">void</span><span style=3D"letter-spacing: 0.0px"> would still be legal=
..</span></p><p style=3D"margin: 0px 0px 8px; font-size: 13px;"><span style=
=3D"letter-spacing: 0.2px">2.1.2. Restriction of class value category</span=
></p><p style=3D"margin: 0px 0px 6px;"><span style=3D"letter-spacing: 0.0px=
">The class could be forbidden from forming a prvalue expression. This woul=
d forbid the guard ever being an anonymous, discarded object. Function retu=
rn values are always of category prvalue though, so the best middle ground =
is to also permit a lifetime-extended temporary.</span></p><p style=3D"marg=
in: 0px 0px 6px;"><span style=3D"letter-spacing: 0.0px">The restriction cou=
ld be expressed by a <i>class-head</i> decorator such as </span><span style=
=3D"font-family: Courier; letter-spacing: 0px;">&amp;</span><span style=3D"=
letter-spacing: 0.0px">. The corresponding </span><span style=3D"font-famil=
y: Courier; letter-spacing: 0px;">&amp;&amp;</span><span style=3D"letter-sp=
acing: 0.0px"> decorator would conversely express that instances cannot be =
named (or lifetime-extended), such as expression template specializations. =
Inheritance of this decorator is a difficult question. One simple solution =
is to make them <i>class-virt-specifiers</i> implying </span><span style=3D=
"font-family: Courier; letter-spacing: 0px;">final</span><span style=3D"let=
ter-spacing: 0.0px">, thus prohibiting derivation.</span></p><p style=3D"ma=
rgin: 0px 0px 6px;"><span style=3D"letter-spacing: 0.0px">This rather elega=
ntly removes the danger, but it does not improve convenience. The ideal sol=
ution would simply fix the bare function call expression to be correct. Suc=
h a </span><span style=3D"font-family: Courier; letter-spacing: 0px;">&amp;=
</span><span style=3D"letter-spacing: 0.0px"> specifier may be sufficiently=
 expressive to allow the language to surmise that a discarded prvalue, rath=
er than being ill-formed, should be interpreted as being bound to an anonym=
ous reference.</span></p></blockquote><br></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_63148564-A320-4EEE-91D7-D6BE52C5B75E--

.


Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Tue, 11 Mar 2014 13:56:46 -0400
Raw View
On 2014-03-11 12:35, David Krauss wrote:
> On 2014-03-11, at 11:45 PM, Matthew Woehlke wrote:
>> ...then what does __attribute__((warn_unused_result)) do?
>
> You seem to presume I know something :v) .

In that case, I will also point you to
http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-value-365,
which looks similar to your 'explicit operator void()' proposal and thus
might serve as a useful implementation precedent.

--
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: David Krauss <potswa@gmail.com>
Date: Wed, 12 Mar 2014 06:59:21 +0800
Raw View
On 2014-03-12, at 1:56 AM, Matthew Woehlke <mw_triad@users.sourceforge.net> wrote:

> On 2014-03-11 12:35, David Krauss wrote:
>> On 2014-03-11, at 11:45 PM, Matthew Woehlke wrote:
>>> ...then what does __attribute__((warn_unused_result)) do?
>>
>> You seem to presume I know something :v) .
>
> In that case, I will also point you to http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-value-365, which looks similar to your 'explicit operator void()' proposal and thus might serve as a useful implementation precedent.

That one, I am aware of. It's different because it can be disabled by a cast to void, and there is no hook. It applies to "values," which according to GCC's heuristic includes POD objects but nothing with a destructor.

Most compilers have one or more features along the right lines, but the requirements to protect against guard abuse are deceptively specific. Implementation difficulty should be very modest in any case.

--

---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: =?UTF-8?Q?R=C3=B3bert_D=C3=A1vid?= <lrdxgm@gmail.com>
Date: Wed, 19 Mar 2014 15:23:56 -0700 (PDT)
Raw View
------=_Part_51_7649802.1395267837430
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

That's.. not too smart - names containing double underscore are reserved to=
=20
the implementation in *all* scopes. Also names starting with single=20
underscore reserved in the global namespace ( 17.6.4.3.2 / [global.names]=
=20
). Thus, V8 code is ill-formed.

I'm not sure if it's a good idea to "downvote" a proposal because it would=
=20
break ill-formed code.. If such code breaks, then suffer in silence, it was=
=20
already broken.

Regards,
Robert

2014. m=C3=A1rcius 7., p=C3=A9ntek 20:49:44 UTC+1 id=C5=91pontban Thiago Ma=
cieira a=20
k=C3=B6vetkez=C5=91t =C3=ADrta:
>
> Em sex 07 mar 2014, =C3=A0s 11:39:59, Jeffrey Yasskin escreveu:=20
> > Although "__" (two underscores) is currently reserved, so it might be=
=20
> ok.=20
>
> That doesn't mean it's unused.=20
>
> V8 (the JS engine from Blink / Chromium) uses it for the assembler:=20
>
>
> https://code.google.com/p/v8/codesearch#v8/trunk/src/codegen.cc&q=3D__&sq=
=3Dpackage:v8&type=3Dcs&l=3D43=20
>
> https://code.google.com/p/v8/codesearch#v8/trunk/src/x64/debug-x64.cc&q=
=3D__&sq=3Dpackage:v8&type=3Dcs&l=3D96=20
>
> Etc.=20
>
> --=20
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org=20
>    Software Architect - Intel Open Source Technology Center=20
>       PGP/GPG: 0x6EF45358; fingerprint:=20
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358=20
>
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_51_7649802.1395267837430
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">That's.. not too smart - names containing double underscor=
e are reserved to the implementation in <b>all</b> scopes. Also names start=
ing with single underscore reserved in the global namespace ( 17.6.4.3.2 / =
[global.names] ). Thus, V8 code is ill-formed.<br><br>I'm not sure if it's =
a good idea to "downvote" a proposal because it would break ill-formed code=
... If such code breaks, then suffer in silence, it was already broken.<br><=
br>Regards,<br>Robert<br><br>2014. m=C3=A1rcius 7., p=C3=A9ntek 20:49:44 UT=
C+1 id=C5=91pontban Thiago Macieira a k=C3=B6vetkez=C5=91t =C3=ADrta:<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;">Em sex 07 mar 2014, =C3=A0s 11:39:59=
, Jeffrey Yasskin escreveu:
<br>&gt; Although "__" (two underscores) is currently reserved, so it might=
 be ok.
<br>
<br>That doesn't mean it's unused.
<br>
<br>V8 (the JS engine from Blink / Chromium) uses it for the assembler:
<br>
<br><a href=3D"https://code.google.com/p/v8/codesearch#v8/trunk/src/codegen=
..cc&amp;q=3D__&amp;sq=3Dpackage:v8&amp;type=3Dcs&amp;l=3D43" target=3D"_bla=
nk" onmousedown=3D"this.href=3D'https://code.google.com/p/v8/codesearch#v8/=
trunk/src/codegen.cc\46q\75__\46sq\75package:v8\46type\75cs\46l\07543';retu=
rn true;" onclick=3D"this.href=3D'https://code.google.com/p/v8/codesearch#v=
8/trunk/src/codegen.cc\46q\75__\46sq\75package:v8\46type\75cs\46l\07543';re=
turn true;">https://code.google.com/p/v8/<wbr>codesearch#v8/trunk/src/<wbr>=
codegen.cc&amp;q=3D__&amp;sq=3Dpackage:v8&amp;<wbr>type=3Dcs&amp;l=3D43</a>
<br><a href=3D"https://code.google.com/p/v8/codesearch#v8/trunk/src/x64/deb=
ug-x64.cc&amp;q=3D__&amp;sq=3Dpackage:v8&amp;type=3Dcs&amp;l=3D96" target=
=3D"_blank" onmousedown=3D"this.href=3D'https://code.google.com/p/v8/codese=
arch#v8/trunk/src/x64/debug-x64.cc\46q\75__\46sq\75package:v8\46type\75cs\4=
6l\7596';return true;" onclick=3D"this.href=3D'https://code.google.com/p/v8=
/codesearch#v8/trunk/src/x64/debug-x64.cc\46q\75__\46sq\75package:v8\46type=
\75cs\46l\7596';return true;">https://code.google.com/p/v8/<wbr>codesearch#=
v8/trunk/src/x64/<wbr>debug-x64.cc&amp;q=3D__&amp;sq=3Dpackage:<wbr>v8&amp;=
type=3Dcs&amp;l=3D96</a>
<br>
<br>Etc.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhq=
Ln_62FW8ag';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNC=
Nanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - thiago (AT) <a href=
=3D"http://kde.org" target=3D"_blank" onmousedown=3D"this.href=3D'http://ww=
w.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQj=
CNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;" onclick=3D"this.href=3D'http:=
//www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75=
AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return true;">kde.org</a>
<br>&nbsp; &nbsp;Software Architect - Intel Open Source Technology Center
<br>&nbsp; &nbsp; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:
<br>&nbsp; &nbsp; &nbsp; E067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_51_7649802.1395267837430--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 19 Mar 2014 15:39:19 -0700
Raw View
Em qua 19 mar 2014, =E0s 15:23:56, R=F3bert D=E1vid escreveu:
> That's.. not too smart - names containing double underscore are reserved =
to
> the implementation in *all* scopes. Also names starting with single
> underscore reserved in the global namespace ( 17.6.4.3.2 / [global.names]
> ). Thus, V8 code is ill-formed.
>=20
> I'm not sure if it's a good idea to "downvote" a proposal because it woul=
d
> break ill-formed code.. If such code breaks, then suffer in silence, it w=
as
> already broken.

Fair enough.

I was just pointing out that certain code usually takes liberties with the=
=20
standard and we should be aware of it when making certain identifiers have=
=20
special meanings or become keywords.

I've also seen many libraries use underscore + capital, such as this extrac=
ted=20
from glib:

typedef struct _GDir GDir;

https://github.com/GNOME/glib/blob/master/glib/gdir.h#L37
--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.