Topic: [c++std-core-27204] An implementation of


Author: Herb Sutter <hsutter@microsoft.com>
Date: Fri, 6 Mar 2015 00:24:06 +0000
Raw View
--_000_BLUPR03MB455C81E71E81F839F9326C9B81C0BLUPR03MB455namprd_
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

To paraphrase Stroustrup, it=E2=80=99s not about functional programming and=
 object-oriented programming and generic programming=E2=80=A6 =E2=80=9Cit=
=E2=80=99s all just programming.=E2=80=9D

> Templates are a fundamentally different kind of construct

Why? Every full specialization of a function template is just a function.

> My issue is with, well, any syntax that declares a template without havin=
g to type either the word "template" or the use of "<>" brackets.

That ship has sailed:

                auto plus =3D [](auto x, auto y) { return x+y; }

which even already decays to an ordinary pointer to function, etc.

Clarifying Q: Are we mainly arguing about whether to require the three char=
acters =3D, [, and ] ?

Not only has the ship sailed, but I for one like the direction it=E2=80=99s=
 sailing. I see no reason why functions should be forced to spell =E2=80=9C=
template=E2=80=9D and =E2=80=9C<>=E2=80=9D. What value does it add? It=E2=
=80=99s =E2=80=9Cjust programming.=E2=80=9D In fact, if we didn=E2=80=99t h=
ave backward compatibility issues with unnamed parameters and such, I=E2=80=
=99d personally probably be fine with just =E2=80=9Cauto plus(x,y){x+y}=E2=
=80=9D as an equivalent function definition. That still doesn=E2=80=99t los=
e any information.

Gratuitous syntax is often unnecessary and usually harmful. Saying

                template<class T, class U>
                auto(T x, U y) -> decltype(x+y) { return x+y; }

does not appear to me to contain any more information than

                auto plus(auto x, auto y) { return x+y; }

does it? Requiring the verbose syntax is gratuitous, if the verbose syntax =
does not add information, does not serve to disambiguate anything, and does=
 not highlight a dangerous operation or anything else I can see that deserv=
es to have attention called to it.

There=E2=80=99s a disturbing (to me and at least some others) trend in C++ =
these days: People seem to be very prone to wanting =E2=80=9Cmore syntax=E2=
=80=9D lately. It=E2=80=99s rather Vasa-like, if only lexically. Let me cha=
nnel certain influential committee members and say: =E2=80=98People these d=
ays are always asking for more syntax! There=E2=80=99s no proposal they=E2=
=80=99ve seen that they couldn=E2=80=99t make uglier with more syntax!=E2=
=80=99

Important note: The point here is NOT terseness for terseness=E2=80=99 sake=
.. I am not arguing that terser is somehow better, that terseness is virtuou=
s in itself. Too many people glorify languages because they=E2=80=99re ters=
er; fewer characters alone doesn=E2=80=99t make code clearer. Rather, my po=
int is to avoid gratuitous verbosity. At the other end of the pendulum, too=
 many people glorify verbose syntax because they think _that_ is somehow in=
herently clearer; usually it isn=E2=80=99t. So I am arguing that neither is=
 verbosity virtuous in itself.

Herb


From: Nicol Bolas [mailto:jmckesson@gmail.com]
Sent: Thursday, March 5, 2015 3:19 PM
To: std-discussion@isocpp.org
Cc: std-proposals@isocpp.org; c++std-core@accu.org; faisalv@gmail.com
Subject: [c++std-core-27204] Re: An implementation of enhanced auto deducti=
on and abbreviated template syntax using Clang

I... just... ugh.

I'm fine with type deduction patterns like std::vector<auto> =3D ...; That'=
s just a generalization of type deduction in static contexts.

My issue is with, well, any syntax that declares a template without having =
to type either the word "template" or the use of "<>" brackets. Templates a=
re a fundamentally different kind of construct, and we have specific syntax=
 for doing so. By removing that syntax, it becomes way too easy to not noti=
ce that you've declared a template.

The last thing we should want is for people to accidentally make something =
a template.

I accept this with lambdas, because the main point of lambdas is that they'=
re a short-cut. Furthermore, they have a syntax that's fundamentally differ=
ent from regular functions. But for a regular function? No.

Basically, if I see this:

X func_name(...);

I expect that &func_name ought to return a pointer. For it to do something =
else, like being a compiler error, would be surprising.

--=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/.

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

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
 {font-family:"Cambria Math";
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin:0in;
 margin-bottom:.0001pt;
 font-size:12.0pt;
 font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
 {mso-style-priority:99;
 color:#0563C1;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {mso-style-priority:99;
 color:#954F72;
 text-decoration:underline;}
span.EmailStyle17
 {mso-style-type:personal-reply;
 font-family:"Calibri",sans-serif;
 color:#1F497D;}
..MsoChpDefault
 {mso-style-type:export-only;
 font-family:"Calibri",sans-serif;}
@page WordSection1
 {size:8.5in 11.0in;
 margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
 {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">To paraphrase Stroustrup, it=E2=80=99=
s not about functional programming and object-oriented programming and gene=
ric programming=E2=80=A6 =E2=80=9Cit=E2=80=99s all
<i>just programming</i>.=E2=80=9D<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&gt;
</span>Templates are a fundamentally different kind of construct<span style=
=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1F49=
7D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Why? Every full specialization of a f=
unction template is just a function.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&gt;
</span>My issue is with, well, any syntax that declares a template without =
having to type either the word &quot;template&quot; or the use of &quot;&lt=
;&gt;&quot; brackets.<span style=3D"font-size:11.0pt;font-family:&quot;Cali=
bri&quot;,sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">That ship has sailed:<o:p></o:p></spa=
n></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto plus =3D [](auto=
 x, auto y) { return x&#43;y; }<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">which even already decays to an ordin=
ary pointer to function, etc.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Clarifying Q: Are we mainly arguing a=
bout whether to require the three characters =3D, [, and ] ?<o:p></o:p></sp=
an></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Not only has the ship sailed, but I f=
or one like the direction it=E2=80=99s sailing. I see no reason why functio=
ns should be forced to spell =E2=80=9Ctemplate=E2=80=9D and =E2=80=9C&lt;&g=
t;=E2=80=9D. What
 value does it add? It=E2=80=99s =E2=80=9Cjust programming.=E2=80=9D In fac=
t, if we didn=E2=80=99t have backward compatibility issues with unnamed par=
ameters and such, I=E2=80=99d personally probably be fine with just =E2=80=
=9Cauto plus(x,y){x&#43;y}=E2=80=9D as an equivalent function definition. T=
hat still doesn=E2=80=99t
 lose any information.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Gratuitous syntax is often unnecessar=
y and usually harmful. Saying<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; template&lt;class T, =
class U&gt;<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto(T x, U y) -&gt; =
decltype(x&#43;y) { return x&#43;y; }<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">does not appear to me to contain any =
more information than<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto plus(auto x, aut=
o y) { return x&#43;y; }<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">does it? Requiring the verbose syntax=
 is gratuitous, if the verbose syntax does not add information, does not se=
rve to disambiguate anything, and does not highlight
 a dangerous operation or anything else I can see that deserves to have att=
ention called to it.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">There=E2=80=99s a disturbing (to me a=
nd at least some others) trend in C&#43;&#43; these days: People seem to be=
 very prone to wanting =E2=80=9Cmore syntax=E2=80=9D lately. It=E2=80=99s r=
ather Vasa-like,
 if only lexically. Let me channel certain influential committee members an=
d say: =E2=80=98People these days are always asking for more syntax! There=
=E2=80=99s no proposal they=E2=80=99ve seen that they couldn=E2=80=99t make=
 uglier with more syntax!=E2=80=99<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Important note: The point here is NOT=
 terseness for terseness=E2=80=99 sake. I am not arguing that terser is som=
ehow better, that terseness is virtuous in itself. Too
 many people glorify languages because they=E2=80=99re terser; fewer charac=
ters alone doesn=E2=80=99t make code clearer. Rather, my point is to avoid =
gratuitous verbosity. At the other end of the pendulum, too many people glo=
rify verbose syntax because they think _that_ is
 somehow inherently clearer; usually it isn=E2=80=99t. So I am arguing that=
 neither is verbosity virtuous in itself.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Herb<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div style=3D"border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in =
4.0pt">
<div>
<div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in =
0in 0in">
<p class=3D"MsoNormal"><b><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,sans-serif">From:</span></b><span style=3D"font-size:11.0pt;=
font-family:&quot;Calibri&quot;,sans-serif"> Nicol Bolas [mailto:jmckesson@=
gmail.com]
<br>
<b>Sent:</b> Thursday, March 5, 2015 3:19 PM<br>
<b>To:</b> std-discussion@isocpp.org<br>
<b>Cc:</b> std-proposals@isocpp.org; c&#43;&#43;std-core@accu.org; faisalv@=
gmail.com<br>
<b>Subject:</b> [c&#43;&#43;std-core-27204] Re: An implementation of enhanc=
ed auto deduction and abbreviated template syntax using Clang<o:p></o:p></s=
pan></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class=3D"MsoNormal">I... just... ugh.<br>
<br>
I'm fine with type deduction patterns like std::vector&lt;auto&gt; =3D ...;=
 That's just a generalization of type deduction in static contexts.<br>
<br>
My issue is with, well, any syntax that declares a template without having =
to type either the word &quot;template&quot; or the use of &quot;&lt;&gt;&q=
uot; brackets. Templates are a fundamentally different kind of construct, a=
nd we have specific syntax for doing so. By removing that
 syntax, it becomes way too easy to not notice that you've declared a templ=
ate.<br>
<br>
The last thing we should want is for people to accidentally make something =
a template.<br>
<br>
I accept this with lambdas, because the main point of lambdas is that they'=
re a short-cut. Furthermore, they have a syntax that's fundamentally differ=
ent from regular functions. But for a regular function? No.<br>
<br>
Basically, if I see this:<br>
<br>
X func_name(...);<br>
<br>
I expect that &amp;func_name ought to return a pointer. For it to do someth=
ing else, like being a compiler error, would be surprising.<o:p></o:p></p>
</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 />

--_000_BLUPR03MB455C81E71E81F839F9326C9B81C0BLUPR03MB455namprd_--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 6 Mar 2015 09:21:16 -0800 (PST)
Raw View
------=_Part_956_930836835.1425662476578
Content-Type: multipart/alternative;
 boundary="----=_Part_957_156317450.1425662476578"

------=_Part_957_156317450.1425662476578
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Thursday, March 5, 2015 at 7:24:32 PM UTC-5, Herb Sutter wrote:
>
>  To paraphrase Stroustrup, it=E2=80=99s not about functional programming =
and=20
> object-oriented programming and generic programming=E2=80=A6 =E2=80=9Cit=
=E2=80=99s all *just=20
> programming*.=E2=80=9D
>
> =20
>
> > Templates are a fundamentally different kind of construct
>
> =20
>
> Why? Every full specialization of a function template is just a function.
>
>
OK, let's explore this.

Let's say that I'm a novice C++ programmer. I don't really know much about=
=20
the language. But I have some basic knowledge.

Now, I've been told that when I write functions, I put a prototype in a=20
header file so that other people can use it. But I also put the=20
implementation in a source file, so that it stays hidden. So I write:

//header
RetType func_name(Type1 arg1, ...);

//source
RetType func_name(Type1 arg1, ...)
{
//implementation
}


OK, fine.

I've also been told about a different class of functions: template=20
functions. For reasons I haven't been told and don't much care about (since=
=20
I'm a novice), I have to put the implementation in the header file. So I=20
know that if I type the word "template", then that function's=20
implementation has to go into a header. So I always do this:

//header
template<typename T>
RetType func_name_template(T arg1, ...)
{
//implementation
}

//source doesn't exist.

=20
OK, fine. So... explain to me, the novice C++ programmer, why this doesn't=
=20
work:

//header
RetType func_name_concept(ConceptName arg1, ...);

//source
RetType func_name_concept(ConceptName arg1, ...)
{
//implementation
}

Explain to me, the novice C++ programmer, why this thing which doesn't look=
=20
like a template suddenly *became* a template. Explain to me why I have to=
=20
implement it in a header, even though it looks exactly like every other=20
non-template function declaration/definition.

To the novice C++ programmer, it *isn't* "all just programming." Whether=20
something is a template *matters*.

Oh, you could say, "well just put *everything* in a header." That's...=20
insane. Compile times for C++ projects of significant size are already huge=
=20
even when you try to only put what you need in headers. Adding the burden=
=20
of shoving everything in a header is crazy.

Now, if you can promise me that the same version of C++ that will include=
=20
this terse syntax will also include *modules*, I will immediately stop=20
caring. Once that exists, then most of the differences between template and=
=20
non-template functions will be erased. And therefore, so too can the=20
syntactic differences.

But so long as there is a difference in how you implement template and=20
non-template functions, I say that there should be an obvious difference in=
=20
syntax too.

=20
>
> > My issue is with, well, any syntax that declares a template without=20
> having to type either the word "template" or the use of "<>" brackets.
>
> =20
>
> That ship has sailed:
>
> =20
>
>                 auto plus =3D [](auto x, auto y) { return x+y; }
>
> =20
>
> which even already decays to an ordinary pointer to function, etc.
>

That doesn't decay into a function pointer. It can't; the operator() is a=
=20
template.
=20

> =20
>
> Clarifying Q: Are we mainly arguing about whether to require the three=20
> characters =3D, [, and ] ?
>
Except that there is a difference between creating a lambda (which creates=
=20
a functor) and creating a function (which can be overloaded).

=20
>
> Not only has the ship sailed, but I for one like the direction it=E2=80=
=99s=20
> sailing. I see no reason why functions should be forced to spell =E2=80=
=9Ctemplate=E2=80=9D=20
> and =E2=80=9C<>=E2=80=9D. What value does it add? It=E2=80=99s =E2=80=9Cj=
ust programming.=E2=80=9D In fact, if we=20
> didn=E2=80=99t have backward compatibility issues with unnamed parameters=
 and such,=20
> I=E2=80=99d personally probably be fine with just =E2=80=9Cauto plus(x,y)=
{x+y}=E2=80=9D as an=20
> equivalent function definition. That still doesn=E2=80=99t lose any infor=
mation.
>
> =20
>
> Gratuitous syntax is often unnecessary and usually harmful. Saying
>
> =20
>
>                 template<class T, class U>
>
>                 auto(T x, U y) -> decltype(x+y) { return x+y; }
>
> =20
>
> does not appear to me to contain any more information than
>
> =20
>
>                 auto plus(auto x, auto y) { return x+y; }
>
> =20
>
> does it?
>
If you take out the late specified return type (I specifically said that=20
static deduction was fine), then I don't see the problem with the first one=
..

=20

> Requiring the verbose syntax is gratuitous, if the verbose syntax does no=
t=20
> add information, does not serve to disambiguate anything, and does not=20
> highlight a dangerous operation or anything else I can see that deserves =
to=20
> have attention called to it.
>
> =20
>
> There=E2=80=99s a disturbing (to me and at least some others) trend in C+=
+ these=20
> days: People seem to be very prone to wanting =E2=80=9Cmore syntax=E2=80=
=9D lately. It=E2=80=99s=20
> rather Vasa-like, if only lexically. Let me channel certain influential=
=20
> committee members and say: =E2=80=98People these days are always asking f=
or more=20
> syntax! There=E2=80=99s no proposal they=E2=80=99ve seen that they couldn=
=E2=80=99t make uglier=20
> with more syntax!=E2=80=99
>
> =20
>
> Important note: The point here is NOT terseness for terseness=E2=80=99 sa=
ke. I am=20
> not arguing that terser is somehow better, that terseness is virtuous in=
=20
> itself. Too many people glorify languages because they=E2=80=99re terser;=
 fewer=20
> characters alone doesn=E2=80=99t make code clearer. Rather, my point is t=
o avoid=20
> gratuitous verbosity. At the other end of the pendulum, too many people=
=20
> glorify verbose syntax because they think _that_ is somehow inherently=20
> clearer; usually it isn=E2=80=99t. So I am arguing that neither is verbos=
ity=20
> virtuous in itself.
>
> =20
>
> Herb
>
The virtue to me of the large syntax of templates is this:

Templates have to be treated differently from non-templates. They have=20
different needs of where their implementations live. And because of those=
=20
needs, templates make your code compile slower. Even ignoring the=20
compile-time cost of template instantiation, your source has to go in the=
=20
header. And if that header is included in more than one place, then the=20
source for that template must be recompiled for every place it is included.

Therefore, the bulky template syntax pokes you in the eye every time you=20
write something that's going to compile slower. It immediately lets you=20
know that this function operates under fundamentally different rules than=
=20
regular functions.

Again, if you could guarantee that we get modules alongside this syntax,=20
I'd be fine, since using templates will not hurt your compile times nearly=
=20
as much.

--=20

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

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

<div dir=3D"ltr">On Thursday, March 5, 2015 at 7:24:32 PM UTC-5, Herb Sutte=
r wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;">





<div link=3D"#0563C1" vlink=3D"#954F72" lang=3D"EN-US">
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">To paraphrase Stroustrup, it=E2=80=99=
s not about functional programming and object-oriented programming and gene=
ric programming=E2=80=A6 =E2=80=9Cit=E2=80=99s all
<i>just programming</i>.=E2=80=9D</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&gt;
</span>Templates are a fundamentally different kind of construct<span style=
=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif;color:#1f49=
7d"></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">Why? Every full specialization of a f=
unction template is just a function.</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d"></span></p></div></div></blockquote><=
div><br>OK, let's explore this.<br><br>Let's say that I'm a novice C++ prog=
rammer. I don't really know much about the language. But I have some basic =
knowledge.<br><br>Now, I've been told that when I write functions, I put a =
prototype in a header file so that other people can use it. But I also put =
the implementation in a source file, so that it stays hidden. So I write:<b=
r><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 2=
50); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1=
px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpr=
ettyprint"><span style=3D"color: #800;" class=3D"styled-by-prettify">//head=
er</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">RetType</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> func_name</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Type1</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> arg1</span><span style=3D"colo=
r: #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"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">//source</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">RetType</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> func_name</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Type1<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> arg1</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">...)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">//implementation</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br></span></div></code></div><br><br>OK, fine.<br><br>I've also been =
told about a different class of functions: template functions. For reasons =
I haven't been told and don't much care about (since I'm a novice), I have =
to put the implementation in the header file. So I know that if I type the =
word "template", then that function's implementation has to go into a heade=
r. So I always do this:<br><br><div class=3D"prettyprint" style=3D"backgrou=
nd-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-styl=
e: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">//header</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">template</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">typename</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #606;" class=3D"styled-by-prettify">RetType</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> func_name_template</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">T arg1</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">...)</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//implementation</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">//sourc=
e doesn't exist.</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span></div></code></div><br>&nbsp;<br>OK, fine. So... explain t=
o me, the novice C++ programmer, why this doesn't work:<br><br><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 style=3D"color: #800;" class=3D"styled-by-prettify">//header</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">RetType</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> func_name_concept</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">ConceptName</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> arg1</span><span style=3D"colo=
r: #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"styl=
ed-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"styled=
-by-prettify">//source</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #606;" class=3D"styled-by-pret=
tify">RetType</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> func_name_concept</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">(</span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">ConceptName</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> arg1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">...)</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" c=
lass=3D"styled-by-prettify">//implementation</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">}</span></div></code></div><br>Explain to me, t=
he novice C++ programmer, why this thing which doesn't look like a template=
 suddenly <i>became</i> a template. Explain to me why I have to implement i=
t in a header, even though it looks exactly like every other non-template f=
unction declaration/definition.<br><br>To the novice C++ programmer, it <i>=
isn't</i> "all just programming." Whether something is a template <i>matter=
s</i>.<br><br>Oh, you could say, "well just put <i>everything</i> in a head=
er." That's... insane. Compile times for C++ projects of significant size a=
re already huge even when you try to only put what you need in headers. Add=
ing the burden of shoving everything in a header is crazy.<br><br>Now, if y=
ou can promise me that the same version of C++ that will include this terse=
 syntax will also include <i>modules</i>, I will immediately stop caring. O=
nce that exists, then most of the differences between template and non-temp=
late functions will be erased. And therefore, so too can the syntactic diff=
erences.<br><br>But so long as there is a difference in how you implement t=
emplate and non-template functions, I say that there should be an obvious d=
ifference in syntax too.<br><br></div><blockquote class=3D"gmail_quote" sty=
le=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left=
: 1ex;"><div link=3D"#0563C1" vlink=3D"#954F72" lang=3D"EN-US"><div><p clas=
s=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&q=
uot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&gt;
</span>My issue is with, well, any syntax that declares a template without =
having to type either the word "template" or the use of "&lt;&gt;" brackets=
..<span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif=
;color:#1f497d"></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">That ship has sailed:</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto plus =3D [](auto=
 x, auto y) { return x+y; }</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">which even already decays to an ordin=
ary pointer to function, etc.</span></p></div></div></blockquote><div><br>T=
hat doesn't decay into a function pointer. It can't; the operator() is a te=
mplate.<br>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div li=
nk=3D"#0563C1" vlink=3D"#954F72" lang=3D"EN-US"><div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">Clarifying Q: Are we mainly arguing a=
bout whether to require the three characters =3D, [, and ] ?</span></p></di=
v></div></blockquote><div>Except that there is a difference between creatin=
g a lambda (which creates a functor) and creating a function (which can be =
overloaded).<br><br></div><blockquote class=3D"gmail_quote" style=3D"margin=
: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div=
 link=3D"#0563C1" vlink=3D"#954F72" lang=3D"EN-US"><div>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">Not only has the ship sailed, but I f=
or one like the direction it=E2=80=99s sailing. I see no reason why functio=
ns should be forced to spell =E2=80=9Ctemplate=E2=80=9D and =E2=80=9C&lt;&g=
t;=E2=80=9D. What
 value does it add? It=E2=80=99s =E2=80=9Cjust programming.=E2=80=9D In fac=
t, if we didn=E2=80=99t have backward compatibility issues with unnamed par=
ameters and such, I=E2=80=99d personally probably be fine with just =E2=80=
=9Cauto plus(x,y){x+y}=E2=80=9D as an equivalent function definition. That =
still doesn=E2=80=99t
 lose any information.</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">Gratuitous syntax is often unnecessar=
y and usually harmful. Saying</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; template&lt;class T, =
class U&gt;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto(T x, U y) -&gt; =
decltype(x+y) { return x+y; }</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">does not appear to me to contain any =
more information than</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto plus(auto x, aut=
o y) { return x+y; }</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">does it?</span></p></div></div></bloc=
kquote><div>If you take out the late specified return type (I specifically =
said that static deduction was fine), then I don't see the problem with the=
 first one.<br><br>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div link=3D"#0563C1" vlink=3D"#954F72" lang=3D"EN-US"><div><p class=3D"Ms=
oNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1f497d">Requiring the verbose syntax is gratuitous, if the =
verbose syntax does not add information, does not serve to disambiguate any=
thing, and does not highlight
 a dangerous operation or anything else I can see that deserves to have att=
ention called to it.</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">There=E2=80=99s a disturbing (to me a=
nd at least some others) trend in C++ these days: People seem to be very pr=
one to wanting =E2=80=9Cmore syntax=E2=80=9D lately. It=E2=80=99s rather Va=
sa-like,
 if only lexically. Let me channel certain influential committee members an=
d say: =E2=80=98People these days are always asking for more syntax! There=
=E2=80=99s no proposal they=E2=80=99ve seen that they couldn=E2=80=99t make=
 uglier with more syntax!=E2=80=99</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">Important note: The point here is NOT=
 terseness for terseness=E2=80=99 sake. I am not arguing that terser is som=
ehow better, that terseness is virtuous in itself. Too
 many people glorify languages because they=E2=80=99re terser; fewer charac=
ters alone doesn=E2=80=99t make code clearer. Rather, my point is to avoid =
gratuitous verbosity. At the other end of the pendulum, too many people glo=
rify verbose syntax because they think _that_ is
 somehow inherently clearer; usually it isn=E2=80=99t. So I am arguing that=
 neither is verbosity virtuous in itself.</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">&nbsp;</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1f497d">Herb</span></p></div></div></blockquo=
te><div>The virtue to me of the large syntax of templates is this:<br><br>T=
emplates have to be treated differently from non-templates. They have diffe=
rent needs of where their implementations live. And because of those needs,=
 templates make your code compile slower. Even ignoring the compile-time co=
st of template instantiation, your source has to go in the header. And if t=
hat header is included in more than one place, then the source for that tem=
plate must be recompiled for every place it is included.<br><br>Therefore, =
the bulky template syntax pokes you in the eye every time you write somethi=
ng that's going to compile slower. It immediately lets you know that this f=
unction operates under fundamentally different rules than regular functions=
..<br><br>Again, if you could guarantee that we get modules alongside this s=
yntax, I'd be fine, since using templates will not hurt your compile times =
nearly as much.</div><br></div>

<p></p>

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

------=_Part_957_156317450.1425662476578--
------=_Part_956_930836835.1425662476578--

.


Author: Tom Honermann <thonermann@coverity.com>
Date: Fri, 6 Mar 2015 12:46:30 -0500
Raw View
On 03/06/2015 12:21 PM, Nicol Bolas wrote:
> Oh, you could say, "well just put /everything/ in a header." That's...
> insane.

and would cause link errors unless also specified as inline.  Now the
novice learns to define all their functions as inline functions in a header.

I'm not sure I really buy the novice argument though.  I learned this,
others can too.

The real issue to me is that the abbreviated syntax does not permit me
to syntactically determine if a function definition is a template or not
- semantic information is required (unless at least one of the
placeholder types is 'auto').

I don't see modules helping with that.

Tom.

--

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

.


Author: Herb Sutter <hsutter@microsoft.com>
Date: Fri, 6 Mar 2015 18:27:23 +0000
Raw View
--_000_BLUPR03MB45525477B539ABD37D21C09B81C0BLUPR03MB455namprd_
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

> To the novice C++ programmer, it isn't "all just programming." Whether so=
mething is a template matters.

Why? Only because of where you put the definition, and that=E2=80=99s (a) t=
eachable and (b) not new because the same issue exists already with:

                auto f() { =E2=80=A6 };

This is not a template, but must appear in a header. This is amazingly simi=
lar =E2=80=93 and easy to teach as =E2=80=9Cif the declaration mentions =E2=
=80=98auto=E2=80=99 or a concept name, the compiler needs the definition, e=
ither to deduce something or to inline the body into the caller.=E2=80=9D R=
ight?

Herb

PS =E2=80=93 Since you mention =E2=80=9Cnovices=E2=80=9D writing templates,=
 in my experience (and to my surprise) I=E2=80=99ve found that not only nov=
ices but also intermediate developers (like 5-7 year veterans) don=E2=80=99=
t write templates very much. [I expect this to change with concepts, for th=
e good.] I discovered this by chance when I had a class exercise that inclu=
ded writing a very simple template, and as I walked through the class durin=
g the exercise I was surprised that most of the groups asked about the synt=
ax for writing a template =E2=80=93 a dead giveaway that they didn=E2=80=99=
t write templates very often, yet these were pretty experienced developers =
who used C++ every day, but just never needed to write templates much in th=
eir normal code. To validate that this wasn=E2=80=99t just an outlier group=
, I=E2=80=99ve watched that exercise in a number of classes over several ye=
ars and found a similar result =E2=80=93 the majority of even reasonably ex=
perienced C++ programmers asked about the syntax for how to write a templat=
e.



From: Nicol Bolas [mailto:jmckesson@gmail.com]
Sent: Friday, March 6, 2015 9:21 AM
To: std-discussion@isocpp.org
Cc: c++std-core@accu.org; std-proposals@isocpp.org; faisalv@gmail.com; Herb=
 Sutter
Subject: Re: [c++std-core-27204] Re: An implementation of enhanced auto ded=
uction and abbreviated template syntax using Clang

On Thursday, March 5, 2015 at 7:24:32 PM UTC-5, Herb Sutter wrote:
To paraphrase Stroustrup, it=E2=80=99s not about functional programming and=
 object-oriented programming and generic programming=E2=80=A6 =E2=80=9Cit=
=E2=80=99s all just programming.=E2=80=9D

> Templates are a fundamentally different kind of construct

Why? Every full specialization of a function template is just a function.

OK, let's explore this.

Let's say that I'm a novice C++ programmer. I don't really know much about =
the language. But I have some basic knowledge.

Now, I've been told that when I write functions, I put a prototype in a hea=
der file so that other people can use it. But I also put the implementation=
 in a source file, so that it stays hidden. So I write:
//header
RetType func_name(Type1 arg1, ...);

//source
RetType func_name(Type1 arg1, ...)
{
//implementation
}


OK, fine.

I've also been told about a different class of functions: template function=
s. For reasons I haven't been told and don't much care about (since I'm a n=
ovice), I have to put the implementation in the header file. So I know that=
 if I type the word "template", then that function's implementation has to =
go into a header. So I always do this:
//header
template<typename T>
RetType func_name_template(T arg1, ...)
{
//implementation
}

//source doesn't exist.


OK, fine. So... explain to me, the novice C++ programmer, why this doesn't =
work:
//header
RetType func_name_concept(ConceptName arg1, ...);

//source
RetType func_name_concept(ConceptName arg1, ...)
{
//implementation
}

Explain to me, the novice C++ programmer, why this thing which doesn't look=
 like a template suddenly became a template. Explain to me why I have to im=
plement it in a header, even though it looks exactly like every other non-t=
emplate function declaration/definition.

To the novice C++ programmer, it isn't "all just programming." Whether some=
thing is a template matters.

Oh, you could say, "well just put everything in a header." That's... insane=
.. Compile times for C++ projects of significant size are already huge even =
when you try to only put what you need in headers. Adding the burden of sho=
ving everything in a header is crazy.

Now, if you can promise me that the same version of C++ that will include t=
his terse syntax will also include modules, I will immediately stop caring.=
 Once that exists, then most of the differences between template and non-te=
mplate functions will be erased. And therefore, so too can the syntactic di=
fferences.

But so long as there is a difference in how you implement template and non-=
template functions, I say that there should be an obvious difference in syn=
tax too.

> My issue is with, well, any syntax that declares a template without havin=
g to type either the word "template" or the use of "<>" brackets.

That ship has sailed:

                auto plus =3D [](auto x, auto y) { return x+y; }

which even already decays to an ordinary pointer to function, etc.

That doesn't decay into a function pointer. It can't; the operator() is a t=
emplate.


Clarifying Q: Are we mainly arguing about whether to require the three char=
acters =3D, [, and ] ?
Except that there is a difference between creating a lambda (which creates =
a functor) and creating a function (which can be overloaded).

Not only has the ship sailed, but I for one like the direction it=E2=80=99s=
 sailing. I see no reason why functions should be forced to spell =E2=80=9C=
template=E2=80=9D and =E2=80=9C<>=E2=80=9D. What value does it add? It=E2=
=80=99s =E2=80=9Cjust programming.=E2=80=9D In fact, if we didn=E2=80=99t h=
ave backward compatibility issues with unnamed parameters and such, I=E2=80=
=99d personally probably be fine with just =E2=80=9Cauto plus(x,y){x+y}=E2=
=80=9D as an equivalent function definition. That still doesn=E2=80=99t los=
e any information.

Gratuitous syntax is often unnecessary and usually harmful. Saying

                template<class T, class U>
                auto(T x, U y) -> decltype(x+y) { return x+y; }

does not appear to me to contain any more information than

                auto plus(auto x, auto y) { return x+y; }

does it?
If you take out the late specified return type (I specifically said that st=
atic deduction was fine), then I don't see the problem with the first one.


Requiring the verbose syntax is gratuitous, if the verbose syntax does not =
add information, does not serve to disambiguate anything, and does not high=
light a dangerous operation or anything else I can see that deserves to hav=
e attention called to it.

There=E2=80=99s a disturbing (to me and at least some others) trend in C++ =
these days: People seem to be very prone to wanting =E2=80=9Cmore syntax=E2=
=80=9D lately. It=E2=80=99s rather Vasa-like, if only lexically. Let me cha=
nnel certain influential committee members and say: =E2=80=98People these d=
ays are always asking for more syntax! There=E2=80=99s no proposal they=E2=
=80=99ve seen that they couldn=E2=80=99t make uglier with more syntax!=E2=
=80=99

Important note: The point here is NOT terseness for terseness=E2=80=99 sake=
.. I am not arguing that terser is somehow better, that terseness is virtuou=
s in itself. Too many people glorify languages because they=E2=80=99re ters=
er; fewer characters alone doesn=E2=80=99t make code clearer. Rather, my po=
int is to avoid gratuitous verbosity. At the other end of the pendulum, too=
 many people glorify verbose syntax because they think _that_ is somehow in=
herently clearer; usually it isn=E2=80=99t. So I am arguing that neither is=
 verbosity virtuous in itself.

Herb
The virtue to me of the large syntax of templates is this:

Templates have to be treated differently from non-templates. They have diff=
erent needs of where their implementations live. And because of those needs=
, templates make your code compile slower. Even ignoring the compile-time c=
ost of template instantiation, your source has to go in the header. And if =
that header is included in more than one place, then the source for that te=
mplate must be recompiled for every place it is included.

Therefore, the bulky template syntax pokes you in the eye every time you wr=
ite something that's going to compile slower. It immediately lets you know =
that this function operates under fundamentally different rules than regula=
r functions.

Again, if you could guarantee that we get modules alongside this syntax, I'=
d be fine, since using templates will not hurt your compile times nearly as=
 much.

--=20

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

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

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8">
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
 {font-family:"Cambria Math";
 panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
 {font-family:Calibri;
 panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
 {margin:0in;
 margin-bottom:.0001pt;
 font-size:12.0pt;
 font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
 {mso-style-priority:99;
 color:#0563C1;
 text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
 {mso-style-priority:99;
 color:#954F72;
 text-decoration:underline;}
code
 {mso-style-priority:99;
 font-family:"Courier New";}
span.styled-by-prettify
 {mso-style-name:styled-by-prettify;}
span.EmailStyle19
 {mso-style-type:personal-reply;
 font-family:"Calibri",sans-serif;
 color:#1F497D;}
..MsoChpDefault
 {mso-style-type:export-only;
 font-family:"Calibri",sans-serif;}
@page WordSection1
 {size:8.5in 11.0in;
 margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
 {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&gt;</span> To the novice C&#43;&#43;=
 programmer, it
<i>isn't</i> &quot;all just programming.&quot; Whether something is a templ=
ate <i>matters</i>.<span style=3D"font-size:11.0pt;font-family:&quot;Calibr=
i&quot;,sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Why? Only because of where you put th=
e definition, and that=E2=80=99s (a) teachable and (b) not new because the =
same issue exists already with:<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto f() { =E2=80=A6 =
};<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">This is not a template, but must appe=
ar in a header. This is amazingly similar =E2=80=93 and easy to teach as =
=E2=80=9Cif the declaration mentions =E2=80=98auto=E2=80=99 or a concept na=
me, the
 compiler needs the definition, either to deduce something or to inline the=
 body into the caller.=E2=80=9D Right?<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">Herb<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D">PS =E2=80=93 Since you mention =E2=80=
=9Cnovices=E2=80=9D writing templates, in my experience (and to my surprise=
) I=E2=80=99ve found that not only novices but also intermediate developers=
 (like
 5-7 year veterans) don=E2=80=99t write templates very much. [I expect this=
 to change with concepts, for the good.] I discovered this by chance when I=
 had a class exercise that included writing a very simple template, and as =
I walked through the class during the exercise
 I was surprised that most of the groups asked about the syntax for writing=
 a template =E2=80=93 a dead giveaway that they didn=E2=80=99t write templa=
tes very often, yet these were pretty experienced developers who used C&#43=
;&#43; every day, but just never needed to write templates
 much in their normal code. To validate that this wasn=E2=80=99t just an ou=
tlier group, I=E2=80=99ve watched that exercise in a number of classes over=
 several years and found a similar result =E2=80=93 the majority of even re=
asonably experienced C&#43;&#43; programmers asked about the syntax
 for how to write a template.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;font-family:&quot;Ca=
libri&quot;,sans-serif;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div style=3D"border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in =
4.0pt">
<div>
<div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in =
0in 0in">
<p class=3D"MsoNormal"><b><span style=3D"font-size:11.0pt;font-family:&quot=
;Calibri&quot;,sans-serif">From:</span></b><span style=3D"font-size:11.0pt;=
font-family:&quot;Calibri&quot;,sans-serif"> Nicol Bolas [mailto:jmckesson@=
gmail.com]
<br>
<b>Sent:</b> Friday, March 6, 2015 9:21 AM<br>
<b>To:</b> std-discussion@isocpp.org<br>
<b>Cc:</b> c&#43;&#43;std-core@accu.org; std-proposals@isocpp.org; faisalv@=
gmail.com; Herb Sutter<br>
<b>Subject:</b> Re: [c&#43;&#43;std-core-27204] Re: An implementation of en=
hanced auto deduction and abbreviated template syntax using Clang<o:p></o:p=
></span></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<p class=3D"MsoNormal">On Thursday, March 5, 2015 at 7:24:32 PM UTC-5, Herb=
 Sutter wrote:<o:p></o:p></p>
<blockquote style=3D"border:none;border-left:solid #CCCCCC 1.0pt;padding:0i=
n 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">To paraphrase Stroustrup, it=E2=80=99s not about fu=
nctional programming and object-oriented programming and
 generic programming=E2=80=A6 =E2=80=9Cit=E2=80=99s all <i>just programming=
</i>.=E2=80=9D</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&gt;
</span>Templates are a fundamentally different kind of construct<o:p></o:p>=
</p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">Why? Every full specialization of a function templa=
te is just a function.</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
OK, let's explore this.<br>
<br>
Let's say that I'm a novice C&#43;&#43; programmer. I don't really know muc=
h about the language. But I have some basic knowledge.<br>
<br>
Now, I've been told that when I write functions, I put a prototype in a hea=
der file so that other people can use it. But I also put the implementation=
 in a source file, so that it stays hidden. So I write:<o:p></o:p></p>
<div style=3D"border:solid #BBBBBB 1.0pt;padding:0in 0in 0in 0in;word-wrap:=
 break-word">
<div>
<p class=3D"MsoNormal" style=3D"background:#FAFAFA"><span class=3D"styled-b=
y-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;;color:#880000">//header</span></span><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#660066">RetType</span></span><spa=
n class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:=
&quot;Courier New&quot;;color:black"> func_name</span></span><span class=3D=
"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Cour=
ier New&quot;;color:#666600">(</span></span><span class=3D"styled-by-pretti=
fy"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;col=
or:#660066">Type1</span></span><span class=3D"styled-by-prettify"><span sty=
le=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">
 arg1</span></span><span class=3D"styled-by-prettify"><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">,</span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:black">
</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:1=
0.0pt;font-family:&quot;Courier New&quot;;color:#666600">...);</span></span=
><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:=
black"><br>
<br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#880000">//source</span></span><sp=
an style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:blac=
k"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#660066">RetType</span></span><spa=
n class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:=
&quot;Courier New&quot;;color:black"> func_name</span></span><span class=3D=
"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Cour=
ier New&quot;;color:#666600">(</span></span><span class=3D"styled-by-pretti=
fy"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;col=
or:#660066">Type1</span></span><span class=3D"styled-by-prettify"><span sty=
le=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black">
 arg1</span></span><span class=3D"styled-by-prettify"><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">,</span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:black">
</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:1=
0.0pt;font-family:&quot;Courier New&quot;;color:#666600">...)</span></span>=
<span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:b=
lack"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#666600">{</span></span><span styl=
e=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#880000">//implementation</span></=
span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;co=
lor:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#666600">}</span></span><span styl=
e=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><o:p></o:p></spa=
n></p>
</div>
</div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
<br>
OK, fine.<br>
<br>
I've also been told about a different class of functions: template function=
s. For reasons I haven't been told and don't much care about (since I'm a n=
ovice), I have to put the implementation in the header file. So I know that=
 if I type the word &quot;template&quot;,
 then that function's implementation has to go into a header. So I always d=
o this:<o:p></o:p></p>
<div style=3D"border:solid #BBBBBB 1.0pt;padding:0in 0in 0in 0in;word-wrap:=
 break-word">
<div>
<p class=3D"MsoNormal" style=3D"background:#FAFAFA"><span class=3D"styled-b=
y-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;;color:#880000">//header</span></span><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#000088">template</span></span><sp=
an class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family=
:&quot;Courier New&quot;;color:#666600">&lt;</span></span><span class=3D"st=
yled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier=
 New&quot;;color:#000088">typename</span></span><span class=3D"styled-by-pr=
ettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;=
;color:black">
 T</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size=
:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">&gt;</span></spa=
n><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color=
:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#660066">RetType</span></span><spa=
n class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:=
&quot;Courier New&quot;;color:black"> func_name_template</span></span><span=
 class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&=
quot;Courier New&quot;;color:#666600">(</span></span><span class=3D"styled-=
by-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&=
quot;;color:black">T
 arg1</span></span><span class=3D"styled-by-prettify"><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">,</span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:black">
</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:1=
0.0pt;font-family:&quot;Courier New&quot;;color:#666600">...)</span></span>=
<span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:b=
lack"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#666600">{</span></span><span styl=
e=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#880000">//implementation</span></=
span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;co=
lor:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#666600">}</span></span><span styl=
e=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><br>
<br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#880000">//source doesn't exist.</=
span></span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;"><o:p></o:p></span></p>
</div>
</div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
&nbsp;<br>
OK, fine. So... explain to me, the novice C&#43;&#43; programmer, why this =
doesn't work:<o:p></o:p></p>
<div style=3D"border:solid #BBBBBB 1.0pt;padding:0in 0in 0in 0in;word-wrap:=
 break-word">
<div>
<p class=3D"MsoNormal" style=3D"background:#FAFAFA"><span class=3D"styled-b=
y-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;;color:#880000">//header</span></span><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#660066">RetType</span></span><spa=
n class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:=
&quot;Courier New&quot;;color:black"> func_name_concept</span></span><span =
class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&q=
uot;Courier New&quot;;color:#666600">(</span></span><span class=3D"styled-b=
y-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;;color:#660066">ConceptName</span></span><span class=3D"styled-by-prett=
ify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;co=
lor:black">
 arg1</span></span><span class=3D"styled-by-prettify"><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">,</span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:black">
</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:1=
0.0pt;font-family:&quot;Courier New&quot;;color:#666600">...);</span></span=
><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:=
black"><br>
<br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#880000">//source</span></span><sp=
an style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:blac=
k"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#660066">RetType</span></span><spa=
n class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:=
&quot;Courier New&quot;;color:black"> func_name_concept</span></span><span =
class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-family:&q=
uot;Courier New&quot;;color:#666600">(</span></span><span class=3D"styled-b=
y-prettify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&q=
uot;;color:#660066">ConceptName</span></span><span class=3D"styled-by-prett=
ify"><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;co=
lor:black">
 arg1</span></span><span class=3D"styled-by-prettify"><span style=3D"font-s=
ize:10.0pt;font-family:&quot;Courier New&quot;;color:#666600">,</span></spa=
n><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;font-f=
amily:&quot;Courier New&quot;;color:black">
</span></span><span class=3D"styled-by-prettify"><span style=3D"font-size:1=
0.0pt;font-family:&quot;Courier New&quot;;color:#666600">...)</span></span>=
<span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:b=
lack"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#666600">{</span></span><span styl=
e=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;color:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#880000">//implementation</span></=
span><span style=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;;co=
lor:black"><br>
</span><span class=3D"styled-by-prettify"><span style=3D"font-size:10.0pt;f=
ont-family:&quot;Courier New&quot;;color:#666600">}</span></span><span styl=
e=3D"font-size:10.0pt;font-family:&quot;Courier New&quot;"><o:p></o:p></spa=
n></p>
</div>
</div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"><br>
Explain to me, the novice C&#43;&#43; programmer, why this thing which does=
n't look like a template suddenly
<i>became</i> a template. Explain to me why I have to implement it in a hea=
der, even though it looks exactly like every other non-template function de=
claration/definition.<br>
<br>
To the novice C&#43;&#43; programmer, it <i>isn't</i> &quot;all just progra=
mming.&quot; Whether something is a template
<i>matters</i>.<br>
<br>
Oh, you could say, &quot;well just put <i>everything</i> in a header.&quot;=
 That's... insane. Compile times for C&#43;&#43; projects of significant si=
ze are already huge even when you try to only put what you need in headers.=
 Adding the burden of shoving everything in a header
 is crazy.<br>
<br>
Now, if you can promise me that the same version of C&#43;&#43; that will i=
nclude this terse syntax will also include
<i>modules</i>, I will immediately stop caring. Once that exists, then most=
 of the differences between template and non-template functions will be era=
sed. And therefore, so too can the syntactic differences.<br>
<br>
But so long as there is a difference in how you implement template and non-=
template functions, I say that there should be an obvious difference in syn=
tax too.<o:p></o:p></p>
</div>
<blockquote style=3D"border:none;border-left:solid #CCCCCC 1.0pt;padding:0i=
n 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&gt;
</span>My issue is with, well, any syntax that declares a template without =
having to type either the word &quot;template&quot; or the use of &quot;&lt=
;&gt;&quot; brackets.<o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">That ship has sailed:</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto plus =3D [](auto x, auto y) { =
return x&#43;y; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">which even already decays to an ordinary pointer to=
 function, etc.</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class=3D"MsoNormal"><br>
That doesn't decay into a function pointer. It can't; the operator() is a t=
emplate.<br>
&nbsp;<o:p></o:p></p>
</div>
<blockquote style=3D"border:none;border-left:solid #CCCCCC 1.0pt;padding:0i=
n 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">Clarifying Q: Are we mainly arguing about whether t=
o require the three characters =3D, [, and ] ?</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt">Except that there is =
a difference between creating a lambda (which creates a functor) and creati=
ng a function (which can be overloaded).<o:p></o:p></p>
</div>
<blockquote style=3D"border:none;border-left:solid #CCCCCC 1.0pt;padding:0i=
n 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">Not only has the ship sailed, but I for one like th=
e direction it=E2=80=99s sailing. I see no reason why functions
 should be forced to spell =E2=80=9Ctemplate=E2=80=9D and =E2=80=9C&lt;&gt;=
=E2=80=9D. What value does it add? It=E2=80=99s =E2=80=9Cjust programming.=
=E2=80=9D In fact, if we didn=E2=80=99t have backward compatibility issues =
with unnamed parameters and such, I=E2=80=99d personally probably be fine w=
ith just =E2=80=9Cauto plus(x,y){x&#43;y}=E2=80=9D as an
 equivalent function definition. That still doesn=E2=80=99t lose any inform=
ation.</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">Gratuitous syntax is often unnecessary and usually =
harmful. Saying</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; template&lt;class T, class U&gt;</s=
pan><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto(T x, U y) -&gt; decltype(x&#43=
;y) { return x&#43;y; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">does not appear to me to contain any more informati=
on than</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto plus(auto x, auto y) { return =
x&#43;y; }</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">does it?</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class=3D"MsoNormal">If you take out the late specified return type (I sp=
ecifically said that static deduction was fine), then I don't see the probl=
em with the first one.<br>
<br>
&nbsp;<o:p></o:p></p>
</div>
<blockquote style=3D"border:none;border-left:solid #CCCCCC 1.0pt;padding:0i=
n 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">Requiring the verbose syntax is gratuitous, if the =
verbose syntax does not add information, does not
 serve to disambiguate anything, and does not highlight a dangerous operati=
on or anything else I can see that deserves to have attention called to it.=
</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">There=E2=80=99s a disturbing (to me and at least so=
me others) trend in C&#43;&#43; these days: People seem to be very
 prone to wanting =E2=80=9Cmore syntax=E2=80=9D lately. It=E2=80=99s rather=
 Vasa-like, if only lexically. Let me channel certain influential committee=
 members and say: =E2=80=98People these days are always asking for more syn=
tax! There=E2=80=99s no proposal they=E2=80=99ve seen that they couldn=E2=
=80=99t make uglier
 with more syntax!=E2=80=99</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">Important note: The point here is NOT terseness for=
 terseness=E2=80=99 sake. I am not arguing that terser is
 somehow better, that terseness is virtuous in itself. Too many people glor=
ify languages because they=E2=80=99re terser; fewer characters alone doesn=
=E2=80=99t make code clearer. Rather, my point is to avoid gratuitous verbo=
sity. At the other end of the pendulum, too many
 people glorify verbose syntax because they think _that_ is somehow inheren=
tly clearer; usually it isn=E2=80=99t. So I am arguing that neither is verb=
osity virtuous in itself.</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a=
lt:auto"><span style=3D"font-size:11.0pt;font-family:&quot;Calibri&quot;,sa=
ns-serif;color:#1F497D">Herb</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class=3D"MsoNormal">The virtue to me of the large syntax of templates is=
 this:<br>
<br>
Templates have to be treated differently from non-templates. They have diff=
erent needs of where their implementations live. And because of those needs=
, templates make your code compile slower. Even ignoring the compile-time c=
ost of template instantiation, your
 source has to go in the header. And if that header is included in more tha=
n one place, then the source for that template must be recompiled for every=
 place it is included.<br>
<br>
Therefore, the bulky template syntax pokes you in the eye every time you wr=
ite something that's going to compile slower. It immediately lets you know =
that this function operates under fundamentally different rules than regula=
r functions.<br>
<br>
Again, if you could guarantee that we get modules alongside this syntax, I'=
d be fine, since using templates will not hurt your compile times nearly as=
 much.<o:p></o:p></p>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
</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 - Discussion&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-discussion+unsubscribe@isocpp.org">std-discus=
sion+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-discussion@isocp=
p.org">std-discussion@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-discussion/">http://groups.google.com/a/isocpp.org/group/std-discussion=
/</a>.<br />

--_000_BLUPR03MB45525477B539ABD37D21C09B81C0BLUPR03MB455namprd_--

.


Author: Nevin Liber <nevin@eviloverlord.com>
Date: Fri, 6 Mar 2015 12:56:22 -0600
Raw View
--001a1139ba94fb641c0510a33f13
Content-Type: text/plain; charset=UTF-8

On 6 March 2015 at 11:21, Nicol Bolas <jmckesson@gmail.com> wrote:

>                 auto plus = [](auto x, auto y) { return x+y; }
>>
>>
>>
>> which even already decays to an ordinary pointer to function, etc.
>>
>
> That doesn't decay into a function pointer. It can't; the operator() is a
> template.
>

This code seems to work:

    using fn = int (*)(int, int);

    fn f = plus;

    std::cout << f(2, 3) << std::endl;
--
 Nevin ":-)" Liber  <mailto:nevin@eviloverlord.com>  (847) 691-1404

--

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

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On 6 March 2015 at 11:21, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"mail=
to:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</span=
> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0=
..8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-s=
tyle:solid;padding-left:1ex"><span><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(20=
4,204,204);border-left-style:solid;padding-left:1ex"><div link=3D"#0563C1" =
vlink=3D"#954F72" lang=3D"EN-US"><div><p class=3D"MsoNormal"><span style=3D=
"font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 auto plus =3D [](auto x, auto y) { return x+y; }</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11pt;font-family:Calibri,sa=
ns-serif;color:rgb(31,73,125)">=C2=A0</span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:11pt;font-family:Calibri,sa=
ns-serif;color:rgb(31,73,125)">which even already decays to an ordinary poi=
nter to function, etc.</span></p></div></div></blockquote></span><div><br>T=
hat doesn&#39;t decay into a function pointer. It can&#39;t; the operator()=
 is a template.<br></div></blockquote></div><br>This code seems to work:</d=
iv><div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra"><p style=
=3D"margin:0px;font-size:11px;font-family:Menlo">=C2=A0 =C2=A0=C2=A0<span s=
tyle=3D"color:rgb(187,44,162)">using</span> fn =3D <span style=3D"color:rgb=
(187,44,162)">int</span> (*)(<span style=3D"color:rgb(187,44,162)">int</spa=
n>, <span style=3D"color:rgb(187,44,162)">int</span>);</p><p style=3D"margi=
n:0px;font-size:11px;font-family:Menlo">=C2=A0 =C2=A0 fn f =3D plus;</p><p =
style=3D"margin:0px;font-size:10px;font-family:&#39;Source Code Pro&#39;;ba=
ckground-color:rgb(254,244,156)">

</p><p style=3D"margin:0px;font-size:11px;font-family:Menlo">=C2=A0 =C2=A0 =
std::cout &lt;&lt; f(<span style=3D"color:rgb(39,42,216)">2</span>, <span s=
tyle=3D"color:rgb(39,42,216)">3</span>) &lt;&lt; std::endl;</p>-- <br><div>=
=C2=A0Nevin &quot;:-)&quot; Liber=C2=A0 &lt;mailto:<a href=3D"mailto:nevin@=
eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>&gt;=C2=A0 <a=
 href=3D"tel:%28847%29%20691-1404" value=3D"+18476911404" target=3D"_blank"=
>(847) 691-1404</a></div>
</div></div>

<p></p>

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

--001a1139ba94fb641c0510a33f13--

.