Topic: [proposal]Alternate concepts idea
Author: Darius Jankauskas <d5926j@gmail.com>
Date: Tue, 15 Nov 2016 19:33:55 -0800 (PST)
Raw View
------=_Part_3876_1764109956.1479267235707
Content-Type: multipart/alternative;
boundary="----=_Part_3877_661065046.1479267235707"
------=_Part_3877_661065046.1479267235707
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
We currently have a C++ proposal for Concepts-lite. However, it has several=
=20
issues. First of all, there is no compile-time checking by the compiler to=
=20
ensure functions and classes aren=E2=80=99t using functionality of a type n=
ot=20
specified as a concept. Second of all, the two different forms of concepts=
=20
as functions are variable templates are undesirable, as they have various=
=20
differences such as that the variable form cannot be overloaded, but the=20
function form can.
I think another design inspired by older ideas is needed; this is an=20
informal starting point.
For this, a new construct predictably named concept and the keyword require=
s=20
would be introduced. A concept would be defined as a set of=20
pseudo-signatures. For example, a concept that would test for the presence=
=20
of operator< would be implemented as =20
template <typename T> concept LessThanComparable
{
bool T::operator<(const T&, const T&);
};
(This is in comparison to the function Concepts-lite version:
template <typename T> concept
bool LessThanComparable() {
return requires(T a, T b) { {a < b} -> bool;} };
}
)
This can be used to constrain functions and templates; for example, a=20
helper function that is used to define operator=3D=3D with only operator< w=
ould=20
be
template <typename T>
bool is_equal(const T& lhs, const T& rhs)
requires LessThanComparable<T> {return !(a < b) && !(b < a);}; //long=20
form, short form available
This function is constrained; types that do not meet LessThanComparable wil=
l=20
cause a compiler error(if no other suitable functions are available;=20
Concept failure Is Not An Error!). is_equal<int> will succeed, but=20
is_equal<std::vector> will fail as it has no matching operator<. The=20
concept can also be used as a variable template to replace a use case of=20
Concepts-lite:
constexpr if(LessThanComparable<T>) //becomes constexpr bool, true if all=
=20
conditions met, false otherwise
//some code;=20
Many different types of requirements can be declared:
template <typename T> concept Example //requires ... can inherit=20
constraints from other concepts as well as accepting constexpr bools that=
=20
must be true for success
{
int T::position; //member variable
std::sort<T>(T, T); //free-standing function=20
static int T::static_func(int foo); // static member functions
T::typename size_type; //member type
};
These requirements would not have to be met perfectly, with for example a=
=20
function that accepts variables by value would satisfy a requirement for a=
=20
function accepting variables by const reference. Defining how strict and=20
lenient such rules would be is quite difficult. Functions as well as class=
=20
member functions would be checked to ensure that no functionality of types=
=20
that was not defined in a constraint could be used. (this would not be=20
applicable to any language feature that is completely unconstrained for=20
backwards compatibility.)=20
Other aspects of a concepts system would be taken directly from=20
concepts-lite, such abbreviated forms of declaring constrained functions &=
=20
other templates, choosing of more specifically constrained functions, and=
=20
the requires clause from the proposal, with some changes to deal with the=
=20
changed nature of this proposal. These are some early thoughts of mine on a=
=20
different proposal than is currently present, any feedback would be much=20
appreciated!
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/5a081e2d-0c6b-479e-b5e0-985a7d1e0827%40isocpp.or=
g.
------=_Part_3877_661065046.1479267235707
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span id=3D"docs-internal-guid-d24b9cad-6b1f-d86a-3749-eee=
554693c5b"><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-b=
ottom:0pt;"><span style=3D"font-size:14.666666666666666px;font-family:Arial=
;color:#000000;background-color:transparent;font-weight:400;font-style:norm=
al;font-variant:normal;text-decoration:none;vertical-align:baseline;white-s=
pace:pre-wrap;">We currently have a C++ proposal for Concepts-lite. However=
, it has several issues. First of all, there is no compile-time checking by=
the compiler to ensure functions and classes aren=E2=80=99t using function=
ality of a type not specified as a concept. Second of all, the two differen=
t forms of concepts as functions are variable templates are undesirable, as=
they have various differences such as that the variable form cannot be ove=
rloaded, but the function form can.</span></p><p dir=3D"ltr" style=3D"line-=
height:1.38;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:14.=
666666666666666px;font-family:Arial;color:#000000;background-color:transpar=
ent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:n=
one;vertical-align:baseline;white-space:pre-wrap;">I think another design i=
nspired by older ideas is needed; this is an informal starting point.</span=
></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:=
0pt;"><span style=3D"font-size:14.666666666666666px;font-family:Arial;color=
:#000000;background-color:transparent;font-weight:400;font-style:normal;fon=
t-variant:normal;text-decoration:none;vertical-align:baseline;white-space:p=
re-wrap;">For this, a new construct predictably named </span><span style=3D=
"font-size:14.666666666666666px;font-family:'Courier New';color:#00=
0000;background-color:transparent;font-weight:400;font-style:normal;font-va=
riant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-w=
rap;">concept</span><span style=3D"font-size:14.666666666666666px;font-fami=
ly:Arial;color:#000000;background-color:transparent;font-weight:400;font-st=
yle:normal;font-variant:normal;text-decoration:none;vertical-align:baseline=
;white-space:pre-wrap;"> and the keyword </span><span style=3D"font-size:14=
..666666666666666px;font-family:'Courier New';color:#000000;backgrou=
nd-color:transparent;font-weight:400;font-style:normal;font-variant:normal;=
text-decoration:none;vertical-align:baseline;white-space:pre-wrap;">require=
s</span><span style=3D"font-size:14.666666666666666px;font-family:Arial;col=
or:#000000;background-color:transparent;font-weight:400;font-style:normal;f=
ont-variant:normal;text-decoration:none;vertical-align:baseline;white-space=
:pre-wrap;"> would be introduced. A concept would be defined as a set of ps=
eudo-signatures. For example, a concept that would test for the presence of=
</span><span style=3D"font-size:14.666666666666666px;font-family:'Cour=
ier New';color:#000000;background-color:transparent;font-weight:400;fon=
t-style:normal;font-variant:normal;text-decoration:none;vertical-align:base=
line;white-space:pre-wrap;">operator< </span><span style=3D"font-size:14=
..666666666666666px;font-family:Arial;color:#000000;background-color:transpa=
rent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:=
none;vertical-align:baseline;white-space:pre-wrap;">would be implemented as=
=C2=A0</span></p><div class=3D"prettyprint" style=3D"background-color: rgb=
(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bor=
der-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">template</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">concept</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">LessThanComparable</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><br>=C2=A0</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">bool</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">operator</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
<(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">&,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">const</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&);</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br><br></span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">};</span></div></code></div><p dir=3D"ltr" style=
=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font=
-size:14.666666666666666px;font-family:'Courier New';color:#000000;=
background-color:transparent;font-weight:400;font-style:normal;font-variant=
:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;"=
><br></span></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;mar=
gin-bottom:0pt;"><span style=3D"font-size:14.666666666666666px;font-family:=
Arial;color:#000000;background-color:transparent;font-weight:400;font-style=
:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;wh=
ite-space:pre-wrap;">(This is in comparison to the function Concepts-lite v=
ersion:</span></p><div class=3D"prettyprint" style=3D"background-color: rgb=
(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bor=
der-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cl=
ass=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">template</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">></span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">concept</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">bool</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">LessThanComparable</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-prettify">re=
turn</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> requi=
res</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">T a</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> T b</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">-></span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">bool</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">;}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code><=
/div><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:=
0pt;"><span style=3D"font-size:14.666666666666666px;font-family:'Courie=
r New';color:#000000;background-color:transparent;font-weight:400;font-=
style:normal;font-variant:normal;text-decoration:none;vertical-align:baseli=
ne;white-space:pre-wrap;"><br></span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.38;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:14.66666=
6666666666px;font-family:Arial;color:#000000;background-color:transparent;f=
ont-weight:400;font-style:normal;font-variant:normal;text-decoration:none;v=
ertical-align:baseline;white-space:pre-wrap;">)</span></p><p dir=3D"ltr" st=
yle=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt;"><span style=3D"f=
ont-size:14.666666666666666px;font-family:Arial;color:#000000;background-co=
lor:transparent;font-weight:400;font-style:normal;font-variant:normal;text-=
decoration:none;vertical-align:baseline;white-space:pre-wrap;">This can be =
used to constrain functions and templates; for example, a helper function t=
hat is used to define </span><span style=3D"font-size:14.666666666666666px;=
font-family:'Courier New';color:#000000;background-color:transparen=
t;font-weight:400;font-style:normal;font-variant:normal;text-decoration:non=
e;vertical-align:baseline;white-space:pre-wrap;">operator=3D=3D </span><spa=
n style=3D"font-size:14.666666666666666px;font-family:Arial;color:#000000;b=
ackground-color:transparent;font-weight:400;font-style:normal;font-variant:=
normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;">=
with only </span><span style=3D"font-size:14.666666666666666px;font-family:=
'Courier New';color:#000000;background-color:transparent;font-weigh=
t:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-a=
lign:baseline;white-space:pre-wrap;">operator<</span><span style=3D"font=
-size:14.666666666666666px;font-family:Arial;color:#000000;background-color=
:transparent;font-weight:400;font-style:normal;font-variant:normal;text-dec=
oration:none;vertical-align:baseline;white-space:pre-wrap;"> would be</span=
></p><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 25=
0); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1p=
x; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">templat=
e</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br>=C2=A0</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">bool</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> is_equal</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> lhs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">&</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> rhs</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>=C2=A0requires </span><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">LessThanComparable</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">></span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</span><span style=3D"background-color: transparent; color: rgb(0, 1=
21, 107); font-family: "Courier New"; font-size: 14.6667px; white=
-space: pre-wrap;"><span style=3D"color: #008;" class=3D"styled-by-prettify=
">return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">!(</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">a </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&&</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">!(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">);</span></span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #8=
00;" class=3D"styled-by-prettify">//long form, short form available</span><=
/div></code></div><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;m=
argin-bottom:0pt;"><span style=3D"font-size:14.666666666666666px;font-famil=
y:'Courier New';color:#000000;background-color:transparent;font-wei=
ght:400;font-style:normal;font-variant:normal;text-decoration:none;vertical=
-align:baseline;white-space:pre-wrap;"><br></span></p><p dir=3D"ltr" style=
=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font=
-size:14.666666666666666px;font-family:Arial;color:#000000;background-color=
:transparent;font-weight:400;font-style:normal;font-variant:normal;text-dec=
oration:none;vertical-align:baseline;white-space:pre-wrap;">This function i=
s constrained; types that do not meet </span><span style=3D"font-size:14.66=
6666666666666px;font-family:'Courier New';color:#000000;background-=
color:transparent;font-weight:400;font-style:normal;font-variant:normal;tex=
t-decoration:none;vertical-align:baseline;white-space:pre-wrap;">LessThanCo=
mparable </span><span style=3D"font-size:14.666666666666666px;font-family:A=
rial;color:#000000;background-color:transparent;font-weight:400;font-style:=
normal;font-variant:normal;text-decoration:none;vertical-align:baseline;whi=
te-space:pre-wrap;">will cause a compiler error(if no other suitable functi=
ons are available; Concept failure Is Not An Error!). </span><span style=3D=
"font-size:14.666666666666666px;font-family:'Courier New';color:#00=
0000;background-color:transparent;font-weight:400;font-style:normal;font-va=
riant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-w=
rap;">is_equal<int></span><span style=3D"font-size:14.666666666666666=
px;font-family:Arial;color:#000000;background-color:transparent;font-weight=
:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-al=
ign:baseline;white-space:pre-wrap;"> will succeed, but </span><span style=
=3D"font-size:14.666666666666666px;font-family:'Courier New';color:=
#000000;background-color:transparent;font-weight:400;font-style:normal;font=
-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pr=
e-wrap;">is_equal<std::vector></span><span style=3D"font-size:14.6666=
66666666666px;font-family:Arial;color:#000000;background-color:transparent;=
font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;=
vertical-align:baseline;white-space:pre-wrap;"> will fail as it has no matc=
hing </span><span style=3D"font-size:14.666666666666666px;font-family:'=
Courier New';color:#000000;background-color:transparent;font-weight:400=
;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:=
baseline;white-space:pre-wrap;">operator<</span><span style=3D"font-size=
:14.666666666666666px;font-family:Arial;color:#000000;background-color:tran=
sparent;font-weight:400;font-style:normal;font-variant:normal;text-decorati=
on:none;vertical-align:baseline;white-space:pre-wrap;">. The concept can al=
so be used as a variable template to replace a use case of Concepts-lite:</=
span></p><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250=
, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width=
: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">con=
stexpr</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">LessThanComparable</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">>)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">//becomes constexpr bool, true if all conditions =
met, false otherwise</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>=C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">//some code; </span></div></code></div><p dir=3D"ltr" style=3D"li=
ne-height:1.38;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:=
14.666666666666666px;font-family:'Courier New';color:#000000;backgr=
ound-color:transparent;font-weight:400;font-style:normal;font-variant:norma=
l;text-decoration:none;vertical-align:baseline;white-space:pre-wrap;"><br><=
/span></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bo=
ttom:0pt;"><span style=3D"font-size:14.666666666666666px;font-family:Arial;=
color:#000000;background-color:transparent;font-weight:400;font-style:norma=
l;font-variant:normal;text-decoration:none;vertical-align:baseline;white-sp=
ace:pre-wrap;">Many different types of requirements can be declared:</span>=
</p><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250=
); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px=
; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><span style=3D"color: #008;" class=3D"styled-by-prettify">template=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">typename</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">concept</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Example</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettif=
y">//requires ... can inherit constraints from other concepts as well as ac=
cepting constexpr bools that must be true for success</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;" c=
lass=3D"styled-by-prettify"><br>=C2=A0</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">position</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//member variab=
le</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">sort</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">T</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">>(</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">//free=
-standing function </span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br>=C2=A0</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">static</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">int<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">static_func</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> foo</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-=
prettify">// static member functions</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>=C2=A0T</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">typename</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> size_type</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/member type</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
};</span></div></code></div><p dir=3D"ltr" style=3D"line-height:1.38;margin=
-top:0pt;margin-bottom:0pt;"><span style=3D"font-size: 14.6667px; color: rg=
b(0, 0, 0); background-color: transparent; font-weight: 400; font-style: no=
rmal; font-variant-ligatures: normal; font-variant-caps: normal; text-decor=
ation: none; vertical-align: baseline; white-space: pre-wrap;"><font face=
=3D"arial, sans-serif">These requirements would not have to be met perfectl=
y, with for example a function that accepts variables by value would satis=
fy a requirement for a function accepting variables by const reference. Def=
ining how strict and lenient such rules would be is quite difficult. Functi=
ons as well as class member functions would be checked to ensure that no f=
unctionality of types that was not defined in a constraint could be used. (=
this would not be applicable to any language feature that is completely unc=
onstrained for backwards compatibility.) </font></span></p><p dir=3D"ltr" s=
tyle=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt;"><span id=3D"doc=
s-internal-guid-d24b9cad-6b1f-d86a-3749-eee554693c5b"><span style=3D"font-s=
ize: 14.6667px; font-family: Arial; color: rgb(0, 0, 0); background-color: =
transparent; vertical-align: baseline; white-space: pre-wrap;">Other aspect=
s of a concepts system would be taken directly from concepts-lite, such abb=
reviated forms of declaring constrained functions & other templates, ch=
oosing of more specifically constrained functions, and the </span><span sty=
le=3D"font-size: 14.6667px; font-family: "Courier New"; color: rg=
b(0, 0, 0); background-color: transparent; vertical-align: baseline; white-=
space: pre-wrap;">requires</span><span style=3D"font-size: 14.6667px; font-=
family: Arial; color: rgb(0, 0, 0); background-color: transparent; vertical=
-align: baseline; white-space: pre-wrap;"> clause from the proposal, with s=
ome changes to deal with the changed nature of this proposal. These are som=
e early thoughts of mine on a different proposal than is currently present,=
any feedback would be much appreciated!</span></span><br></p></span></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5a081e2d-0c6b-479e-b5e0-985a7d1e0827%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5a081e2d-0c6b-479e-b5e0-985a7d1e0827=
%40isocpp.org</a>.<br />
------=_Part_3877_661065046.1479267235707--
------=_Part_3876_1764109956.1479267235707--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 15 Nov 2016 20:27:37 -0800 (PST)
Raw View
------=_Part_1504_798216096.1479270457379
Content-Type: multipart/alternative;
boundary="----=_Part_1505_745134686.1479270457379"
------=_Part_1505_745134686.1479270457379
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankauskas wrote=
:
>
> We currently have a C++ proposal for Concepts-lite. However, it has=20
> several issues. First of all, there is no compile-time checking by the=20
> compiler to ensure functions and classes aren=E2=80=99t using functionali=
ty of a=20
> type not specified as a concept. Second of all, the two different forms o=
f=20
> concepts as functions are variable templates are undesirable, as they hav=
e=20
> various differences such as that the variable form cannot be overloaded,=
=20
> but the function form can.=20
>
I think another design inspired by older ideas is needed; this is an=20
> informal starting point.
>
We do not need a complete teardown&redesign of concepts in order to resolve=
=20
either of those problems.
I don't see any particular advantage to your specific syntax, relative to=
=20
implementing one of the fixes for item 2 from this paper=20
<http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0324r0.html>.
=20
> Many different types of requirements can be declared:
> template <typename T> concept Example //requires ... can inherit=20
> constraints from other concepts as well as accepting constexpr bools that=
=20
> must be true for success
> {
> int T::position; //member variable
> std::sort<T>(T, T); //free-standing function=20
> static int T::static_func(int foo); // static member functions
> T::typename size_type; //member type
>
> };
>
> These requirements would not have to be met perfectly, with for example a=
=20
> function that accepts variables by value would satisfy a requirement for =
a=20
> function accepting variables by const reference.
>
Issues like that are precisely why concepts-TS has constraints defined by=
=20
*expressions* on values of those types, rather than checking for the=20
existence of a particular functions or members. That's why the `requires`=
=20
clause is able to declare that variables of a certain type speculatively=20
exist, so that you can apply expressions to them.
Your way is far too specific. Concepts are a way of saying, "here are the=
=20
things I expect to be able to do with the type in question.
Why does it matter for a concept if `T::position` is exactly `int`? Why=20
can't it be `short`? Or any integer type? Or any type which conforms to an=
=20
integer-like concept?
>
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/d21de5a1-1643-4fac-9baa-aca32cafb63a%40isocpp.or=
g.
------=_Part_1505_745134686.1479270457379
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius=
Jankauskas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr"><span><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-b=
ottom:0pt"><span style=3D"font-size:14.666666666666666px;font-family:Arial;=
color:#000000;background-color:transparent;font-weight:400;font-style:norma=
l;font-variant:normal;text-decoration:none;vertical-align:baseline;white-sp=
ace:pre-wrap">We currently have a C++ proposal for Concepts-lite. However, =
it has several issues. First of all, there is no compile-time checking by t=
he compiler to ensure functions and classes aren=E2=80=99t using functional=
ity of a type not specified as a concept. Second of all, the two different =
forms of concepts as functions are variable templates are undesirable, as t=
hey have various differences such as that the variable form cannot be overl=
oaded, but the function form can.</span>=C2=A0</p></span></div></blockquote=
><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><span><p dir=
=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span =
style=3D"font-size:14.666666666666666px;font-family:Arial;color:#000000;bac=
kground-color:transparent;font-weight:400;font-style:normal;font-variant:no=
rmal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">I t=
hink another design inspired by older ideas is needed; this is an informal =
starting point.</span></p></span></div></blockquote><div><br>We do not need=
a complete teardown&redesign of concepts in order to resolve either of=
those problems.<br><br>I don't see any particular advantage to your sp=
ecific syntax, relative to implementing one of the fixes for item 2 <a href=
=3D"http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0324r0.html">f=
rom this paper</a>.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line-height:1.38;margi=
n-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.666666666666666px;=
font-family:Arial;color:#000000;background-color:transparent;font-weight:40=
0;font-style:normal;font-variant:normal;text-decoration:none;vertical-align=
:baseline;white-space:pre-wrap">Many different types of requirements can be=
declared:</span></p><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break=
-word"><code><div><span style=3D"color:#008">template</span><span style=3D"=
color:#000"> </span><span style=3D"color:#660"><</span><span style=3D"co=
lor:#008">typename</span><span style=3D"color:#000"> T</span><span style=3D=
"color:#660">></span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#008">concept</span><span style=3D"color:#000"> </span><span style=3D"=
color:#606">Example</span><span style=3D"color:#000"> </span><span style=3D=
"color:#800">//requires ... can inherit constraints from other concepts as =
well as accepting constexpr bools that must be true for success</span><span=
style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span s=
tyle=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#008">int</span><=
span style=3D"color:#000"> T</span><span style=3D"color:#660">::</span><spa=
n style=3D"color:#000">position</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#800">//member variab=
le</span><span style=3D"color:#000"><br>=C2=A0std</span><span style=3D"colo=
r:#660">::</span><span style=3D"color:#000">sort</span><span style=3D"color=
:#660"><</span><span style=3D"color:#000">T</span><span style=3D"color:#=
660">>(</span><span style=3D"color:#000">T</span><span style=3D"color:#6=
60">,</span><span style=3D"color:#000"> T</span><span style=3D"color:#660">=
);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//fr=
ee-standing function </span><span style=3D"color:#000"><br>=C2=A0</span><sp=
an style=3D"color:#008">static</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">int</span><span style=3D"color:#000"> T</span><span=
style=3D"color:#660">::</span><span style=3D"color:#000">static_func</span=
><span style=3D"color:#660">(</span><span style=3D"color:#008">int</span><s=
pan style=3D"color:#000"> foo</span><span style=3D"color:#660">);</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#800">// static member=
functions</span><span style=3D"color:#000"><br>=C2=A0T</span><span style=
=3D"color:#660">::</span><span style=3D"color:#008">typename</span><span st=
yle=3D"color:#000"> size_type</span><span style=3D"color:#660">;</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#800">//member type</sp=
an><span style=3D"color:#000"><br><br></span><span style=3D"color:#660">};<=
/span></div></code></div><p dir=3D"ltr" style=3D"line-height:1.38;margin-to=
p:0pt;margin-bottom:0pt"><span style=3D"font-size:14.6667px;color:rgb(0,0,0=
);background-color:transparent;font-weight:400;font-style:normal;text-decor=
ation:none;vertical-align:baseline;white-space:pre-wrap"><font face=3D"aria=
l, sans-serif">These requirements would not have to be met perfectly, with =
for example a function that accepts variables by value would satisfy a req=
uirement for a function accepting variables by const reference.</font></spa=
n></p></span></div></blockquote><div><br>Issues like that are precisely why=
concepts-TS has constraints defined by <i>expressions</i> on values of tho=
se types, rather than checking for the existence of a particular functions =
or members. That's why the `requires` clause is able to declare that va=
riables of a certain type speculatively exist, so that you can apply expres=
sions to them.<br><br>Your way is far too specific. Concepts are a way of s=
aying, "here are the things I expect to be able to do with the type in=
question.<br><br>Why does it matter for a concept if `T::position` is exac=
tly `int`? Why can't it be `short`? Or any integer type? Or any type wh=
ich conforms to an integer-like concept?<br></div><blockquote class=3D"gmai=
l_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;=
padding-left: 1ex;"><div dir=3D"ltr"><span></span></div></blockquote></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/d21de5a1-1643-4fac-9baa-aca32cafb63a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d21de5a1-1643-4fac-9baa-aca32cafb63a=
%40isocpp.org</a>.<br />
------=_Part_1505_745134686.1479270457379--
------=_Part_1504_798216096.1479270457379--
.
Author: Darius Jankauskas <d5926j@gmail.com>
Date: Wed, 16 Nov 2016 15:43:30 -0800 (PST)
Raw View
------=_Part_3743_790740318.1479339810765
Content-Type: multipart/alternative;
boundary="----=_Part_3744_659056262.1479339810766"
------=_Part_3744_659056262.1479339810766
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Tuesday, November 15, 2016 at 11:27:37 PM UTC-5, Nicol Bolas wrote:
>
> On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankauskas=20
> wrote:
>>
>> We currently have a C++ proposal for Concepts-lite. However, it has=20
>> several issues. First of all, there is no compile-time checking by the=
=20
>> compiler to ensure functions and classes aren=E2=80=99t using functional=
ity of a=20
>> type not specified as a concept. Second of all, the two different forms =
of=20
>> concepts as functions are variable templates are undesirable, as they ha=
ve=20
>> various differences such as that the variable form cannot be overloaded,=
=20
>> but the function form can.=20
>>
> I think another design inspired by older ideas is needed; this is an=20
>> informal starting point.
>>
>
> We do not need a complete teardown&redesign of concepts in order to=20
> resolve either of those problems.
>
> I don't see any particular advantage to your specific syntax, relative to=
=20
> implementing one of the fixes for item 2 from this paper=20
> <http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0324r0.html>.
> =20
>
>> Many different types of requirements can be declared:
>> template <typename T> concept Example //requires ... can inherit=20
>> constraints from other concepts as well as accepting constexpr bools tha=
t=20
>> must be true for success
>> {
>> int T::position; //member variable
>> std::sort<T>(T, T); //free-standing function=20
>> static int T::static_func(int foo); // static member functions
>> T::typename size_type; //member type
>>
>> };
>>
>> These requirements would not have to be met perfectly, with for example =
a=20
>> function that accepts variables by value would satisfy a requirement for=
a=20
>> function accepting variables by const reference.
>>
>
> Issues like that are precisely why concepts-TS has constraints defined by=
=20
> *expressions* on values of those types, rather than checking for the=20
> existence of a particular functions or members. That's why the `requires`=
=20
> clause is able to declare that variables of a certain type speculatively=
=20
> exist, so that you can apply expressions to them.
>
> Your way is far too specific. Concepts are a way of saying, "here are the=
=20
> things I expect to be able to do with the type in question.
>
> Why does it matter for a concept if `T::position` is exactly `int`? Why=
=20
> can't it be `short`? Or any integer type? Or any type which conforms to a=
n=20
> integer-like concept?
>
Your first claim that this complete teardown of concepts isn't necessary=20
for fixing the issue of two different forms of concepts is true; in fact I=
=20
was aware of that proposal already. however, that proposal does not seem to=
=20
have gained any traction among the C++ community, probably because the=20
issues with two different concept forms is not seen to be bad enough that=
=20
change is warranted. The situation is fixed with this proposal as a side=20
effect, not the main reason.
I disagree with your statement that a teardown of the current concepts=20
proposal is not necessary to provide definition checking that is seen by=
=20
many as essential (hence concepts not in C++ 17). In fact, P0240=20
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0240r0.html> expr=
esses=20
the sentiment that it is extremely unlikely that the current system could=
=20
ever have definition checking, and that is just unacceptable. Even if a=20
solution were to be found, it would likely be overly complex and=20
error-prone as understanding what constraint an expression is supposed to=
=20
represent will certainly not be easy or transparent.
As for your final issue, let's redo concept Example:
template <typename T> concept Example
{
Integral T::position; //where Integral is a concept for a type that has=20
the arithmetic operators
//or the long form:
//template <typename X> T::position requires Integral<X>;
//or a variable position of any type:
//auto T::position;
std::sort<T>(T, T); //free-standing function=20
static int T::static_func(int foo); // static member functions
T::typename size_type; //member type
};
With this form of concepts, the flexibility of Concepts-lite is preserved=
=20
but the compiler can (relatively) easily tell what we should be able to do=
=20
with the types. We need definition checking in a concepts system and=20
rethinking Concepts-lite is necessary.=20
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/86bff859-8471-4a39-8eb8-ec7eb5782d12%40isocpp.or=
g.
------=_Part_3744_659056262.1479339810766
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Tuesday, November 15, 2016 at 11:27:37 PM UTC-5=
, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankaus=
kas wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><p=
dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><s=
pan style=3D"font-size:14.666666666666666px;font-family:Arial;color:#000000=
;background-color:transparent;font-weight:400;font-style:normal;font-varian=
t:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"=
>We currently have a C++ proposal for Concepts-lite. However, it has severa=
l issues. First of all, there is no compile-time checking by the compiler t=
o ensure functions and classes aren=E2=80=99t using functionality of a type=
not specified as a concept. Second of all, the two different forms of conc=
epts as functions are variable templates are undesirable, as they have vari=
ous differences such as that the variable form cannot be overloaded, but th=
e function form can.</span>=C2=A0</p></span></div></blockquote><blockquote =
class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #=
ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"=
line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size=
:14.666666666666666px;font-family:Arial;color:#000000;background-color:tran=
sparent;font-weight:400;font-style:normal;font-variant:normal;text-decorati=
on:none;vertical-align:baseline;white-space:pre-wrap">I think another desig=
n inspired by older ideas is needed; this is an informal starting point.</s=
pan></p></span></div></blockquote><div><br>We do not need a complete teardo=
wn&redesign of concepts in order to resolve either of those problems.<b=
r><br>I don't see any particular advantage to your specific syntax, rel=
ative to implementing one of the fixes for item 2 <a href=3D"http://www.ope=
n-std.org/JTC1/SC22/WG21/docs/papers/2016/p0324r0.html" target=3D"_blank" r=
el=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q=
\x3dhttp%3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F20=
16%2Fp0324r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEd7TCCdi1ksjLDZDJ=
8zLH5nVcTrA';return true;" onclick=3D"this.href=3D'http://www.googl=
e.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2F=
papers%2F2016%2Fp0324r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEd7TCC=
di1ksjLDZDJ8zLH5nVcTrA';return true;">from this paper</a>.<br>=C2=A0</d=
iv><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D=
"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span sty=
le=3D"font-size:14.666666666666666px;font-family:Arial;color:#000000;backgr=
ound-color:transparent;font-weight:400;font-style:normal;font-variant:norma=
l;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Many d=
ifferent types of requirements can be declared:</span></p><div style=3D"bac=
kground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:s=
olid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color=
:#008">template</span><span style=3D"color:#000"> </span><span style=3D"col=
or:#660"><</span><span style=3D"color:#008">typename</span><span style=
=3D"color:#000"> T</span><span style=3D"color:#660">></span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">concept</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">Example</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#800">//requires ... can inh=
erit constraints from other concepts as well as accepting constexpr bools t=
hat must be true for success</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0</spa=
n><span style=3D"color:#008">int</span><span style=3D"color:#000"> T</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#000">position</sp=
an><span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#800">//member variable</span><span style=3D"color:#000"=
><br>=C2=A0std</span><span style=3D"color:#660">::</span><span style=3D"col=
or:#000">sort</span><span style=3D"color:#660"><</span><span style=3D"co=
lor:#000">T</span><span style=3D"color:#660">>(</span><span style=3D"col=
or:#000">T</span><span style=3D"color:#660">,</span><span style=3D"color:#0=
00"> T</span><span style=3D"color:#660">);</span><span style=3D"color:#000"=
> </span><span style=3D"color:#800">//free-standing function </span><span s=
tyle=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#008">static</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#008">int</span><=
span style=3D"color:#000"> T</span><span style=3D"color:#660">::</span><spa=
n style=3D"color:#000">static_func</span><span style=3D"color:#660">(</span=
><span style=3D"color:#008">int</span><span style=3D"color:#000"> foo</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#800">// static member functions</span><span style=3D"col=
or:#000"><br>=C2=A0T</span><span style=3D"color:#660">::</span><span style=
=3D"color:#008">typename</span><span style=3D"color:#000"> size_type</span>=
<span style=3D"color:#660">;</span><span style=3D"color:#000"> </span><span=
style=3D"color:#800">//member type</span><span style=3D"color:#000"><br><b=
r></span><span style=3D"color:#660">};</span></div></code></div><p dir=3D"l=
tr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=
=3D"font-size:14.6667px;color:rgb(0,0,0);background-color:transparent;font-=
weight:400;font-style:normal;text-decoration:none;vertical-align:baseline;w=
hite-space:pre-wrap"><font face=3D"arial, sans-serif">These requirements wo=
uld not have to be met perfectly, with for example a function that accepts =
variables by value would satisfy a requirement for a function accepting va=
riables by const reference.</font></span></p></span></div></blockquote><div=
><br>Issues like that are precisely why concepts-TS has constraints defined=
by <i>expressions</i> on values of those types, rather than checking for t=
he existence of a particular functions or members. That's why the `requ=
ires` clause is able to declare that variables of a certain type speculativ=
ely exist, so that you can apply expressions to them.<br><br>Your way is fa=
r too specific. Concepts are a way of saying, "here are the things I e=
xpect to be able to do with the type in question.<br><br>Why does it matter=
for a concept if `T::position` is exactly `int`? Why can't it be `shor=
t`? Or any integer type? Or any type which conforms to an integer-like conc=
ept?<br></div></div></blockquote><div>Your first claim that this complete t=
eardown of concepts isn't necessary for fixing the issue of two differe=
nt forms of concepts is true; in fact I was aware of that proposal already.=
however, that proposal does not seem to have gained any traction among the=
C++ community, probably because the issues with two different concept form=
s is not seen to be bad enough that change is warranted. The situation is f=
ixed with this proposal as a side effect, not the main reason.</div><div>I =
disagree with your statement that a teardown of the current concepts propos=
al is not necessary to provide =C2=A0definition checking that is seen by ma=
ny as essential (hence concepts not in C++ 17). In fact,=C2=A0<a href=3D"ht=
tp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0240r0.html">P0240</=
a>=C2=A0expresses the sentiment that it is extremely unlikely that the curr=
ent system could ever have definition checking, and that is just unacceptab=
le. Even if a solution were to be found, it would likely be overly complex =
and error-prone=C2=A0as understanding what constraint an expression is supp=
osed to represent will certainly not be easy or transparent.</div><div>As f=
or your final issue, let's redo concept Example:</div><div><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: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">template</span></span><span style=3D"color: rgb(0, 0, 0);"=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><=
span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><</span></span><span style=3D"color: rgb(0, 0, 1=
36);"><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</s=
pan></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> T</span></span><span style=3D"color: rgb(10=
2, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">>=
</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: rgb(=
0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prettify">conc=
ept</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: r=
gb(102, 0, 102);"><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Example</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span></span><span style=3D"=
color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0</span><span style=3D=
"color: #606;" class=3D"styled-by-prettify">Integral</span></span><span sty=
le=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> T</span></span><span style=3D"color: rgb(102, 102, 0);"><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span></span><span st=
yle=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">position</span></span><span style=3D"color: rgb(102, 102, 0);">=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">//where Integral is a concept for a=
type that has the arithmetic operators</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span></span><span style=3D"color: rgb(0,=
0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0</=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">//or the lon=
g form:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>=C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-prettify">//t=
emplate <typename X> T::position requires Integral<X>;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0</span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">//or a variable pos=
ition of any type:</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>=C2=A0</span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">//auto T::position;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>=C2=A0std</span></span><span style=3D"color: rgb(102, =
102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" =
class=3D"styled-by-prettify">sort</span></span><span style=3D"color: rgb(10=
2, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">T</span></span><span style=3D"color: rgb(=
102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;(</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
#000;" class=3D"styled-by-prettify">T</span></span><span style=3D"color: r=
gb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>,</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> T</span></span><span style=3D"color: r=
gb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>);</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: r=
gb(136, 0, 0);"><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/free-standing function </span></span><span style=3D"color: rgb(0, 0, 0);">=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0</span>=
</span><span style=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;" =
class=3D"styled-by-prettify">static</span></span><span style=3D"color: rgb(=
0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n></span><span style=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">int</span></span><span style=3D"color: rgb(0=
, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</spa=
n></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">::</span></span><span style=3D"color: rgb(=
0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify">static=
_func</span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span></span><span style=3D"co=
lor: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">int</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> foo</span></span><span style=3D"=
color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span style=
=3D"color: rgb(136, 0, 0);"><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// static member functions</span></span><span style=3D"color: rg=
b(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0T</span></span><span style=3D"color: rgb(102, 102, 0);"><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span></span><span style=
=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">typename</span></span><span style=3D"color: rgb(0, 0, 0);"><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> size_type</span></spa=
n><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span></span><span style=3D"color: rgb(0, 0, 0)=
;"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></span=
><span style=3D"color: rgb(136, 0, 0);"><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//member type</span></span><span style=3D"color: rg=
b(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br></span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">};</span></span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span></div></code></div>With=
this form of concepts, the flexibility of Concepts-lite is preserved but t=
he compiler can (relatively) easily tell what we should be able to do with =
the types. We need definition checking in a concepts system and rethinking =
Concepts-lite is necessary.=C2=A0</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/86bff859-8471-4a39-8eb8-ec7eb5782d12%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/86bff859-8471-4a39-8eb8-ec7eb5782d12=
%40isocpp.org</a>.<br />
------=_Part_3744_659056262.1479339810766--
------=_Part_3743_790740318.1479339810765--
.
Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Wed, 16 Nov 2016 16:23:10 -0800 (PST)
Raw View
------=_Part_5374_1926044243.1479342190839
Content-Type: multipart/alternative;
boundary="----=_Part_5375_407100687.1479342190839"
------=_Part_5375_407100687.1479342190839
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, November 16, 2016 at 3:43:30 PM UTC-8, Darius Jankauskas=20
wrote:
>
> On Tuesday, November 15, 2016 at 11:27:37 PM UTC-5, Nicol Bolas wrote:
>>
>> On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankauskas=20
>> wrote:
>>>
>>> We currently have a C++ proposal for Concepts-lite. However, it has=20
>>> several issues.=20
>>>
>> [...]
>>
>>> Many different types of requirements can be declared:
>>> template <typename T> concept Example //requires ... can inherit=20
>>> constraints from other concepts as well as accepting constexpr bools th=
at=20
>>> must be true for success
>>> {
>>> int T::position; //member variable
>>> std::sort<T>(T, T); //free-standing function=20
>>> static int T::static_func(int foo); // static member functions
>>> T::typename size_type; //member type
>>>
>>> };
>>>
>>> These requirements would not have to be met perfectly, with for example=
=20
>>> a function that accepts variables by value would satisfy a requirement =
for=20
>>> a function accepting variables by const reference.
>>>
>>
>> Issues like that are precisely why concepts-TS has constraints defined b=
y=20
>> *expressions* on values of those types, rather than checking for the=20
>> existence of a particular functions or members. That's why the `requires=
`=20
>> clause is able to declare that variables of a certain type speculatively=
=20
>> exist, so that you can apply expressions to them.
>>
>> Your way is far too specific. Concepts are a way of saying, "here are th=
e=20
>> things I expect to be able to do with the type in question.
>>
>> Why does it matter for a concept if `T::position` is exactly `int`? Why=
=20
>> can't it be `short`? Or any integer type? Or any type which conforms to =
an=20
>> integer-like concept?
>>
> [...]=20
> As for your final issue, let's redo concept Example:
> template <typename T> concept Example
> {
> Integral T::position; //where Integral is a concept for a type that has=
=20
> the arithmetic operators
> //or the long form:
> //template <typename X> T::position requires Integral<X>;
> //or a variable position of any type:
> //auto T::position;
> std::sort<T>(T, T); //free-standing function=20
> static int T::static_func(int foo); // static member functions
> T::typename size_type; //member type
>
> };
> With this form of concepts, the flexibility of Concepts-lite is preserved=
=20
> but the compiler can (relatively) easily tell what we should be able to d=
o=20
> with the types. We need definition checking in a concepts system and=20
> rethinking Concepts-lite is necessary.
>
I agree with Nicol that your idea is fundamentally unworkable (well,=20
unworkable without a LOT of additional explanation and specification) =E2=
=80=94=20
which I think is what you meant by "(relatively) easy". You say potato, I=
=20
say potato. ;)
I'd like to see how you would implement a concept in your proposed syntax=
=20
that has the same semantics (or even just "close enough" semantics) to the=
=20
following Concepts-Lite concept:
template <typename T> concept
bool LessThanComparable() {
return requires(T a, T b) { {a < b} -> bool;} };
}
It needs to match at least the following types:
- int (comparison provided by built-in operator)
- std::string (comparison provided by non-member function template)
- any RandomAccessIterator (comparison provided by unspecified means,=20
possibly a member function or member function template)
- any type whose operator< returns a YesNo, where YesNo is not bool but is=
=20
contextually convertible thereto: http://stackoverflow.com/a/8014673/142487=
7
Now, I don't think that the Concepts-Lite syntax of requires(T a, T=20
b){{a<b}->bool;} is the best syntax for the job; I'd prefer something more=
=20
like requires(T a, T=20
b)std::is_contextually_convertible_to_bool_v<decltype(a<b)> (where SFINAE=
=20
within the boolean constant-expression) or simply requires(T a, T=20
b){if(a<b);}. (where SFINAE within the braced function-body and if there's=
=20
no substitution failure then the concept matches). But I can't imagine how=
=20
you'd express the same concept in your proposed syntax; yours just doesn't=
=20
seem expressive enough.
Concepts-Lite syntax *can* express concepts like "has a member variable foo=
=20
of type exactly int" or "has a member function bar with this exact=20
signature" using the detection idiom =E2=80=94 but I don't think anyone sho=
uld=20
*want* to express such concepts. They don't enable generic programming, so=
=20
what's the point? I'd go so far as to say that anyone who thinks their=20
program could benefit from such a restricted "concept" would be better off=
=20
just using a typedef (if there is only one reasonable candidate type=20
matching your "concept") or an inheritance hierarchy (if there are several=
=20
candidate types but they necessarily have exactly the same public method=20
signatures).
=E2=80=93Arthur
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/907a8e54-054b-4e9d-b56d-899e235d57f7%40isocpp.or=
g.
------=_Part_5375_407100687.1479342190839
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, November 16, 2016 at 3:43:30 PM UTC-8, Dariu=
s Jankauskas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr">On Tuesday, November 15, 2016 at 11:27:37 PM UTC-5, Nicol Bolas wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Tuesday, Novem=
ber 15, 2016 at 10:33:55 PM UTC-5, Darius Jankauskas wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line=
-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.=
666666666666666px;font-family:Arial;color:#000000;background-color:transpar=
ent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:n=
one;vertical-align:baseline;white-space:pre-wrap">We currently have a C++ p=
roposal for Concepts-lite. However, it has several issues. </span></p></spa=
n></div></blockquote><div>=C2=A0[...]</div><blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line-height:1.38;mar=
gin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.666666666666666p=
x;font-family:Arial;color:#000000;background-color:transparent;font-weight:=
400;font-style:normal;font-variant:normal;text-decoration:none;vertical-ali=
gn:baseline;white-space:pre-wrap">Many different types of requirements can =
be declared:</span></p><div style=3D"background-color:rgb(250,250,250);bord=
er-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:bre=
ak-word"><code><div><span style=3D"color:#008">template</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660"><</span><span style=
=3D"color:#008">typename</span><span style=3D"color:#000"> T</span><span st=
yle=3D"color:#660">></span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">concept</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#606">Example</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#800">//requires ... can inherit constraints from other concep=
ts as well as accepting constexpr bools that must be true for success</span=
><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#008">int</=
span><span style=3D"color:#000"> T</span><span style=3D"color:#660">::</spa=
n><span style=3D"color:#000">position</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#800">//member =
variable</span><span style=3D"color:#000"><br>=C2=A0std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">sort</span><span style=
=3D"color:#660"><</span><span style=3D"color:#000">T</span><span style=
=3D"color:#660">>(</span><span style=3D"color:#000">T</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> T</span><span style=3D"=
color:#660">);</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#800">//free-standing function </span><span style=3D"color:#000"><br>=C2=
=A0</span><span style=3D"color:#008">static</span><span style=3D"color:#000=
"> </span><span style=3D"color:#008">int</span><span style=3D"color:#000"> =
T</span><span style=3D"color:#660">::</span><span style=3D"color:#000">stat=
ic_func</span><span style=3D"color:#660">(</span><span style=3D"color:#008"=
>int</span><span style=3D"color:#000"> foo</span><span style=3D"color:#660"=
>);</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// =
static member functions</span><span style=3D"color:#000"><br>=C2=A0T</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#008">typename</sp=
an><span style=3D"color:#000"> size_type</span><span style=3D"color:#660">;=
</span><span style=3D"color:#000"> </span><span style=3D"color:#800">//memb=
er type</span><span style=3D"color:#000"><br><br></span><span style=3D"colo=
r:#660">};</span></div></code></div><p dir=3D"ltr" style=3D"line-height:1.3=
8;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.6667px;colo=
r:rgb(0,0,0);background-color:transparent;font-weight:400;font-style:normal=
;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><font f=
ace=3D"arial, sans-serif">These requirements would not have to be met perfe=
ctly, with for example a function that accepts variables by value would sa=
tisfy a requirement for a function accepting variables by const reference.<=
/font></span></p></span></div></blockquote><div><br>Issues like that are pr=
ecisely why concepts-TS has constraints defined by <i>expressions</i> on va=
lues of those types, rather than checking for the existence of a particular=
functions or members. That's why the `requires` clause is able to decl=
are that variables of a certain type speculatively exist, so that you can a=
pply expressions to them.<br><br>Your way is far too specific. Concepts are=
a way of saying, "here are the things I expect to be able to do with =
the type in question.<br><br>Why does it matter for a concept if `T::positi=
on` is exactly `int`? Why can't it be `short`? Or any integer type? Or =
any type which conforms to an integer-like concept?<br></div></div></blockq=
uote><div></div></div></blockquote><div>[...]=C2=A0<br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px =
#ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>As for your final issu=
e, let's redo concept Example:<br></div><div><div style=3D"background-c=
olor:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bord=
er-width:1px;word-wrap:break-word"><code><div><span style=3D"color:rgb(0,0,=
136)"><span style=3D"color:#008">template</span></span><span style=3D"color=
:rgb(0,0,0)"><span style=3D"color:#000"> </span></span><span style=3D"color=
:rgb(102,102,0)"><span style=3D"color:#660"><</span></span><span style=
=3D"color:rgb(0,0,136)"><span style=3D"color:#008">typename</span></span><s=
pan style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> T</span></span><=
span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">></span><=
/span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> </span><=
/span><span style=3D"color:rgb(0,0,136)"><span style=3D"color:#008">concept=
</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> =
</span></span><span style=3D"color:rgb(102,0,102)"><span style=3D"color:#60=
6">Example</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"col=
or:#000"><br></span></span><span style=3D"color:rgb(102,102,0)"><span style=
=3D"color:#660">{</span></span><span style=3D"color:rgb(0,0,0)"><span style=
=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#606">Integral</span>=
</span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> T</span=
></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::<=
/span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">po=
sition</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"col=
or:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#8=
00">//where Integral is a concept for a type that has the arithmetic operat=
ors</span><span style=3D"color:#000"><br></span></span><span style=3D"color=
:rgb(0,0,0)"><span style=3D"color:#000">=C2=A0</span><span style=3D"color:#=
800">//or the long form:</span><span style=3D"color:#000"><br>=C2=A0</span>=
<span style=3D"color:#800">//template <typename X> T::position requir=
es Integral<X>;</span><span style=3D"color:#000"><br>=C2=A0</span><sp=
an style=3D"color:#800">//or a variable position of any type:</span><span s=
tyle=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#800">//auto T::p=
osition;</span><span style=3D"color:#000"><br>=C2=A0std</span></span><span =
style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::</span></span><=
span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">sort</span></spa=
n><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660"><</spa=
n></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">T</spa=
n></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">&g=
t;(</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000=
">T</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:=
#660">,</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:=
#000"> T</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"c=
olor:#660">);</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"=
color:#000"> </span></span><span style=3D"color:rgb(136,0,0)"><span style=
=3D"color:#800">//free-standing function </span></span><span style=3D"color=
:rgb(0,0,0)"><span style=3D"color:#000"><br>=C2=A0</span></span><span style=
=3D"color:rgb(0,0,136)"><span style=3D"color:#008">static</span></span><spa=
n style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> </span></span><spa=
n style=3D"color:rgb(0,0,136)"><span style=3D"color:#008">int</span></span>=
<span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> T</span></span=
><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::</span><=
/span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">static_fu=
nc</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#=
660">(</span></span><span style=3D"color:rgb(0,0,136)"><span style=3D"color=
:#008">int</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"col=
or:#000"> foo</span></span><span style=3D"color:rgb(102,102,0)"><span style=
=3D"color:#660">);</span></span><span style=3D"color:rgb(0,0,0)"><span styl=
e=3D"color:#000"> </span></span><span style=3D"color:rgb(136,0,0)"><span st=
yle=3D"color:#800">// static member functions</span></span><span style=3D"c=
olor:rgb(0,0,0)"><span style=3D"color:#000"><br>=C2=A0T</span></span><span =
style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::</span></span><=
span style=3D"color:rgb(0,0,136)"><span style=3D"color:#008">typename</span=
></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> size_t=
ype</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:=
#660">;</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:=
#000"> </span></span><span style=3D"color:rgb(136,0,0)"><span style=3D"colo=
r:#800">//member type</span></span><span style=3D"color:rgb(0,0,0)"><span s=
tyle=3D"color:#000"><br><br></span></span><span style=3D"color:rgb(102,102,=
0)"><span style=3D"color:#660">};</span></span><span style=3D"color:#000"><=
br></span></div></code></div>With this form of concepts, the flexibility of=
Concepts-lite is preserved but the compiler can (relatively) easily tell w=
hat we should be able to do with the types. We need definition checking in =
a concepts system and rethinking Concepts-lite is necessary.</div></div></b=
lockquote><div><br></div><div>I agree with Nicol that your idea is fundamen=
tally unworkable (well, unworkable without a LOT of additional explanation =
and specification) =E2=80=94 which I think is what you meant by "(rela=
tively) easy". You say potato, I say potato. ;)</div><div><br></div><d=
iv>I'd like to see how you would implement a concept in your proposed s=
yntax that has the same semantics (or even just "close enough" se=
mantics) to the following Concepts-Lite concept:</div><div><br></div><div><=
span style=3D"font-family: monospace; color: rgb(0, 0, 136);">template</spa=
n><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=C2=A0</span=
><span style=3D"font-family: monospace; color: rgb(102, 102, 0);"><</spa=
n><span style=3D"font-family: monospace; color: rgb(0, 0, 136);">typename</=
span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=C2=A0T</=
span><span style=3D"font-family: monospace; color: rgb(102, 102, 0);">><=
/span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=C2=A0</=
span><span style=3D"font-family: monospace; color: rgb(0, 0, 136);">concept=
</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);"><br></s=
pan><span style=3D"font-family: monospace; color: rgb(0, 0, 136);">bool</sp=
an><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=C2=A0</spa=
n><span style=3D"font-family: monospace; color: rgb(102, 0, 102);">LessThan=
Comparable</span><span style=3D"font-family: monospace; color: rgb(102, 102=
, 0);">()</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);=
">=C2=A0</span><span style=3D"font-family: monospace; color: rgb(102, 102, =
0);">{</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);"><=
br>=C2=A0</span><span style=3D"font-family: monospace; color: rgb(0, 0, 136=
);">return</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0)=
;">=C2=A0requires</span><span style=3D"font-family: monospace; color: rgb(1=
02, 102, 0);">(</span><span style=3D"font-family: monospace; color: rgb(0, =
0, 0);">T a</span><span style=3D"font-family: monospace; color: rgb(102, 10=
2, 0);">,</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);=
">=C2=A0T b</span><span style=3D"font-family: monospace; color: rgb(102, 10=
2, 0);">)</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);=
">=C2=A0</span><span style=3D"font-family: monospace; color: rgb(102, 102, =
0);">{</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=
=C2=A0</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0)=
;">{</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">a=
=C2=A0</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0)=
;"><</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=
=C2=A0b</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0=
);">}</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=
=C2=A0</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0)=
;">-></span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);"=
>=C2=A0</span><span style=3D"font-family: monospace; color: rgb(0, 0, 136);=
">bool</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0)=
;">;}</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);">=
=C2=A0</span><span style=3D"font-family: monospace; color: rgb(102, 102, 0)=
;">};</span><span style=3D"font-family: monospace; color: rgb(0, 0, 0);"><b=
r></span><span style=3D"font-family: monospace; color: rgb(102, 102, 0);">}=
</span><br></div><div><br></div><div>It needs to match at least the followi=
ng types:<br></div><div>- int (comparison provided by built-in operator)</d=
iv><div>- std::string (comparison provided by non-member function template)=
</div><div>- any RandomAccessIterator (comparison provided by unspecified m=
eans, possibly a member function or member function template)</div><div>- a=
ny type whose operator< returns a YesNo, where YesNo is not bool but is =
contextually convertible thereto: <a href=3D"http://stackoverflow.com/a/801=
4673/1424877">http://stackoverflow.com/a/8014673/1424877</a></div><div><br>=
</div><div>Now, I don't think that the Concepts-Lite syntax of <font fa=
ce=3D"courier new, monospace">requires(T a, T b){{a<b}->bool;}</font>=
=C2=A0is the best syntax for the job; I'd prefer something more like <f=
ont face=3D"courier new, monospace">requires(T a, T b)std::is_contextually_=
convertible_to_bool_v<decltype(a<b)></font>=C2=A0(where SFINAE wit=
hin the boolean constant-expression) or simply <font face=3D"courier new, m=
onospace">requires(T a, T b){if(a<b);}</font>. (where SFINAE within the =
braced function-body and if there's no substitution failure then the co=
ncept matches). But I can't imagine how you'd express the same conc=
ept in your proposed syntax; yours just doesn't seem expressive enough.=
</div><div><br></div><div>Concepts-Lite syntax <i>can</i> express concepts =
like "has a member variable foo of type exactly int" or "has=
a member function bar with this exact signature" using the detection =
idiom =E2=80=94 but I don't think anyone should <i>want</i> to express =
such concepts. They don't enable generic programming, so what's the=
point? I'd go so far as to say that anyone who thinks their program co=
uld benefit from such a restricted "concept" would be better off =
just using a typedef (if there is only one reasonable candidate type matchi=
ng your "concept") or an inheritance hierarchy (if there are seve=
ral candidate types but they necessarily have exactly the same public metho=
d signatures).</div><div><br></div><div>=E2=80=93Arthur</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/907a8e54-054b-4e9d-b56d-899e235d57f7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/907a8e54-054b-4e9d-b56d-899e235d57f7=
%40isocpp.org</a>.<br />
------=_Part_5375_407100687.1479342190839--
------=_Part_5374_1926044243.1479342190839--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 16 Nov 2016 20:33:02 -0800 (PST)
Raw View
------=_Part_5435_1657071106.1479357182799
Content-Type: multipart/alternative;
boundary="----=_Part_5436_1238260307.1479357182800"
------=_Part_5436_1238260307.1479357182800
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, November 16, 2016 at 6:43:30 PM UTC-5, Darius Jankauskas=20
wrote:
>
>
>
> On Tuesday, November 15, 2016 at 11:27:37 PM UTC-5, Nicol Bolas wrote:
>>
>> On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankauskas=20
>> wrote:
>>>
>>> We currently have a C++ proposal for Concepts-lite. However, it has=20
>>> several issues. First of all, there is no compile-time checking by the=
=20
>>> compiler to ensure functions and classes aren=E2=80=99t using functiona=
lity of a=20
>>> type not specified as a concept. Second of all, the two different forms=
of=20
>>> concepts as functions are variable templates are undesirable, as they h=
ave=20
>>> various differences such as that the variable form cannot be overloaded=
,=20
>>> but the function form can.=20
>>>
>> I think another design inspired by older ideas is needed; this is an=20
>>> informal starting point.
>>>
>>
>> We do not need a complete teardown&redesign of concepts in order to=20
>> resolve either of those problems.
>>
>> I don't see any particular advantage to your specific syntax, relative t=
o=20
>> implementing one of the fixes for item 2 from this paper=20
>> <http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2016/p0324r0.html>.
>> =20
>>
>>> Many different types of requirements can be declared:
>>> template <typename T> concept Example //requires ... can inherit=20
>>> constraints from other concepts as well as accepting constexpr bools th=
at=20
>>> must be true for success
>>> {
>>> int T::position; //member variable
>>> std::sort<T>(T, T); //free-standing function=20
>>> static int T::static_func(int foo); // static member functions
>>> T::typename size_type; //member type
>>>
>>> };
>>>
>>> These requirements would not have to be met perfectly, with for example=
=20
>>> a function that accepts variables by value would satisfy a requirement =
for=20
>>> a function accepting variables by const reference.
>>>
>>
>> Issues like that are precisely why concepts-TS has constraints defined b=
y=20
>> *expressions* on values of those types, rather than checking for the=20
>> existence of a particular functions or members. That's why the `requires=
`=20
>> clause is able to declare that variables of a certain type speculatively=
=20
>> exist, so that you can apply expressions to them.
>>
>> Your way is far too specific. Concepts are a way of saying, "here are th=
e=20
>> things I expect to be able to do with the type in question.
>>
>> Why does it matter for a concept if `T::position` is exactly `int`? Why=
=20
>> can't it be `short`? Or any integer type? Or any type which conforms to =
an=20
>> integer-like concept?
>>
> Your first claim that this complete teardown of concepts isn't necessary=
=20
> for fixing the issue of two different forms of concepts is true; in fact =
I=20
> was aware of that proposal already. however, that proposal does not seem =
to=20
> have gained any traction among the C++ community, probably because the=20
> issues with two different concept forms is not seen to be bad enough that=
=20
> change is warranted.
>
I am not aware of any information on how the proposal was received by the=
=20
committee. Do you have any links to information about this?
Furthermore, if the C++ standards committee genuinely thinks that having=20
two different concept forms is just fine, why do you think they'll consider=
=20
your *complete rewrite* of concepts? If they're not willing to do minor=20
refactoring of one element of the syntax, they're certainly not going to do=
=20
a page-one rewrite.
The situation is fixed with this proposal as a side effect, not the main=20
> reason.
> I disagree with your statement that a teardown of the current concepts=20
> proposal is not necessary to provide definition checking that is seen by=
=20
> many as essential (hence concepts not in C++ 17). In fact, P0240=20
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0240r0.html> ex=
presses=20
> the sentiment that it is extremely unlikely that the current system could=
=20
> ever have definition checking, and that is just unacceptable. Even if a=
=20
> solution were to be found, it would likely be overly complex and=20
> error-prone as understanding what constraint an expression is supposed to=
=20
> represent will certainly not be easy or transparent.
>
The people behind concepts TS do not agree with either assessment. They=20
don't think it would be "extremely unlikely" to work, and they don't feel=
=20
that it would be "overly complex and error-prone".
I agree with your assessment that definition checking is important. But the=
=20
people who know the most about concepts lite seem to think that it is very=
=20
doable with the general design they currently have.
Though the fact that they haven't actually drawn up even a draft proposal=
=20
yet, nor do they seem particularly inclined to do so, is disconcerting.
As for your final issue, let's redo concept Example:
> template <typename T> concept Example
> {
> Integral T::position; //where Integral is a concept for a type that has=
=20
> the arithmetic operators
> //or the long form:
> //template <typename X> T::position requires Integral<X>;
> //or a variable position of any type:
> //auto T::position;
> std::sort<T>(T, T); //free-standing function=20
> static int T::static_func(int foo); // static member functions
> T::typename size_type; //member type
>
> };
> With this form of concepts, the flexibility of Concepts-lite is preserved
>
I fail to see any flexibility here.
It's hard to know how to respond to your example, because it's not actually=
=20
an example of a useful concept. It's just a bunch of tests, with no real=20
meaning to them. For example, why does this concept care that `static_func`=
=20
is actually a `static` function? Why can't it be a non-static function? Or=
=20
even a `virtual` function? Why does it care that it returns an `int` and=20
takes an `int`? Again, why not `short`, `char`, `long` or anything else?
What seems clear to me is that the equivalent concepts-lite expressions are=
=20
more flexible *by default* than your version. Your versions over-constrain=
=20
things, requiring additional syntax to permit more generic constructs. By=
=20
contrast, concepts-lite is always generic, only using explicit types when=
=20
you specifically ask for it.
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/2443c705-d25d-4013-adfc-84605a4aeb46%40isocpp.or=
g.
------=_Part_5436_1238260307.1479357182800
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, November 16, 2016 at 6:43:30 PM UTC-=
5, Darius Jankauskas wrote:<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr"><br><br>On Tuesday, November 15, 2016 at 11:27:37 PM UTC-5, N=
icol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin=
-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">O=
n Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankauskas wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"lt=
r" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=
=3D"font-size:14.666666666666666px;font-family:Arial;color:#000000;backgrou=
nd-color:transparent;font-weight:400;font-style:normal;font-variant:normal;=
text-decoration:none;vertical-align:baseline;white-space:pre-wrap">We curre=
ntly have a C++ proposal for Concepts-lite. However, it has several issues.=
First of all, there is no compile-time checking by the compiler to ensure =
functions and classes aren=E2=80=99t using functionality of a type not spec=
ified as a concept. Second of all, the two different forms of concepts as f=
unctions are variable templates are undesirable, as they have various diffe=
rences such as that the variable form cannot be overloaded, but the functio=
n form can.</span>=C2=A0</p></span></div></blockquote><blockquote class=3D"=
gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid=
;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line-heig=
ht:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.66666=
6666666666px;font-family:Arial;color:#000000;background-color:transparent;f=
ont-weight:400;font-style:normal;font-variant:normal;text-decoration:none;v=
ertical-align:baseline;white-space:pre-wrap">I think another design inspire=
d by older ideas is needed; this is an informal starting point.</span></p><=
/span></div></blockquote><div><br>We do not need a complete teardown&re=
design of concepts in order to resolve either of those problems.<br><br>I d=
on't see any particular advantage to your specific syntax, relative to =
implementing one of the fixes for item 2 <a href=3D"http://www.open-std.org=
/JTC1/SC22/WG21/docs/papers/2016/p0324r0.html" rel=3D"nofollow" target=3D"_=
blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%=
3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016%2Fp032=
4r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEd7TCCdi1ksjLDZDJ8zLH5nVcT=
rA';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\x3dhttp%3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F=
2016%2Fp0324r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEd7TCCdi1ksjLDZ=
DJ8zLH5nVcTrA';return true;">from this paper</a>.<br>=C2=A0</div><block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" sty=
le=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"fon=
t-size:14.666666666666666px;font-family:Arial;color:#000000;background-colo=
r:transparent;font-weight:400;font-style:normal;font-variant:normal;text-de=
coration:none;vertical-align:baseline;white-space:pre-wrap">Many different =
types of requirements can be declared:</span></p><div style=3D"background-c=
olor:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bord=
er-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">te=
mplate</span><span style=3D"color:#000"> </span><span style=3D"color:#660">=
<</span><span style=3D"color:#008">typename</span><span style=3D"color:#=
000"> T</span><span style=3D"color:#660">></span><span style=3D"color:#0=
00"> </span><span style=3D"color:#008">concept</span><span style=3D"color:#=
000"> </span><span style=3D"color:#606">Example</span><span style=3D"color:=
#000"> </span><span style=3D"color:#800">//requires ... can inherit constra=
ints from other concepts as well as accepting constexpr bools that must be =
true for success</span><span style=3D"color:#000"><br></span><span style=3D=
"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0</span><span styl=
e=3D"color:#008">int</span><span style=3D"color:#000"> T</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">position</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">//member variable</span><span style=3D"color:#000"><br>=C2=
=A0std</span><span style=3D"color:#660">::</span><span style=3D"color:#000"=
>sort</span><span style=3D"color:#660"><</span><span style=3D"color:#000=
">T</span><span style=3D"color:#660">>(</span><span style=3D"color:#000"=
>T</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> T</=
span><span style=3D"color:#660">);</span><span style=3D"color:#000"> </span=
><span style=3D"color:#800">//free-standing function </span><span style=3D"=
color:#000"><br>=C2=A0</span><span style=3D"color:#008">static</span><span =
style=3D"color:#000"> </span><span style=3D"color:#008">int</span><span sty=
le=3D"color:#000"> T</span><span style=3D"color:#660">::</span><span style=
=3D"color:#000">static_func</span><span style=3D"color:#660">(</span><span =
style=3D"color:#008">int</span><span style=3D"color:#000"> foo</span><span =
style=3D"color:#660">);</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#800">// static member functions</span><span style=3D"color:#000=
"><br>=C2=A0T</span><span style=3D"color:#660">::</span><span style=3D"colo=
r:#008">typename</span><span style=3D"color:#000"> size_type</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">//member type</span><span style=3D"color:#000"><br><br></sp=
an><span style=3D"color:#660">};</span></div></code></div><p dir=3D"ltr" st=
yle=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"fo=
nt-size:14.6667px;color:rgb(0,0,0);background-color:transparent;font-weight=
:400;font-style:normal;text-decoration:none;vertical-align:baseline;white-s=
pace:pre-wrap"><font face=3D"arial, sans-serif">These requirements would no=
t have to be met perfectly, with for example a function that accepts varia=
bles by value would satisfy a requirement for a function accepting variable=
s by const reference.</font></span></p></span></div></blockquote><div><br>I=
ssues like that are precisely why concepts-TS has constraints defined by <i=
>expressions</i> on values of those types, rather than checking for the exi=
stence of a particular functions or members. That's why the `requires` =
clause is able to declare that variables of a certain type speculatively ex=
ist, so that you can apply expressions to them.<br><br>Your way is far too =
specific. Concepts are a way of saying, "here are the things I expect =
to be able to do with the type in question.<br><br>Why does it matter for a=
concept if `T::position` is exactly `int`? Why can't it be `short`? Or=
any integer type? Or any type which conforms to an integer-like concept?<b=
r></div></div></blockquote><div>Your first claim that this complete teardow=
n of concepts isn't necessary for fixing the issue of two different for=
ms of concepts is true; in fact I was aware of that proposal already. howev=
er, that proposal does not seem to have gained any traction among the C++ c=
ommunity, probably because the issues with two different concept forms is n=
ot seen to be bad enough that change is warranted.</div></div></blockquote>=
<div><br>I am not aware of any information on how the proposal was received=
by the committee. Do you have any links to information about this?<br><br>=
Furthermore, if the C++ standards committee genuinely thinks that having tw=
o different concept forms is just fine, why do you think they'll consid=
er your <i>complete rewrite</i> of concepts? If they're not willing to =
do minor refactoring of one element of the syntax, they're certainly no=
t going to do a page-one rewrite.<br><br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;pad=
ding-left: 1ex;"><div dir=3D"ltr"><div>The situation is fixed with this pro=
posal as a side effect, not the main reason.</div><div>I disagree with your=
statement that a teardown of the current concepts proposal is not necessar=
y to provide =C2=A0definition checking that is seen by many as essential (h=
ence concepts not in C++ 17). In fact,=C2=A0<a href=3D"http://www.open-std.=
org/jtc1/sc22/wg21/docs/papers/2016/p0240r0.html" target=3D"_blank" rel=3D"=
nofollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dht=
tp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp=
0240r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFUvnS8tPvyS8v0zv_-e046r=
Xnxhw';return true;" onclick=3D"this.href=3D'http://www.google.com/=
url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers=
%2F2016%2Fp0240r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFUvnS8tPvyS8=
v0zv_-e046rXnxhw';return true;">P0240</a>=C2=A0expresses the sentiment =
that it is extremely unlikely that the current system could ever have defin=
ition checking, and that is just unacceptable. Even if a solution were to b=
e found, it would likely be overly complex and error-prone=C2=A0as understa=
nding what constraint an expression is supposed to represent will certainly=
not be easy or transparent.</div></div></blockquote><div><br>The people be=
hind concepts TS do not agree with either assessment. They don't think =
it would be "extremely unlikely" to work, and they don't feel=
that it would be "overly complex and error-prone".<br><br>I agre=
e with your assessment that definition checking is important. But the peopl=
e who know the most about concepts lite seem to think that it is very doabl=
e with the general design they currently have.<br><br>Though the fact that =
they haven't actually drawn up even a draft proposal yet, nor do they s=
eem particularly inclined to do so, is disconcerting.<br><br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>As for your fina=
l issue, let's redo concept Example:</div><div><div style=3D"background=
-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;bo=
rder-width:1px;word-wrap:break-word"><code><div><span style=3D"color:rgb(0,=
0,136)"><span style=3D"color:#008">template</span></span><span style=3D"col=
or:rgb(0,0,0)"><span style=3D"color:#000"> </span></span><span style=3D"col=
or:rgb(102,102,0)"><span style=3D"color:#660"><</span></span><span style=
=3D"color:rgb(0,0,136)"><span style=3D"color:#008">typename</span></span><s=
pan style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> T</span></span><=
span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">></span><=
/span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> </span><=
/span><span style=3D"color:rgb(0,0,136)"><span style=3D"color:#008">concept=
</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> =
</span></span><span style=3D"color:rgb(102,0,102)"><span style=3D"color:#60=
6">Example</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"col=
or:#000"><br></span></span><span style=3D"color:rgb(102,102,0)"><span style=
=3D"color:#660">{</span></span><span style=3D"color:rgb(0,0,0)"><span style=
=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#606">Integral</span>=
</span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> T</span=
></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::<=
/span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">po=
sition</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"col=
or:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#8=
00">//where Integral is a concept for a type that has the arithmetic operat=
ors</span><span style=3D"color:#000"><br></span></span><span style=3D"color=
:rgb(0,0,0)"><span style=3D"color:#000">=C2=A0</span><span style=3D"color:#=
800">//or the long form:</span><span style=3D"color:#000"><br>=C2=A0</span>=
<span style=3D"color:#800">//template <typename X> T::position requir=
es Integral<X>;</span><span style=3D"color:#000"><br>=C2=A0</span><sp=
an style=3D"color:#800">//or a variable position of any type:</span><span s=
tyle=3D"color:#000"><br>=C2=A0</span><span style=3D"color:#800">//auto T::p=
osition;</span><span style=3D"color:#000"><br>=C2=A0std</span></span><span =
style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::</span></span><=
span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">sort</span></spa=
n><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660"><</spa=
n></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">T</spa=
n></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">&g=
t;(</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000=
">T</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:=
#660">,</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:=
#000"> T</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"c=
olor:#660">);</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"=
color:#000"> </span></span><span style=3D"color:rgb(136,0,0)"><span style=
=3D"color:#800">//free-standing function </span></span><span style=3D"color=
:rgb(0,0,0)"><span style=3D"color:#000"><br>=C2=A0</span></span><span style=
=3D"color:rgb(0,0,136)"><span style=3D"color:#008">static</span></span><spa=
n style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> </span></span><spa=
n style=3D"color:rgb(0,0,136)"><span style=3D"color:#008">int</span></span>=
<span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> T</span></span=
><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::</span><=
/span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000">static_fu=
nc</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#=
660">(</span></span><span style=3D"color:rgb(0,0,136)"><span style=3D"color=
:#008">int</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"col=
or:#000"> foo</span></span><span style=3D"color:rgb(102,102,0)"><span style=
=3D"color:#660">);</span></span><span style=3D"color:rgb(0,0,0)"><span styl=
e=3D"color:#000"> </span></span><span style=3D"color:rgb(136,0,0)"><span st=
yle=3D"color:#800">// static member functions</span></span><span style=3D"c=
olor:rgb(0,0,0)"><span style=3D"color:#000"><br>=C2=A0T</span></span><span =
style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">::</span></span><=
span style=3D"color:rgb(0,0,136)"><span style=3D"color:#008">typename</span=
></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> size_t=
ype</span></span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:=
#660">;</span></span><span style=3D"color:rgb(0,0,0)"><span style=3D"color:=
#000"> </span></span><span style=3D"color:rgb(136,0,0)"><span style=3D"colo=
r:#800">//member type</span></span><span style=3D"color:rgb(0,0,0)"><span s=
tyle=3D"color:#000"><br><br></span></span><span style=3D"color:rgb(102,102,=
0)"><span style=3D"color:#660">};</span></span><span style=3D"color:#000"><=
br></span></div></code></div>With this form of concepts, the flexibility of=
Concepts-lite is preserved</div></div></blockquote><div><br>I fail to see =
any flexibility here.<br><br>It's hard to know how to respond to your e=
xample, because it's not actually an example of a useful concept. It=
9;s just a bunch of tests, with no real meaning to them. For example, why d=
oes this concept care that `static_func` is actually a `static` function? W=
hy can't it be a non-static function? Or even a `virtual` function? Why=
does it care that it returns an `int` and takes an `int`? Again, why not `=
short`, `char`, `long` or anything else?<br><br>What seems clear to me is t=
hat the equivalent concepts-lite expressions are more flexible <i>by defaul=
t</i> than your version. Your versions over-constrain things, requiring add=
itional syntax to permit more generic constructs. By contrast, concepts-lit=
e is always generic, only using explicit types when you specifically ask fo=
r it.</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2443c705-d25d-4013-adfc-84605a4aeb46%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/2443c705-d25d-4013-adfc-84605a4aeb46=
%40isocpp.org</a>.<br />
------=_Part_5436_1238260307.1479357182800--
------=_Part_5435_1657071106.1479357182799--
.
Author: Jonathan Coe <jonathanbcoe@gmail.com>
Date: Thu, 17 Nov 2016 04:33:42 +0000
Raw View
--Apple-Mail-71B012D2-F62D-4072-8BDB-E108F52BB4E1
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
> On 16 Nov 2016, at 23:43, Darius Jankauskas <d5926j@gmail.com> wrote:
>=20
>=20
>=20
>> On Tuesday, November 15, 2016 at 11:27:37 PM UTC-5, Nicol Bolas wrote:
>>> On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankauskas w=
rote:
>>> We currently have a C++ proposal for Concepts-lite. However, it has sev=
eral issues. First of all, there is no compile-time checking by the compile=
r to ensure functions and classes aren=E2=80=99t using functionality of a t=
ype not specified as a concept. Second of all, the two different forms of c=
oncepts as functions are variable templates are undesirable, as they have v=
arious differences such as that the variable form cannot be overloaded, but=
the function form can.=20
>>> I think another design inspired by older ideas is needed; this is an in=
formal starting point.
>>=20
>> We do not need a complete teardown&redesign of concepts in order to reso=
lve either of those problems.
>>=20
>> I don't see any particular advantage to your specific syntax, relative t=
o implementing one of the fixes for item 2 from this paper.
>> =20
>>> Many different types of requirements can be declared:
>>> template <typename T> concept Example //requires ... can inherit constr=
aints from other concepts as well as accepting constexpr bools that must be=
true for success
>>> {
>>> int T::position; //member variable
>>> std::sort<T>(T, T); //free-standing function=20
>>> static int T::static_func(int foo); // static member functions
>>> T::typename size_type; //member type
>>>=20
>>> };
>>> These requirements would not have to be met perfectly, with for example=
a function that accepts variables by value would satisfy a requirement fo=
r a function accepting variables by const reference.
>>=20
>> Issues like that are precisely why concepts-TS has constraints defined b=
y expressions on values of those types, rather than checking for the existe=
nce of a particular functions or members. That's why the `requires` clause =
is able to declare that variables of a certain type speculatively exist, so=
that you can apply expressions to them.
>>=20
>> Your way is far too specific. Concepts are a way of saying, "here are th=
e things I expect to be able to do with the type in question.
>>=20
>> Why does it matter for a concept if `T::position` is exactly `int`? Why =
can't it be `short`? Or any integer type? Or any type which conforms to an =
integer-like concept?
> Your first claim that this complete teardown of concepts isn't necessary =
for fixing the issue of two different forms of concepts is true; in fact I =
was aware of that proposal already. however, that proposal does not seem to=
have gained any traction among the C++ community, probably because the iss=
ues with two different concept forms is not seen to be bad enough that chan=
ge is warranted. The situation is fixed with this proposal as a side effect=
, not the main reason.
> I disagree with your statement that a teardown of the current concepts pr=
oposal is not necessary to provide definition checking that is seen by man=
y as essential (hence concepts not in C++ 17).
I'm not sure about 'many' here. There are a vocal few but the main objectio=
n to including concepts in C++17 was that there is only one implementation =
and not (at the time) in a release build of a compiler.
> In fact, P0240 expresses the sentiment that it is extremely unlikely that=
the current system could ever have definition checking, and that is just u=
nacceptable. Even if a solution were to be found, it would likely be overly=
complex and error-prone as understanding what constraint an expression is =
supposed to represent will certainly not be easy or transparent.
> As for your final issue, let's redo concept Example:
> template <typename T> concept Example
> {
> Integral T::position; //where Integral is a concept for a type that has =
the arithmetic operators
> //or the long form:
> //template <typename X> T::position requires Integral<X>;
> //or a variable position of any type:
> //auto T::position;
> std::sort<T>(T, T); //free-standing function=20
> static int T::static_func(int foo); // static member functions
> T::typename size_type; //member type
>=20
> };
> With this form of concepts, the flexibility of Concepts-lite is preserved=
but the compiler can (relatively) easily tell what we should be able to do=
with the types. We need definition checking in a concepts system and rethi=
nking Concepts-lite is necessary.=20
> --=20
> You received this message because you are subscribed to the Google Groups=
"ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/86bff859-8471-4a39-8eb8-ec7eb5782d12%40isocpp.=
org.
--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/BCC98FB8-0780-4506-847C-C3AB3F103B5C%40gmail.com=
..
--Apple-Mail-71B012D2-F62D-4072-8BDB-E108F52BB4E1
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div></div><div><br></div><div>On 16 No=
v 2016, at 23:43, Darius Jankauskas <<a href=3D"mailto:d5926j@gmail.com"=
>d5926j@gmail.com</a>> wrote:<br><br></div><blockquote type=3D"cite"><di=
v><div dir=3D"ltr"><br><br>On Tuesday, November 15, 2016 at 11:27:37 PM UTC=
-5, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">On Tuesday, November 15, 2016 at 10:33:55 PM UTC-5, Darius Jankaus=
kas wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><p=
dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><s=
pan style=3D"font-size:14.666666666666666px;font-family:Arial;color:#000000=
;background-color:transparent;font-weight:400;font-style:normal;font-varian=
t:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"=
>We currently have a C++ proposal for Concepts-lite. However, it has severa=
l issues. First of all, there is no compile-time checking by the compiler t=
o ensure functions and classes aren=E2=80=99t using functionality of a type=
not specified as a concept. Second of all, the two different forms of conc=
epts as functions are variable templates are undesirable, as they have vari=
ous differences such as that the variable form cannot be overloaded, but th=
e function form can.</span> </p></span></div></blockquote><blockquote =
class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #=
ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"=
line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size=
:14.666666666666666px;font-family:Arial;color:#000000;background-color:tran=
sparent;font-weight:400;font-style:normal;font-variant:normal;text-decorati=
on:none;vertical-align:baseline;white-space:pre-wrap">I think another desig=
n inspired by older ideas is needed; this is an informal starting point.</s=
pan></p></span></div></blockquote><div><br>We do not need a complete teardo=
wn&redesign of concepts in order to resolve either of those problems.<b=
r><br>I don't see any particular advantage to your specific syntax, relativ=
e to implementing one of the fixes for item 2 <a href=3D"http://www.open-st=
d.org/JTC1/SC22/WG21/docs/papers/2016/p0324r0.html" target=3D"_blank" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dht=
tp%3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016%2Fp=
0324r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEd7TCCdi1ksjLDZDJ8zLH5n=
VcTrA';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3=
dhttp%3A%2F%2Fwww.open-std.org%2FJTC1%2FSC22%2FWG21%2Fdocs%2Fpapers%2F2016%=
2Fp0324r0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEd7TCCdi1ksjLDZDJ8zL=
H5nVcTrA';return true;">from this paper</a>.<br> </div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc=
solid;padding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"lin=
e-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14=
..666666666666666px;font-family:Arial;color:#000000;background-color:transpa=
rent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:=
none;vertical-align:baseline;white-space:pre-wrap">Many different types of =
requirements can be declared:</span></p><div style=3D"background-color:rgb(=
250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:=
1px;word-wrap:break-word"><code><div><span style=3D"color:#008">template</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660"><</spa=
n><span style=3D"color:#008">typename</span><span style=3D"color:#000"> T</=
span><span style=3D"color:#660">></span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#008">concept</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#606">Example</span><span style=3D"color:#000"> </=
span><span style=3D"color:#800">//requires ... can inherit constraints from=
other concepts as well as accepting constexpr bools that must be true for =
success</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
60">{</span><span style=3D"color:#000"><br> </span><span style=3D"colo=
r:#008">int</span><span style=3D"color:#000"> T</span><span style=3D"color:=
#660">::</span><span style=3D"color:#000">position</span><span style=3D"col=
or:#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#8=
00">//member variable</span><span style=3D"color:#000"><br> std</span>=
<span style=3D"color:#660">::</span><span style=3D"color:#000">sort</span><=
span style=3D"color:#660"><</span><span style=3D"color:#000">T</span><sp=
an style=3D"color:#660">>(</span><span style=3D"color:#000">T</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#000"> T</span><span st=
yle=3D"color:#660">);</span><span style=3D"color:#000"> </span><span style=
=3D"color:#800">//free-standing function </span><span style=3D"color:#000">=
<br> </span><span style=3D"color:#008">static</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#008">int</span><span style=3D"color:=
#000"> T</span><span style=3D"color:#660">::</span><span style=3D"color:#00=
0">static_func</span><span style=3D"color:#660">(</span><span style=3D"colo=
r:#008">int</span><span style=3D"color:#000"> foo</span><span style=3D"colo=
r:#660">);</span><span style=3D"color:#000"> </span><span style=3D"color:#8=
00">// static member functions</span><span style=3D"color:#000"><br> T=
</span><span style=3D"color:#660">::</span><span style=3D"color:#008">typen=
ame</span><span style=3D"color:#000"> size_type</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"> </span><span style=3D"color:#800"=
>//member type</span><span style=3D"color:#000"><br><br></span><span style=
=3D"color:#660">};</span></div></code></div><p dir=3D"ltr" style=3D"line-he=
ight:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.666=
7px;color:rgb(0,0,0);background-color:transparent;font-weight:400;font-styl=
e:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"=
><font face=3D"arial, sans-serif">These requirements would not have to be m=
et perfectly, with for example a function that accepts variables by value =
would satisfy a requirement for a function accepting variables by const ref=
erence.</font></span></p></span></div></blockquote><div><br>Issues like tha=
t are precisely why concepts-TS has constraints defined by <i>expressions</=
i> on values of those types, rather than checking for the existence of a pa=
rticular functions or members. That's why the `requires` clause is able to =
declare that variables of a certain type speculatively exist, so that you c=
an apply expressions to them.<br><br>Your way is far too specific. Concepts=
are a way of saying, "here are the things I expect to be able to do with t=
he type in question.<br><br>Why does it matter for a concept if `T::positio=
n` is exactly `int`? Why can't it be `short`? Or any integer type? Or any t=
ype which conforms to an integer-like concept?<br></div></div></blockquote>=
<div>Your first claim that this complete teardown of concepts isn't necessa=
ry for fixing the issue of two different forms of concepts is true; in fact=
I was aware of that proposal already. however, that proposal does not seem=
to have gained any traction among the C++ community, probably because the =
issues with two different concept forms is not seen to be bad enough that c=
hange is warranted. The situation is fixed with this proposal as a side eff=
ect, not the main reason.</div><div>I disagree with your statement that a t=
eardown of the current concepts proposal is not necessary to provide =
definition checking that is seen by many as essential (hence concepts not i=
n C++ 17). </div></div></div></blockquote><div><br></div><div>I'm not sure =
about 'many' here. There are a vocal few but the main objection to includin=
g concepts in C++17 was that there is only one implementation and not (at t=
he time) in a release build of a compiler.</div><br><blockquote type=3D"cit=
e"><div><div dir=3D"ltr"><div>In fact, <a href=3D"http://www.open-std.=
org/jtc1/sc22/wg21/docs/papers/2016/p0240r0.html">P0240</a> expresses =
the sentiment that it is extremely unlikely that the current system could e=
ver have definition checking, and that is just unacceptable. Even if a solu=
tion were to be found, it would likely be overly complex and error-prone&nb=
sp;as understanding what constraint an expression is supposed to represent =
will certainly not be easy or transparent.</div><div>As for your final issu=
e, let's redo concept Example:</div><div><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
border-style: solid; border-width: 1px; word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: rgb(0=
, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by-prettify">templ=
ate</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: r=
gb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify"=
><</span></span><span style=3D"color: rgb(0, 0, 136);"><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">typename</span></span><span style=
=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> T</span></span><span style=3D"color: rgb(102, 102, 0);"><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">></span></span><span st=
yle=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span></span><span style=3D"color: rgb(0, 0, 136);"><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">concept</span></span><span=
style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span></span><span style=3D"color: rgb(102, 0, 102);"><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Example</span></span>=
<span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span></span><span style=3D"color: rgb(102, 102, 0=
);"><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span></spa=
n><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Integral</span></span><span style=3D"color: rgb(0, =
0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> T</span>=
</span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;=
" class=3D"styled-by-prettify">::</span></span><span style=3D"color: rgb(0,=
0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify">position=
</span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D"=
styled-by-prettify">//where Integral is a concept for a type that has the a=
rithmetic operators</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span></span><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #800;" class=3D"styled-by-prettify">//or the long form:</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">//template <typename=
X> T::position requires Integral<X>;</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br> </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">//or a variable position of any type:</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> </=
span><span style=3D"color: #800;" class=3D"styled-by-prettify">//auto T::po=
sition;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
> std</span></span><span style=3D"color: rgb(102, 102, 0);"><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span></span><span style=
=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">sort</span></span><span style=3D"color: rgb(102, 102, 0);"><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><</span></span><span =
style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled=
-by-prettify">T</span></span><span style=3D"color: rgb(102, 102, 0);"><span=
style=3D"color: #660;" class=3D"styled-by-prettify">>(</span></span><sp=
an style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">T</span></span><span style=3D"color: rgb(102, 102, 0);"><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span></span><spa=
n style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> T</span></span><span style=3D"color: rgb(102, 102, 0);"><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">);</span></span><sp=
an style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span></span><span style=3D"color: rgb(136, 0, 0);"><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">//free-standing funct=
ion </span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> </span></span><span style=
=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">static</span></span><span style=3D"color: rgb(0, 0, 0);"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span></span><span sty=
le=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">int</span></span><span style=3D"color: rgb(0, 0, 0);"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> T</span></span><span sty=
le=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"style=
d-by-prettify">::</span></span><span style=3D"color: rgb(0, 0, 0);"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">static_func</span></span=
><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span></span><span style=3D"color: rgb(0, 0, 136=
);"><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span></s=
pan><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> foo</span></span><span style=3D"color: rgb(102, 10=
2, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span>=
</span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span></span><span style=3D"color: rgb(136, 0,=
0);"><span style=3D"color: #800;" class=3D"styled-by-prettify">// static m=
ember functions</span></span><span style=3D"color: rgb(0, 0, 0);"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br> T</span></span><=
span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span></span><span style=3D"color: rgb(0, 0, 136=
);"><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</spa=
n></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> size_type</span></span><span style=3D"color: =
rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> </span></span><span style=3D"color: r=
gb(136, 0, 0);"><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/member type</span></span><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span></span><span =
style=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">};</span></span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span></div></code></div>With this form of concepts, =
the flexibility of Concepts-lite is preserved but the compiler can (relativ=
ely) easily tell what we should be able to do with the types. We need defin=
ition checking in a concepts system and rethinking Concepts-lite is necessa=
ry. </div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/86bff859-8471-4a39-8eb8-ec7eb5782d12%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/86bff859-8471-4a39-8eb8-ec7eb578=
2d12%40isocpp.org</a>.<br>
</div></blockquote></body></html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/BCC98FB8-0780-4506-847C-C3AB3F103B5C%=
40gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/BCC98FB8-0780-4506-847C-C3AB3F103B5C%=
40gmail.com</a>.<br />
--Apple-Mail-71B012D2-F62D-4072-8BDB-E108F52BB4E1--
.
Author: Tom Honermann <tom@honermann.net>
Date: Wed, 16 Nov 2016 23:47:18 -0500
Raw View
This is a multi-part message in MIME format.
--------------10914694491C18A0D91B0F7C
Content-Type: text/plain; charset=UTF-8; format=flowed
On 11/16/2016 06:43 PM, Darius Jankauskas wrote:
> Your first claim that this complete teardown of concepts isn't
> necessary for fixing the issue of two different forms of concepts is
> true; in fact I was aware of that proposal already. however, that
> proposal does not seem to have gained any traction among the C++
> community, probably because the issues with two different concept
> forms is not seen to be bad enough that change is warranted. The
> situation is fixed with this proposal as a side effect, not the main
> reason.
I'm not sure how you're measuring traction for P0324. That paper has not
yet been presented to the committee because the committee has been busy
finalizing C++17. I expect that paper to be discussed in Kona or
Toronto next year; at which point we'll have some concrete feedback to
work off of.
> I disagree with your statement that a teardown of the current concepts
> proposal is not necessary to provide definition checking that is seen
> by many as essential (hence concepts not in C++ 17). In fact, P0240
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0240r0.html> expresses
> the sentiment that it is extremely unlikely that the current system
> could ever have definition checking, and that is just unacceptable.
> Even if a solution were to be found, it would likely be overly complex
> and error-prone as understanding what constraint an expression is
> supposed to represent will certainly not be easy or transparent.
No proposal for definition checking based on the current Concepts design
has been submitted. The designers of the current Concepts design have
expressed confidence that definition checking can be provided, but they
have tempered such assertions with references to experience with C++0x
Concepts, both in terms of usability and performance. Definition
checking does not come for free; it can be a drag both on development
time and on compilation time. It remains to be seen whether an
implementation that helps more than it hurts is feasible. In the
meantime, usage constraints are seen as being considerably more useful
and important for the near future.
I do believe that a reasonable definition checking design can be
implemented on top of the current Concepts design, but it will
necessarily have to make some compromises with regard to how strict the
definition checking is in order to avoid being overly burdensome. This
was true for the C++0x Concepts design as well (and I think any future
proposals should include comparisons with the trade offs that were
present in that older design). I think it is worth pointing out that
the C++0x Concepts design did not guarantee instantiation success for a
successfully concept checked template instantiated with template
arguments that satisfied the template constraints; I think this is the
lofty goal most people have in mind when definition checking is
discussed, but I suspect it is unobtainable in a usable form.
Tom.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8235062f-7e4d-1a3c-78f9-6598361ac750%40honermann.net.
--------------10914694491C18A0D91B0F7C
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">On 11/16/2016 06:43 PM, Darius
Jankauskas wrote:<br>
</div>
<blockquote
cite=3D"mid:86bff859-8471-4a39-8eb8-ec7eb5782d12@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">Your first claim that this complete teardown of
concepts isn't necessary for fixing the issue of two different
forms of concepts is true; in fact I was aware of that proposal
already. however, that proposal does not seem to have gained any
traction among the C++ community, probably because the issues
with two different concept forms is not seen to be bad enough
that change is warranted. The situation is fixed with this
proposal as a side effect, not the main reason.</div>
</blockquote>
<br>
I'm not sure how you're measuring traction for <span class=3D"c19">P032=
4.=C2=A0
That paper has not yet been presented to the committee because the
committee has been busy finalizing C++17.=C2=A0 I expect that paper t=
o
be discussed in Kona or Toronto next year; at which point we'll
have some concrete feedback to work off of.<br>
<br>
</span>
<blockquote
cite=3D"mid:86bff859-8471-4a39-8eb8-ec7eb5782d12@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">
<div>I disagree with your statement that a teardown of the
current concepts proposal is not necessary to provide
=C2=A0definition checking that is seen by many as essential (henc=
e
concepts not in C++ 17). In fact,=C2=A0<a moz-do-not-send=3D"true=
"
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0240r0.htm=
l">P0240</a>=C2=A0expresses
the sentiment that it is extremely unlikely that the current
system could ever have definition checking, and that is just
unacceptable. Even if a solution were to be found, it would
likely be overly complex and error-prone=C2=A0as understanding wh=
at
constraint an expression is supposed to represent will
certainly not be easy or transparent.</div>
</div>
</blockquote>
<br>
No proposal for definition checking based on the current Concepts
design has been submitted.=C2=A0 The designers of the current Concepts
design have expressed confidence that definition checking can be
provided, but they have tempered such assertions with references to
experience with C++0x Concepts, both in terms of usability and
performance.=C2=A0 Definition checking does not come for free; it can b=
e
a drag both on development time and on compilation time.=C2=A0 It remai=
ns
to be seen whether an implementation that helps more than it hurts
is feasible.=C2=A0 In the meantime, usage constraints are seen as being
considerably more useful and important for the near future.<br>
<br>
I do believe that a reasonable definition checking design can be
implemented on top of the current Concepts design, but it will
necessarily have to make some compromises with regard to how strict
the definition checking is in order to avoid being overly
burdensome.=C2=A0 This was true for the C++0x Concepts design as well
(and I think any future proposals should include comparisons with
the trade offs that were present in that older design).=C2=A0 I think i=
t
is worth pointing out that the C++0x Concepts design did not
guarantee instantiation success for a successfully concept checked
template instantiated with template arguments that satisfied the
template constraints; I think this is the lofty goal most people
have in mind when definition checking is discussed, but I suspect it
is unobtainable in a usable form.<br>
<br>
Tom.<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8235062f-7e4d-1a3c-78f9-6598361ac750%=
40honermann.net?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goog=
le.com/a/isocpp.org/d/msgid/std-proposals/8235062f-7e4d-1a3c-78f9-6598361ac=
750%40honermann.net</a>.<br />
--------------10914694491C18A0D91B0F7C--
.
Author: Darius Jankauskas <d5926j@gmail.com>
Date: Thu, 15 Dec 2016 19:37:55 -0800 (PST)
Raw View
------=_Part_365_1465461065.1481859475881
Content-Type: multipart/alternative;
boundary="----=_Part_366_729602843.1481859475881"
------=_Part_366_729602843.1481859475881
Content-Type: text/plain; charset=UTF-8
I have considered what you all have said and after reading (what I think
is) a recent document <http://www.stroustrup.com/good_concepts.pdf> about
the current concepts proposal by Bjarne Stroustrup I'm inclined to agree
that my solution is suboptimal. Not only does Bjarne claim that definition
checking is possible with concepts as they are now, but that there is no
definition checking now is *by design*. Thank you for all of your feedback;
i can see that my proposal just wouldn't work well for C++.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/23ab2e41-76ff-4dee-8d04-767ce95dbee7%40isocpp.org.
------=_Part_366_729602843.1481859475881
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I have considered what you all have said and after reading=
(what I think is) a <a href=3D"http://www.stroustrup.com/good_concepts.pdf=
">recent document</a> about the current concepts proposal by Bjarne Stroust=
rup I'm inclined to agree that my solution is suboptimal. Not only does=
Bjarne claim that definition checking is possible with concepts as they ar=
e now, but that there is no definition checking now is <b>by design</b>. Th=
ank you for all of your feedback; i can see that my proposal just wouldn=
9;t work well for C++.=C2=A0<div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/23ab2e41-76ff-4dee-8d04-767ce95dbee7%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/23ab2e41-76ff-4dee-8d04-767ce95dbee7=
%40isocpp.org</a>.<br />
------=_Part_366_729602843.1481859475881--
------=_Part_365_1465461065.1481859475881--
.