Topic: More syntactic sugar for auto


Author: vadim.petrochenkov@gmail.com
Date: Thu, 22 May 2014 02:49:57 -0700 (PDT)
Raw View
------=_Part_2401_6183912.1400752197838
Content-Type: text/plain; charset=UTF-8

It may be a bit silly feature request, but it is totally inspired by
practice.

While writing code in "almost always auto" style I found, that "const auto"
is an extremely common combination (2 times more frequent than auto without
const). It is pretty much everywhere.
I wonder if there is a way to introduce a short synonym for it, for
example, "cauto" (named by analogy with cbegin/cend)?

I can see the next benefits from the synonym:
1) General convenience of writing and reading code. The difference between
"const auto" and "cauto" is only 5 letters, but it matters, since the
combination is very frequent. (I've tested it by using cauto as a macro.)
2) It helps not to forget const. It is useful, since the feature is
especially aimed to beginners. With it the rule "use const by default" can
be merged into "almost always auto" rule, increasing teachability.
3) More terse syntax for generic lambdas
std::sort(c.begin(), c.end(), [](const auto& lhs, const auto& rhs) { returnlhs
..x < rhs.x; });
->
std::sort(c.begin(), c.end(), [](cauto& lhs, cauto& rhs) { return lhs.x <rhs
..x; });

The main problem is how to implement the synonym:
1)
#define const auto cauto
It is bad, and not only because of an abstract "macros are bad in general",
but because of practical interaction with tools. For example, in Visual
Studio you can "Go To Definition" of the deduced type with keyword auto,
but not with macro cauto.
2) Keyword cauto
The best way, but too much trouble?
3) Context sensitive identifier cauto
I do not know if it possible or not to unambiguously detect the necessary
context. May be you can help?
4) Some new kind of typedef like: typedef const auto cauto
It doesn't look very good in the sense that it contradicts the idea of what
typedef is supposed to do

Personally I think the feature is still worth the trouble, but I don't know
if anyone who is able to write a real proposal share my thought?

--

---
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_2401_6183912.1400752197838
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>It may be a bit silly feature request, but it is tota=
lly inspired by practice.</div><div><br></div><div>While writing code in "a=
lmost always auto" style I found, that "const auto" is an extremely common =
combination (2 times more frequent than auto without const). It is pretty m=
uch everywhere.</div><div>I wonder if there is a way to introduce a short s=
ynonym for it, for example, "cauto" (named by analogy with cbegin/cend)?</d=
iv><div><br></div><div>I can see the next benefits from the synonym:</div><=
div>1) General convenience of writing and reading code. The difference betw=
een "const auto" and "cauto" is only 5 letters, but it matters, since the c=
ombination is very frequent. (I've tested it by using cauto as a macro.)</d=
iv><div>2) It helps not to forget const. It is useful, since the feature is=
 especially aimed to beginners. With it the rule "use const by default" can=
 be merged into "almost always auto" rule, increasing teachability.</div><d=
iv>3) More terse syntax for generic lambdas</div><div><div class=3D"prettyp=
rint" style=3D"background-color: rgb(250, 250, 250); border: 1px solid rgb(=
187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">sort</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">c</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(),</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">.</span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(),=
</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 sty=
le=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> lhs</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
const</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> rhs</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;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">return</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> lhs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">x </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> rhs</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">x</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">});</span></div></code></div></div><div>-&gt;</div><div><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px=
 solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"sty=
led-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=
">sort</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">c</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">begin</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(),</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> c</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">end</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">[](</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">cauto</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> lhs</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> cauto</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> rhs</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> lhs</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">x </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> rhs</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">x</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">});</span></div>=
</code></div></div><div><br></div><div>The main problem is how to implement=
 the synonym:</div><div>1) <div class=3D"prettyprint" style=3D"background-c=
olor: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: =
break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">#define</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">const</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> cauto</span></div></code></div></div><div>It is ba=
d, and not only because of an abstract "macros are bad in general", but bec=
ause of practical interaction with tools. For example, in Visual Studio you=
 can "Go To Definition" of the deduced type with keyword auto, but not with=
 macro cauto.</div><div>2) Keyword cauto</div><div>The best way, but too mu=
ch trouble?</div><div>3) Context sensitive identifier cauto</div><div>I do =
not know if it possible or not to unambiguously detect the necessary contex=
t. May be you can help?</div><div>4) Some new kind of typedef like: typedef=
 const auto cauto</div><div>It doesn't look very good in the sense that it =
contradicts the idea of what typedef is supposed to do</div><div><br></div>=
<div>Personally I think the feature is still worth the trouble, but I don't=
 know if anyone who is able to write a real proposal share my thought?</div=
><div><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_2401_6183912.1400752197838--

.


Author: David Krauss <potswa@gmail.com>
Date: Thu, 22 May 2014 18:17:31 +0800
Raw View
--Apple-Mail=_3B9B87EE-5285-439D-9143-DFCE908194D4
Content-Type: text/plain; charset=ISO-8859-1


On 2014-05-22, at 5:49 PM, vadim.petrochenkov@gmail.com wrote:

> It may be a bit silly feature request, but it is totally inspired by practice.
>
> While writing code in "almost always auto" style I found, that "const auto" is an extremely common combination (2 times more frequent than auto without const). It is pretty much everywhere.

Why not use "universal references" instead, auto &&? I've not encountered much const auto (or auto const).

> std::sort(c.begin(), c.end(), [](const auto& lhs, const auto& rhs) { return lhs.x < rhs.x; });

I've not yet played with polymorphic lambdas. Does auto && not work here?

--

---
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=_3B9B87EE-5285-439D-9143-DFCE908194D4
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;05&ndash;22, at 5:49 PM, <a href=3D"mailto:vadim.petrochenkov@gmail.c=
om">vadim.petrochenkov@gmail.com</a> wrote:</div><br class=3D"Apple-interch=
ange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div>It may be a b=
it silly feature request, but it is totally inspired by practice.</div><div=
><br></div><div>While writing code in "almost always auto" style I found, t=
hat "const auto" is an extremely common combination (2 times more frequent =
than auto without const). It is pretty much everywhere.</div></div></blockq=
uote><div><br></div><div>Why not use &ldquo;universal references&rdquo; ins=
tead, <font face=3D"Courier">auto &amp;&amp;</font>? I&rsquo;ve not encount=
ered much <font face=3D"Courier">const auto</font>&nbsp;(or <font face=3D"C=
ourier">auto const</font>).</div><br><blockquote type=3D"cite"><div dir=3D"=
ltr"><div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 25=
0, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word; posit=
ion: static; z-index: auto;"><code class=3D"prettyprint">std<span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span>sort<span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span>c<span style=3D"color: #660;=
" class=3D"styled-by-prettify">.</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">begin</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(),</span> c<span style=3D"color: #660;" class=3D"styled=
-by-prettify">.</span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">end</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
,</span> <span style=3D"color: #660;" class=3D"styled-by-prettify">[](</spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">const</span> <s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span> lhs<span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span> <span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">const</span> <span style=3D"color:=
 #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&amp;</span> rhs<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: #008;" class=3D"styl=
ed-by-prettify">return</span> lhs<span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">.</span>x <span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&lt;</span> rhs<span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">.</span>x<span style=3D"color: #660;" class=3D"styled-by-prettify">;=
</span> <span style=3D"color: #660;" class=3D"styled-by-prettify">});</span=
></code></div></div></div></blockquote><br></div><div>I&rsquo;ve not yet pl=
ayed with polymorphic lambdas. Does <font face=3D"Courier">auto &amp;&amp;<=
/font> not work here?</div><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 />

--Apple-Mail=_3B9B87EE-5285-439D-9143-DFCE908194D4--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 22 May 2014 13:20:14 +0300
Raw View
On 22 May 2014 13:17, David Krauss <potswa@gmail.com> wrote:
> std::sort(c.begin(), c.end(), [](const auto& lhs, const auto& rhs) { retu=
rn
> lhs.x < rhs.x; });
> I=E2=80=99ve not yet played with polymorphic lambdas. Does auto && not wo=
rk here?


It does. If you need to perfect-forward, you need decltype, but auto&&
itself is supported
and works just fine.

--=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: Thu, 22 May 2014 13:44:30 -0400
Raw View
On 2014-05-22 05:49, vadim.petrochenkov@gmail.com wrote:
> #define const auto cauto
> It is bad, and not only because of an abstract "macros are bad in general",
> but because of practical interaction with tools. For example, in Visual
> Studio you can "Go To Definition" of the deduced type with keyword auto,
> but not with macro cauto.

That's a bug (or deficiency, at least) in the IDE. Somehow I don't see
adding a feature to the standard for this reason as being a good thing.
(Never mind that the IDE would still need to be taught how to parse it,
so you haven't really gained anything.)

--
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: vadim.petrochenkov@gmail.com
Date: Thu, 22 May 2014 11:53:13 -0700 (PDT)
Raw View
------=_Part_598_23416596.1400784793068
Content-Type: text/plain; charset=UTF-8

>>That's a bug (or deficiency, at least) in the IDE
No, no, IDE just rightfully goes to definition of the macro and not deduced
type :) But that is not the point.

What I want is
1) to find out if there is a common need in this particular shortcut or
some more general instrument allowing to achieve the same syntax (because I
personally find it convenient and very widely applicable).
2) to get an answer to the question "Is such a shortcut can be introduced
with a context sensitive identifier?"

P.S. My posts got constantly deleted for some reason (including my answer
to David Krauss).

On Thursday, May 22, 2014 9:44:30 PM UTC+4, Matthew Woehlke wrote:
>
> On 2014-05-22 05:49, vadim.pet...@gmail.com <javascript:> wrote:
> > #define const auto cauto
> > It is bad, and not only because of an abstract "macros are bad in
> general",
> > but because of practical interaction with tools. For example, in Visual
> > Studio you can "Go To Definition" of the deduced type with keyword auto,
> > but not with macro cauto.
>
> That's a bug (or deficiency, at least) in the IDE. Somehow I don't see
> adding a feature to the standard for this reason as being a good thing.
> (Never mind that the IDE would still need to be taught how to parse it,
> so you haven't really gained anything.)
>
> --
> 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/.

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

<div dir=3D"ltr"><div>&gt;&gt;That's a bug (or deficiency, at least) in the=
 IDE<br>No, no, IDE just rightfully goes to definition of the macro and not=
 deduced type :) But that is not the point.</div><div><br></div><div>What I=
 want is</div><div>1) to find out if there is a common need in this particu=
lar shortcut or some more general instrument allowing to achieve the same s=
yntax (because I personally find it convenient and very widely applicable).=
</div><div>2) to get an answer to the question "Is such a shortcut can be i=
ntroduced with a context sensitive identifier?"</div><div><br></div><div>P.=
S. My posts&nbsp;got constantly deleted for some reason (including my answe=
r to David Krauss).<br></div><br>On Thursday, May 22, 2014 9:44:30 PM UTC+4=
, Matthew Woehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: =
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 201=
4-05-22 05:49, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mai=
lto=3D"ybFmncBZpBoJ" onmousedown=3D"this.href=3D'javascript:';return true;"=
 onclick=3D"this.href=3D'javascript:';return true;">vadim.pet...@gmail.com<=
/a> wrote:
<br>&gt; #define const auto cauto
<br>&gt; It is bad, and not only because of an abstract "macros are bad in =
general",=20
<br>&gt; but because of practical interaction with tools. For example, in V=
isual=20
<br>&gt; Studio you can "Go To Definition" of the deduced type with keyword=
 auto,=20
<br>&gt; but not with macro cauto.
<br>
<br>That's a bug (or deficiency, at least) in the IDE. Somehow I don't see
<br>adding a feature to the standard for this reason as being a good thing.
<br>(Never mind that the IDE would still need to be taught how to parse it,
<br>so you haven't really gained anything.)
<br>
<br>--=20
<br>Matthew
<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_598_23416596.1400784793068--

.


Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Thu, 22 May 2014 15:05:44 -0400
Raw View
--001a11c3cdeec46b4e04fa01cc5d
Content-Type: text/plain; charset=UTF-8

I am not sure I buy into the rationale. From a pedagogical perspective,
hiding the 'const' is not helping the beginners into a should use "const"
everywhere situation, but rather buy into dark magic: use cauto if that
fails to compile use auto. Reasoning about might be surprising for
beginners, consider for example this perfectly valid code:

[](cauto x) { ++x; }(1);   // [](const auto x) { ++x; }(1)

Note that the issue here is that you don't really want 'const auto', but
'const auto&' to be the default. Not pushing the reference into cauto
allows for the above, pushing the reference into it would hide an important
bit of information from the interface that would look like a value when it
is a reference.

If to be able to reason about what the code does the programmer needs to
mentally expand 'cauto' into 'const auto' then there is no advantage other
than less typing, and a possible loss of clarity.

All that being said, I am still stuck in C++03, so take this at face value
:)

    David


On Thu, May 22, 2014 at 2:53 PM, <vadim.petrochenkov@gmail.com> wrote:

> >>That's a bug (or deficiency, at least) in the IDE
> No, no, IDE just rightfully goes to definition of the macro and not
> deduced type :) But that is not the point.
>
> What I want is
> 1) to find out if there is a common need in this particular shortcut or
> some more general instrument allowing to achieve the same syntax (because I
> personally find it convenient and very widely applicable).
> 2) to get an answer to the question "Is such a shortcut can be introduced
> with a context sensitive identifier?"
>
> P.S. My posts got constantly deleted for some reason (including my answer
> to David Krauss).
>
> On Thursday, May 22, 2014 9:44:30 PM UTC+4, Matthew Woehlke wrote:
>
>> On 2014-05-22 05:49, vadim.pet...@gmail.com wrote:
>> > #define const auto cauto
>> > It is bad, and not only because of an abstract "macros are bad in
>> general",
>> > but because of practical interaction with tools. For example, in Visual
>> > Studio you can "Go To Definition" of the deduced type with keyword
>> auto,
>> > but not with macro cauto.
>>
>> That's a bug (or deficiency, at least) in the IDE. Somehow I don't see
>> adding a feature to the standard for this reason as being a good thing.
>> (Never mind that the IDE would still need to be taught how to parse it,
>> so you haven't really gained anything.)
>>
>> --
>> 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/.

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

<div dir=3D"ltr">I am not sure I buy into the rationale. From a pedagogical=
 perspective, hiding the &#39;const&#39; is not helping the beginners into =
a should use &quot;const&quot; everywhere situation, but rather buy into da=
rk magic: use cauto if that fails to compile use auto. Reasoning about migh=
t be surprising for beginners, consider for example this perfectly valid co=
de:<br>
<br>[](cauto x) { ++x; }(1); =C2=A0 // [](const auto x) { ++x; }(1)<br><br>=
Note that the issue here is that you don&#39;t really want &#39;const auto&=
#39;, but &#39;const auto&amp;&#39; to be the default. Not pushing the refe=
rence into cauto allows for the above, pushing the reference into it would =
hide an important bit of information from the interface that would look lik=
e a value when it is a reference.<br>
<br>If to be able to reason about what the code does the programmer needs t=
o mentally expand &#39;cauto&#39; into &#39;const auto&#39; then there is n=
o advantage other than less typing, and a possible loss of clarity.<br>
<br>All that being said, I am still stuck in C++03, so take this at face va=
lue :)<br><br>=C2=A0 =C2=A0 David</div><div class=3D"gmail_extra"><br><br><=
div class=3D"gmail_quote">On Thu, May 22, 2014 at 2:53 PM,  <span dir=3D"lt=
r">&lt;<a href=3D"mailto:vadim.petrochenkov@gmail.com" target=3D"_blank">va=
dim.petrochenkov@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"">&gt;&g=
t;That&#39;s a bug (or deficiency, at least) in the IDE<br></div>No, no, ID=
E just rightfully goes to definition of the macro and not deduced type :) B=
ut that is not the point.</div>
<div><br></div><div>What I want is</div><div>1) to find out if there is a c=
ommon need in this particular shortcut or some more general instrument allo=
wing to achieve the same syntax (because I personally find it convenient an=
d very widely applicable).</div>
<div>2) to get an answer to the question &quot;Is such a shortcut can be in=
troduced with a context sensitive identifier?&quot;</div><div><br></div><di=
v>P.S. My posts=C2=A0got constantly deleted for some reason (including my a=
nswer to David Krauss).<br>
</div><br>On Thursday, May 22, 2014 9:44:30 PM UTC+4, Matthew Woehlke wrote=
:<div><div class=3D"h5"><blockquote class=3D"gmail_quote" style=3D"margin:0=
;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">On 2014-05-=
22 05:49, <a>vadim.pet...@gmail.com</a> wrote:
<br>&gt; #define const auto cauto
<br>&gt; It is bad, and not only because of an abstract &quot;macros are ba=
d in general&quot;,=20
<br>&gt; but because of practical interaction with tools. For example, in V=
isual=20
<br>&gt; Studio you can &quot;Go To Definition&quot; of the deduced type wi=
th keyword auto,=20
<br>&gt; but not with macro cauto.
<br>
<br>That&#39;s a bug (or deficiency, at least) in the IDE. Somehow I don&#3=
9;t see
<br>adding a feature to the standard for this reason as being a good thing.
<br>(Never mind that the IDE would still need to be taught how to parse it,
<br>so you haven&#39;t really gained anything.)
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote></div></div></div><div class=3D"HOEnZb"><div class=3D"h5">

<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
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 />

--001a11c3cdeec46b4e04fa01cc5d--

.


Author: Jonathan Coe <jonathanbcoe@gmail.com>
Date: Thu, 22 May 2014 20:18:22 +0100
Raw View
--Apple-Mail-9109AD02-4A9B-4329-A602-CCC50B839B47
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Many tools would let you type "cauto" and replace it with const "auto".

I'm not sure what one would gain from "cauto" other than faster typing, whi=
ch can be addressed by in-tool aliases or some such.

Regards,

Jonathan

> On 22 May 2014, at 20:05, David Rodr=C3=ADguez Ibeas <dibeas@ieee.org> wr=
ote:
>=20
> I am not sure I buy into the rationale. From a pedagogical perspective, h=
iding the 'const' is not helping the beginners into a should use "const" ev=
erywhere situation, but rather buy into dark magic: use cauto if that fails=
 to compile use auto. Reasoning about might be surprising for beginners, co=
nsider for example this perfectly valid code:
>=20
> [](cauto x) { ++x; }(1);   // [](const auto x) { ++x; }(1)
>=20
> Note that the issue here is that you don't really want 'const auto', but =
'const auto&' to be the default. Not pushing the reference into cauto allow=
s for the above, pushing the reference into it would hide an important bit =
of information from the interface that would look like a value when it is a=
 reference.
>=20
> If to be able to reason about what the code does the programmer needs to =
mentally expand 'cauto' into 'const auto' then there is no advantage other =
than less typing, and a possible loss of clarity.
>=20
> All that being said, I am still stuck in C++03, so take this at face valu=
e :)
>=20
>     David
>=20
>=20
>> On Thu, May 22, 2014 at 2:53 PM,  <vadim.petrochenkov@gmail.com> wrote:
>> >>That's a bug (or deficiency, at least) in the IDE
>> No, no, IDE just rightfully goes to definition of the macro and not dedu=
ced type :) But that is not the point.
>>=20
>> What I want is
>> 1) to find out if there is a common need in this particular shortcut or =
some more general instrument allowing to achieve the same syntax (because I=
 personally find it convenient and very widely applicable).
>> 2) to get an answer to the question "Is such a shortcut can be introduce=
d with a context sensitive identifier?"
>>=20
>> P.S. My posts got constantly deleted for some reason (including my answe=
r to David Krauss).
>>=20
>>> On Thursday, May 22, 2014 9:44:30 PM UTC+4, Matthew Woehlke wrote:
>>> On 2014-05-22 05:49, vadim.pet...@gmail.com wrote:=20
>>> > #define const auto cauto=20
>>> > It is bad, and not only because of an abstract "macros are bad in gen=
eral",=20
>>> > but because of practical interaction with tools. For example, in Visu=
al=20
>>> > Studio you can "Go To Definition" of the deduced type with keyword au=
to,=20
>>> > but not with macro cauto.=20
>>>=20
>>> That's a bug (or deficiency, at least) in the IDE. Somehow I don't see=
=20
>>> adding a feature to the standard for this reason as being a good thing.=
=20
>>> (Never mind that the IDE would still need to be taught how to parse it,=
=20
>>> so you haven't really gained anything.)=20
>>>=20
>>> --=20
>>> Matthew
>>=20
>> --=20
>>=20
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n email to std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-prop=
osals/.
>=20
> --=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=
 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-propo=
sals/.

--=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-9109AD02-4A9B-4329-A602-CCC50B839B47
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div>Many tools would let you type "cau=
to" and replace it with const "auto".</div><div><br></div><div>I'm not sure=
 what one would gain from "cauto" other than faster typing, which can be ad=
dressed by in-tool aliases or some such.</div><div><br></div><div>Regards,<=
/div><div><br></div><div>Jonathan</div><div><br>On 22 May 2014, at 20:05, D=
avid Rodr=C3=ADguez Ibeas &lt;<a href=3D"mailto:dibeas@ieee.org">dibeas@iee=
e.org</a>&gt; wrote:<br><br></div><blockquote type=3D"cite"><div><div dir=
=3D"ltr">I am not sure I buy into the rationale. From a pedagogical perspec=
tive, hiding the 'const' is not helping the beginners into a should use "co=
nst" everywhere situation, but rather buy into dark magic: use cauto if tha=
t fails to compile use auto. Reasoning about might be surprising for beginn=
ers, consider for example this perfectly valid code:<br>
<br>[](cauto x) { ++x; }(1); &nbsp; // [](const auto x) { ++x; }(1)<br><br>=
Note that the issue here is that you don't really want 'const auto', but 'c=
onst auto&amp;' to be the default. Not pushing the reference into cauto all=
ows for the above, pushing the reference into it would hide an important bi=
t of information from the interface that would look like a value when it is=
 a reference.<br>
<br>If to be able to reason about what the code does the programmer needs t=
o mentally expand 'cauto' into 'const auto' then there is no advantage othe=
r than less typing, and a possible loss of clarity.<br>
<br>All that being said, I am still stuck in C++03, so take this at face va=
lue :)<br><br>&nbsp; &nbsp; David</div><div class=3D"gmail_extra"><br><br><=
div class=3D"gmail_quote">On Thu, May 22, 2014 at 2:53 PM,  <span dir=3D"lt=
r">&lt;<a href=3D"mailto:vadim.petrochenkov@gmail.com" target=3D"_blank">va=
dim.petrochenkov@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"">&gt;&g=
t;That's a bug (or deficiency, at least) in the IDE<br></div>No, no, IDE ju=
st rightfully goes to definition of the macro and not deduced type :) But t=
hat is not the point.</div>
<div><br></div><div>What I want is</div><div>1) to find out if there is a c=
ommon need in this particular shortcut or some more general instrument allo=
wing to achieve the same syntax (because I personally find it convenient an=
d very widely applicable).</div>
<div>2) to get an answer to the question "Is such a shortcut can be introdu=
ced with a context sensitive identifier?"</div><div><br></div><div>P.S. My =
posts&nbsp;got constantly deleted for some reason (including my answer to D=
avid Krauss).<br>
</div><br>On Thursday, May 22, 2014 9:44:30 PM UTC+4, Matthew Woehlke wrote=
:<div><div class=3D"h5"><blockquote class=3D"gmail_quote" style=3D"margin:0=
;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">On 2014-05-=
22 05:49, <a>vadim.pet...@gmail.com</a> wrote:
<br>&gt; #define const auto cauto
<br>&gt; It is bad, and not only because of an abstract "macros are bad in =
general",=20
<br>&gt; but because of practical interaction with tools. For example, in V=
isual=20
<br>&gt; Studio you can "Go To Definition" of the deduced type with keyword=
 auto,=20
<br>&gt; but not with macro cauto.
<br>
<br>That's a bug (or deficiency, at least) in the IDE. Somehow I don't see
<br>adding a feature to the standard for this reason as being a good thing.
<br>(Never mind that the IDE would still need to be taught how to parse it,
<br>so you haven't really gained anything.)
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote></div></div></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
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 "=
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>
</div></blockquote></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-9109AD02-4A9B-4329-A602-CCC50B839B47--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Thu, 22 May 2014 23:40:11 +0300
Raw View
On 22 May 2014 21:53,  <vadim.petrochenkov@gmail.com> wrote:
>>>That's a bug (or deficiency, at least) in the IDE
> No, no, IDE just rightfully goes to definition of the macro and not deduced
> type :) But that is not the point.

Well, if you choose to use a macro instead of writing a small handful
of characters,
meh.

> What I want is
> 1) to find out if there is a common need in this particular shortcut or some
> more general instrument allowing to achieve the same syntax (because I
> personally find it convenient and very widely applicable).

I don't think its alleged benefit justifies its cost.

> 2) to get an answer to the question "Is such a shortcut can be introduced
> with a context sensitive identifier?"

Let's not do it.

--

---
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: Faisal Vali <faisalv@gmail.com>
Date: Thu, 22 May 2014 16:42:17 -0500
Raw View
On Thu, May 22, 2014 at 3:40 PM, Ville Voutilainen
<ville.voutilainen@gmail.com> wrote:
> On 22 May 2014 21:53,  <vadim.petrochenkov@gmail.com> wrote:
>>>>That's a bug (or deficiency, at least) in the IDE
>> No, no, IDE just rightfully goes to definition of the macro and not deduced
>> type :) But that is not the point.
>
> Well, if you choose to use a macro instead of writing a small handful
> of characters,
> meh.
>
>> What I want is
>> 1) to find out if there is a common need in this particular shortcut or some
>> more general instrument allowing to achieve the same syntax (because I
>> personally find it convenient and very widely applicable).
>
> I don't think its alleged benefit justifies its cost.
>
>> 2) to get an answer to the question "Is such a shortcut can be introduced
>> with a context sensitive identifier?"
>
> Let's not do it.

As it is, as far as readability is concerned, I find myself being
(perhaps overly) careful in my use of auto - unless it's lexically or
semantically quite clear what my initializer represents (with minimal
context).

So FWIW, I agree with Ville  - let's please not do this.

--

---
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: vadim.petrochenkov@gmail.com
Date: Fri, 23 May 2014 01:08:42 -0700 (PDT)
Raw View
------=_Part_56_22055683.1400832522321
Content-Type: text/plain; charset=UTF-8

Thanks for all the responses, especially constructive ones :)
It is always useful to look at the problem from someone else's perspective

--

---
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_56_22055683.1400832522321
Content-Type: text/html; charset=UTF-8

<div dir="ltr">Thanks for all the responses, especially constructive ones :)<div>It is always useful to look at the problem from someone else's perspective</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 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_56_22055683.1400832522321--

.