Topic: Let the developer to know number of items in enum
Author: Andrey Semashev <andrey.semashev@gmail.com>
Date: Mon, 6 Mar 2017 11:41:52 +0300
Raw View
On 03/06/17 10:57, Konstantin Frumkin wrote:
> For now developers have to use crutches like
> enumFoobar{Foo,Bar,Baz,Quz,length =4};
>
> |
>
> this may be not safe and not robust.
> Let the developer access the length value implicitly at compile time like
> |||
>
> enumFoobar{foo,bar,baz,quz};
> intNumberOfIemsInFoobar=Foobar::length;//
>
> ||NumberOfIemsInFoobaris 4 during runtime||
>
> |
> Make C++ more sweet!|
First, member names cannot be reserved because it breaks valid code like
this:
enum { foo, bar, length };
Second, what should be the "length" be for enums like this:
enum { foo = 2, bar = 10 };
Should it be 2 (number of members) or 11 (max member + 1) or 9 (max
member - min member + 1) or something else? I guess, your answer would
depend on the use case you have in mind (which you haven't presented
yet) and the language cannot pick one for you.
In any case, I don't think any "length" would be useful without the
ability to iterate through the enum elements, and at that point you can
calculate whatever "length" you need.
--
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/5ddd61fd-6d2f-4174-1ac0-3c3a5158817c%40gmail.com.
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Mon, 6 Mar 2017 03:42:49 -0600
Raw View
--001a113dc5e4f70a8e054a0cb7fe
Content-Type: text/plain; charset=UTF-8
This will be part of the upcoming C++ standard reflection feature.
On Mon, Mar 6, 2017 at 1:57 AM, Konstantin Frumkin <fro0mberg@gmail.com>
wrote:
> For now developers have to use crutches like
> enumFoobar{Foo,Bar,Baz,Quz, length =4};
>
>
>
> this may be not safe and not robust.
> Let the developer access the length value implicitly at compile time like
>
> enumFoobar{foo, bar, baz, quz};
> intNumberOfIemsInFoobar=Foobar::length;//
>
> NumberOfIemsInFoobar is 4 during runtime
>
>
> Make C++ more sweet!
>
> --
> 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/8cde95ae-23fe-442f-
> 9bf2-5c040f05efde%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/8cde95ae-23fe-442f-9bf2-5c040f05efde%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHKNtTsA8suawDJc197TnS1Kz4%2B61LDpuM8M1yftL64STQ%40mail.gmail.com.
--001a113dc5e4f70a8e054a0cb7fe
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This will be part of the upcoming C++ standard reflection =
feature.</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On =
Mon, Mar 6, 2017 at 1:57 AM, Konstantin Frumkin <span dir=3D"ltr"><<a hr=
ef=3D"mailto:fro0mberg@gmail.com" target=3D"_blank">fro0mberg@gmail.com</a>=
></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">For n=
ow developers have to use crutches like <br><div class=3D"m_365303405365780=
0038m_-7574783336619094805prettyprint" style=3D"background-color:#fafafa;bo=
rder-color:#bbbbbb;border-style:solid;border-width:1px"><div class=3D"m_365=
3034053657800038m_-7574783336619094805subprettyprint"><span class=3D"m_3653=
034053657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#00=
8">enum</span><span class=3D"m_3653034053657800038m_-7574783336619094805sty=
led-by-prettify" style=3D"color:#606">Foobar</span><span class=3D"m_3653034=
053657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#660">=
{</span><span class=3D"m_3653034053657800038m_-7574783336619094805styled-by=
-prettify" style=3D"color:#606">Foo</span><span class=3D"m_3653034053657800=
038m_-7574783336619094805styled-by-prettify" style=3D"color:#660">,</span><=
span class=3D"m_3653034053657800038m_-7574783336619094805styled-by-prettify=
" style=3D"color:#606">Bar</span><span class=3D"m_3653034053657800038m_-757=
4783336619094805styled-by-prettify" style=3D"color:#660">,</span><span clas=
s=3D"m_3653034053657800038m_-7574783336619094805styled-by-prettify" style=
=3D"color:#606">Baz</span><span class=3D"m_3653034053657800038m_-7574783336=
619094805styled-by-prettify" style=3D"color:#660">,</span><span class=3D"m_=
3653034053657800038m_-7574783336619094805styled-by-prettify" style=3D"color=
:#606">Quz</span><span class=3D"m_3653034053657800038m_-7574783336619094805=
styled-by-prettify" style=3D"color:#660">,</span><span class=3D"m_365303405=
3657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#000"> l=
ength </span><span class=3D"m_3653034053657800038m_-7574783336619094805styl=
ed-by-prettify" style=3D"color:#660">=3D</span><span class=3D"m_36530340536=
57800038m_-7574783336619094805styled-by-prettify" style=3D"color:#066">4</s=
pan><span class=3D"m_3653034053657800038m_-7574783336619094805styled-by-pre=
ttify" style=3D"color:#660">};</span><span class=3D"m_3653034053657800038m_=
-7574783336619094805styled-by-prettify" style=3D"color:#000"><br></span></d=
iv></div><pre class=3D"m_3653034053657800038m_-7574783336619094805lang-cpp =
m_3653034053657800038m_-7574783336619094805prettyprint m_365303405365780003=
8m_-7574783336619094805prettyprinted"><code><span class=3D"m_36530340536578=
00038m_-7574783336619094805pun"><br><br>this may be not safe and not robust=
..<br>Let the developer access the length value implicitly at compile time l=
ike<br></span></code><code></code></pre><div class=3D"m_3653034053657800038=
m_-7574783336619094805prettyprint" style=3D"background-color:#fafafa;border=
-color:#bbbbbb;border-style:solid;border-width:1px"><div class=3D"m_3653034=
053657800038m_-7574783336619094805subprettyprint"><span class=3D"m_36530340=
53657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#008">e=
num</span><span class=3D"m_3653034053657800038m_-7574783336619094805styled-=
by-prettify" style=3D"color:#606">Foobar</span><span class=3D"m_36530340536=
57800038m_-7574783336619094805styled-by-prettify" style=3D"color:#660">{</s=
pan><span class=3D"m_3653034053657800038m_-7574783336619094805styled-by-pre=
ttify" style=3D"color:#000">foo</span><span class=3D"m_3653034053657800038m=
_-7574783336619094805styled-by-prettify" style=3D"color:#660">,</span><span=
class=3D"m_3653034053657800038m_-7574783336619094805styled-by-prettify" st=
yle=3D"color:#000"> bar</span><span class=3D"m_3653034053657800038m_-757478=
3336619094805styled-by-prettify" style=3D"color:#660">,</span><span class=
=3D"m_3653034053657800038m_-7574783336619094805styled-by-prettify" style=3D=
"color:#000"> baz</span><span class=3D"m_3653034053657800038m_-757478333661=
9094805styled-by-prettify" style=3D"color:#660">,</span><span class=3D"m_36=
53034053657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#=
000"> quz</span><span class=3D"m_3653034053657800038m_-7574783336619094805s=
tyled-by-prettify" style=3D"color:#660">};</span><span class=3D"m_365303405=
3657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#000"><b=
r></span><span class=3D"m_3653034053657800038m_-7574783336619094805styled-b=
y-prettify" style=3D"color:#008">int</span><span class=3D"m_365303405365780=
0038m_-7574783336619094805styled-by-prettify" style=3D"color:#606">NumberOf=
IemsInFoobar</span><span class=3D"m_3653034053657800038m_-75747833366190948=
05styled-by-prettify" style=3D"color:#660">=3D</span><span class=3D"m_36530=
34053657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#606=
">Foobar</span><span class=3D"m_3653034053657800038m_-7574783336619094805st=
yled-by-prettify" style=3D"color:#660"><wbr>::</span><span class=3D"m_36530=
34053657800038m_-7574783336619094805styled-by-prettify" style=3D"color:#000=
">length</span><span class=3D"m_3653034053657800038m_-7574783336619094805st=
yled-by-prettify" style=3D"color:#660">;</span><span class=3D"m_36530340536=
57800038m_-7574783336619094805styled-by-prettify" style=3D"color:#800">// <=
/span><br><pre class=3D"m_3653034053657800038m_-7574783336619094805lang-cpp=
m_3653034053657800038m_-7574783336619094805prettyprint m_36530340536578000=
38m_-7574783336619094805prettyprinted"><code><code class=3D"m_3653034053657=
800038m_-7574783336619094805prettyprint"><span class=3D"m_36530340536578000=
38m_-7574783336619094805styled-by-prettify" style=3D"color:#606">NumberOfIe=
msInFoobar</span><span class=3D"m_3653034053657800038m_-7574783336619094805=
styled-by-prettify" style=3D"color:#000"> is 4 during runtime</span></code>=
</code></pre></div></div><pre class=3D"m_3653034053657800038m_-757478333661=
9094805lang-cpp m_3653034053657800038m_-7574783336619094805prettyprint m_36=
53034053657800038m_-7574783336619094805prettyprinted"><code><span class=3D"=
m_3653034053657800038m_-7574783336619094805pun"><br>Make C++ more sweet!</s=
pan></code></pre></div><span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8cde95ae-23fe-442f-9bf2-5c040f05efde%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/8cde=
95ae-23fe-442f-<wbr>9bf2-5c040f05efde%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHKNtTsA8suawDJc197TnS1Kz4%2B6=
1LDpuM8M1yftL64STQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHKNtT=
sA8suawDJc197TnS1Kz4%2B61LDpuM8M1yftL64STQ%40mail.gmail.com</a>.<br />
--001a113dc5e4f70a8e054a0cb7fe--
.
Author: Konstantin Frumkin <fro0mberg@gmail.com>
Date: Mon, 6 Mar 2017 06:44:51 -0800 (PST)
Raw View
------=_Part_1650_748682005.1488811491869
Content-Type: multipart/alternative;
boundary="----=_Part_1651_2042801238.1488811491869"
------=_Part_1651_2042801238.1488811491869
Content-Type: text/plain; charset=UTF-8
length presents number of items.
user can override length explicitly so consistency with old code will be
kept.
On Monday, March 6, 2017 at 11:41:55 AM UTC+3, Andrey Semashev wrote:
>
> On 03/06/17 10:57, Konstantin Frumkin wrote:
> > For now developers have to use crutches like
> > enumFoobar{Foo,Bar,Baz,Quz,length =4};
> >
> > |
> >
> > this may be not safe and not robust.
> > Let the developer access the length value implicitly at compile time
> like
> > |||
> >
> > enumFoobar{foo,bar,baz,quz};
> > intNumberOfIemsInFoobar=Foobar::length;//
> >
> > ||NumberOfIemsInFoobaris 4 during runtime||
> >
> > |
> > Make C++ more sweet!|
>
> First, member names cannot be reserved because it breaks valid code like
> this:
>
> enum { foo, bar, length };
>
> Second, what should be the "length" be for enums like this:
>
> enum { foo = 2, bar = 10 };
>
> Should it be 2 (number of members) or 11 (max member + 1) or 9 (max
> member - min member + 1) or something else? I guess, your answer would
> depend on the use case you have in mind (which you haven't presented
> yet) and the language cannot pick one for you.
>
> In any case, I don't think any "length" would be useful without the
> ability to iterate through the enum elements, and at that point you can
> calculate whatever "length" you need.
>
>
--
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/c27684a4-a545-43b0-af0d-4c246c024f11%40isocpp.org.
------=_Part_1651_2042801238.1488811491869
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">length presents number of items.<br>user can override leng=
th explicitly so consistency with old code will be kept.<br><br>On Monday, =
March 6, 2017 at 11:41:55 AM UTC+3, Andrey Semashev wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">On 03/06/17 10:57, Konstantin Frumkin wrote:
<br>> For now developers have to use crutches like
<br>> enumFoobar{Foo,Bar,Baz,Quz,<wbr>length =3D4};
<br>>
<br>> |
<br>>
<br>> this may be not safe and not robust.
<br>> Let the developer access the length value implicitly at compile ti=
me like
<br>> |||
<br>>
<br>> enumFoobar{foo,bar,baz,quz};
<br>> intNumberOfIemsInFoobar=3D<wbr>Foobar::length;//
<br>>
<br>> ||NumberOfIemsInFoobaris 4 during runtime||
<br>>
<br>> |
<br>> Make C++ more sweet!|
<br>
<br>First, member names cannot be reserved because it breaks valid code lik=
e=20
<br>this:
<br>
<br>=C2=A0 =C2=A0enum { foo, bar, length };
<br>
<br>Second, what should be the "length" be for enums like this:
<br>
<br>=C2=A0 =C2=A0enum { foo =3D 2, bar =3D 10 };
<br>
<br>Should it be 2 (number of members) or 11 (max member + 1) or 9 (max=20
<br>member - min member + 1) or something else? I guess, your answer would=
=20
<br>depend on the use case you have in mind (which you haven't presente=
d=20
<br>yet) and the language cannot pick one for you.
<br>
<br>In any case, I don't think any "length" would be useful w=
ithout the=20
<br>ability to iterate through the enum elements, and at that point you can=
=20
<br>calculate whatever "length" you need.
<br>
<br></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/c27684a4-a545-43b0-af0d-4c246c024f11%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c27684a4-a545-43b0-af0d-4c246c024f11=
%40isocpp.org</a>.<br />
------=_Part_1651_2042801238.1488811491869--
------=_Part_1650_748682005.1488811491869--
.
Author: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= <daniel.kruegler@gmail.com>
Date: Mon, 6 Mar 2017 15:55:24 +0100
Raw View
2017-03-06 15:44 GMT+01:00 Konstantin Frumkin <fro0mberg@gmail.com>:
> length presents number of items.
> user can override length explicitly so consistency with old code will be
> kept.
By "override" you mean
enum { foo, bar, length=1 };
?
This would be even worse, because programmers won't expect that
'length' has the special semantic meaning now interpreted by the
compiler, not only introduced and interpreted by human beings. Not
every code base considers 'length' to be such a magic token. This
proposal has zero chance to become accepted, you really need to
separate enumerator names and semantic attributes (This requirement
would be met by the upcoming reflection feature, Andrew Tomazos was
referring to).
- Daniel
--
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/CAGNvRgCMCe71yw8TWTzhRVwCQ1UeDe3daGM5AEvV-g%2B0qWdVpA%40mail.gmail.com.
.
Author: Konstantin Frumkin <fro0mberg@gmail.com>
Date: Mon, 6 Mar 2017 07:28:39 -0800 (PST)
Raw View
------=_Part_1268_2012114153.1488814119946
Content-Type: multipart/alternative;
boundary="----=_Part_1269_409289825.1488814119947"
------=_Part_1269_409289825.1488814119947
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Yes, you are right.
it might be substituted with=20
Foobar::length();
As a static method. It could not be used before in context of enums.
On Monday, March 6, 2017 at 5:55:27 PM UTC+3, Daniel Kr=C3=BCgler wrote:
>
> 2017-03-06 15:44 GMT+01:00 Konstantin Frumkin <fro0...@gmail.com=20
> <javascript:>>:=20
> > length presents number of items.=20
> > user can override length explicitly so consistency with old code will b=
e=20
> > kept.=20
>
> By "override" you mean=20
>
> enum { foo, bar, length=3D1 };=20
>
> ?=20
>
> This would be even worse, because programmers won't expect that=20
> 'length' has the special semantic meaning now interpreted by the=20
> compiler, not only introduced and interpreted by human beings. Not=20
> every code base considers 'length' to be such a magic token. This=20
> proposal has zero chance to become accepted, you really need to=20
> separate enumerator names and semantic attributes (This requirement=20
> would be met by the upcoming reflection feature, Andrew Tomazos was=20
> referring to).=20
>
> - Daniel=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/ec829141-3d32-482f-87da-313ca26f2d70%40isocpp.or=
g.
------=_Part_1269_409289825.1488814119947
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes, you are right.<div>it might be substituted with=C2=A0=
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); b=
order-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; wo=
rd-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #606;" class=3D"styled-by-prettify">Foobar</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">length</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">();</span></div></code></div=
><span style=3D"background-color: rgb(250, 250, 250); color: rgb(0, 0, 0);"=
>As a static method. It could not be used before in context of enums.<br></=
span><br><br>On Monday, March 6, 2017 at 5:55:27 PM UTC+3, Daniel Kr=C3=BCg=
ler wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">2017-03-06 15:44 GMT=
+01:00 Konstantin Frumkin <<a href=3D"javascript:" target=3D"_blank" gdf=
-obfuscated-mailto=3D"ALkBDEA6CwAJ" rel=3D"nofollow" onmousedown=3D"this.hr=
ef=3D'javascript:';return true;" onclick=3D"this.href=3D'javasc=
ript:';return true;">fro0...@gmail.com</a>>:
<br>> length presents number of items.
<br>> user can override length explicitly so consistency with old code w=
ill be
<br>> kept.
<br>
<br>By "override" you mean
<br>
<br>enum { foo, bar, length=3D1 };
<br>
<br>?
<br>
<br>This would be even worse, because programmers won't expect that
<br>'length' has the special semantic meaning now interpreted by th=
e
<br>compiler, not only introduced and interpreted by human beings. Not
<br>every code base considers 'length' to be such a magic token. Th=
is
<br>proposal has zero chance to become accepted, you really need to
<br>separate enumerator names and semantic attributes (This requirement
<br>would be met by the upcoming reflection feature, Andrew Tomazos was
<br>referring to).
<br>
<br>- Daniel
<br></blockquote></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/ec829141-3d32-482f-87da-313ca26f2d70%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ec829141-3d32-482f-87da-313ca26f2d70=
%40isocpp.org</a>.<br />
------=_Part_1269_409289825.1488814119947--
------=_Part_1268_2012114153.1488814119946--
.
Author: =?UTF-8?Q?Micha=C5=82_Dominiak?= <griwes@griwes.info>
Date: Mon, 06 Mar 2017 15:29:49 +0000
Raw View
--001a114e52888b108e054a1191fb
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
That still conflicts with existing enumeration values named `length`.
On Mon, Mar 6, 2017 at 4:28 PM Konstantin Frumkin <fro0mberg@gmail.com>
wrote:
> Yes, you are right.
> it might be substituted with
> Foobar::length();
> As a static method. It could not be used before in context of enums.
>
>
> On Monday, March 6, 2017 at 5:55:27 PM UTC+3, Daniel Kr=C3=BCgler wrote:
>
> 2017-03-06 15:44 GMT+01:00 Konstantin Frumkin <fro0...@gmail.com>:
> > length presents number of items.
> > user can override length explicitly so consistency with old code will b=
e
> > kept.
>
> By "override" you mean
>
> enum { foo, bar, length=3D1 };
>
> ?
>
> This would be even worse, because programmers won't expect that
> 'length' has the special semantic meaning now interpreted by the
> compiler, not only introduced and interpreted by human beings. Not
> every code base considers 'length' to be such a magic token. This
> proposal has zero chance to become accepted, you really need to
> separate enumerator names and semantic attributes (This requirement
> would be met by the upcoming reflection feature, Andrew Tomazos was
> referring to).
>
> - Daniel
>
> --
> 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/ec829141-3d3=
2-482f-87da-313ca26f2d70%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ec829141-3d=
32-482f-87da-313ca26f2d70%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
--=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/CAPCFJdQ7FhAz0YzBDAhDqMOJ8v3QKzh1_Tndi8x45gw%3DU=
oYOZA%40mail.gmail.com.
--001a114e52888b108e054a1191fb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That still conflicts with existing enumeration values name=
d `length`.</div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Mon, Ma=
r 6, 2017 at 4:28 PM Konstantin Frumkin <<a href=3D"mailto:fro0mberg@gma=
il.com">fro0mberg@gmail.com</a>> wrote:<br></div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr" class=3D"gmail_msg">Yes, you are right.<div class=
=3D"gmail_msg">it might be substituted with=C2=A0<div class=3D"m_-352723462=
2322947100prettyprint gmail_msg" style=3D"background-color:rgb(250,250,250)=
;border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wra=
p:break-word"><code class=3D"m_-3527234622322947100prettyprint gmail_msg"><=
div class=3D"m_-3527234622322947100subprettyprint gmail_msg"><span style=3D=
"color:#606" class=3D"m_-3527234622322947100styled-by-prettify gmail_msg">F=
oobar</span><span style=3D"color:#660" class=3D"m_-3527234622322947100style=
d-by-prettify gmail_msg">::</span><span style=3D"color:#000" class=3D"m_-35=
27234622322947100styled-by-prettify gmail_msg">length</span><span style=3D"=
color:#660" class=3D"m_-3527234622322947100styled-by-prettify gmail_msg">()=
;</span></div></code></div><span style=3D"background-color:rgb(250,250,250)=
;color:rgb(0,0,0)" class=3D"gmail_msg">As a static method. It could not be =
used before in context of enums.<br class=3D"gmail_msg"></span><br class=3D=
"gmail_msg"><br class=3D"gmail_msg">On Monday, March 6, 2017 at 5:55:27 PM =
UTC+3, Daniel Kr=C3=BCgler wrote:</div></div><div dir=3D"ltr" class=3D"gmai=
l_msg"><div class=3D"gmail_msg"><blockquote class=3D"gmail_quote gmail_msg"=
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-lef=
t:1ex">2017-03-06 15:44 GMT+01:00 Konstantin Frumkin <<a rel=3D"nofollow=
" class=3D"gmail_msg">fro0...@gmail.com</a>>:
<br class=3D"gmail_msg">> length presents number of items.
<br class=3D"gmail_msg">> user can override length explicitly so consist=
ency with old code will be
<br class=3D"gmail_msg">> kept.
<br class=3D"gmail_msg">
<br class=3D"gmail_msg">By "override" you mean
<br class=3D"gmail_msg">
<br class=3D"gmail_msg">enum { foo, bar, length=3D1 };
<br class=3D"gmail_msg">
<br class=3D"gmail_msg">?
<br class=3D"gmail_msg">
<br class=3D"gmail_msg">This would be even worse, because programmers won&#=
39;t expect that
<br class=3D"gmail_msg">'length' has the special semantic meaning n=
ow interpreted by the
<br class=3D"gmail_msg">compiler, not only introduced and interpreted by hu=
man beings. Not
<br class=3D"gmail_msg">every code base considers 'length' to be su=
ch a magic token. This
<br class=3D"gmail_msg">proposal has zero chance to become accepted, you re=
ally need to
<br class=3D"gmail_msg">separate enumerator names and semantic attributes (=
This requirement
<br class=3D"gmail_msg">would be met by the upcoming reflection feature, An=
drew Tomazos was
<br class=3D"gmail_msg">referring to).
<br class=3D"gmail_msg">
<br class=3D"gmail_msg">- Daniel
<br class=3D"gmail_msg"></blockquote></div></div>
<p class=3D"gmail_msg"></p>
-- <br class=3D"gmail_msg">
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br class=3D"gmail_msg=
">
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" class=3D"gm=
ail_msg" target=3D"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br cla=
ss=3D"gmail_msg">
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" class=3D"gmail_msg" target=3D"_blank">std-proposals@isocpp.org</a>.<b=
r class=3D"gmail_msg">
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ec829141-3d32-482f-87da-313ca26f2d70%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" class=3D"gmail_msg=
" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-prop=
osals/ec829141-3d32-482f-87da-313ca26f2d70%40isocpp.org</a>.<br class=3D"gm=
ail_msg">
</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/CAPCFJdQ7FhAz0YzBDAhDqMOJ8v3QKzh1_Tnd=
i8x45gw%3DUoYOZA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPCFJdQ7FhAz0Y=
zBDAhDqMOJ8v3QKzh1_Tndi8x45gw%3DUoYOZA%40mail.gmail.com</a>.<br />
--001a114e52888b108e054a1191fb--
.
Author: =?UTF-8?Q?Jonathan_M=c3=bcller?= <jonathanmueller.dev@gmail.com>
Date: Mon, 6 Mar 2017 16:31:46 +0100
Raw View
On 06.03.2017 16:29, Micha=C5=82 Dominiak wrote:
> That still conflicts with existing enumeration values named `length`.
We could go and add something to type_traits=20
`std::enum_length<Enum>::value`, but that still doesn't solve the=20
problem of non-contiguous enums, so we'd need something like=20
`std::is_contiguous_enum<Enum>::value` etc.
--=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/10ea404f-2a6d-1231-1bdc-90d718eb2be3%40gmail.com=
..
.
Author: Bo Persson <bop@gmb.dk>
Date: Tue, 7 Mar 2017 10:41:02 +0100
Raw View
On 2017-03-06 16:29, Micha=C5=82 Dominiak wrote:
> That still conflicts with existing enumeration values named `length`.
Not if we allow it as a member function
enum Foobar
{
foo, bar
static size_t length()
{ return 2; }
};
Though there might be a need for some separator between 'bar' and=20
'static'...
And you would still have to remember to update the function when adding=20
or removing enumerators. So needs more work.
Bo Persson
>
> On Mon, Mar 6, 2017 at 4:28 PM Konstantin Frumkin <fro0mberg@gmail.com
> <mailto:fro0mberg@gmail.com>> wrote:
>
> Yes, you are right.
> it might be substituted with
> |
> Foobar::length();
> |
> As a static method. It could not be used before in context of enums.
>
>
> On Monday, March 6, 2017 at 5:55:27 PM UTC+3, Daniel Kr=C3=BCgler wro=
te:
>
> 2017-03-06 15:44 GMT+01:00 Konstantin Frumkin <fro0...@gmail.com>=
:
> > length presents number of items.
> > user can override length explicitly so consistency with old
> code will be
> > kept.
>
> By "override" you mean
>
> enum { foo, bar, length=3D1 };
>
> ?
>
> This would be even worse, because programmers won't expect that
> 'length' has the special semantic meaning now interpreted by the
> compiler, not only introduced and interpreted by human beings. No=
t
> every code base considers 'length' to be such a magic token. This
> proposal has zero chance to become accepted, you really need to
> separate enumerator names and semantic attributes (This requireme=
nt
> would be met by the upcoming reflection feature, Andrew Tomazos w=
as
> referring to).
>
> - Daniel
>
--=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/o9lv7a%24q8d%241%40blaine.gmane.org.
.
Author: Bo Persson <bop@gmb.dk>
Date: Tue, 7 Mar 2017 12:06:02 +0100
Raw View
On 2017-03-07 10:47, Daniel Kr=C3=BCgler wrote:
> 2017-03-07 10:41 GMT+01:00 Bo Persson <bop@gmb.dk>:
>> On 2017-03-06 16:29, Micha=C5=82 Dominiak wrote:
>>>
>>> That still conflicts with existing enumeration values named `length`.
>>
>> Not if we allow it as a member function
>>
>> enum Foobar
>> {
>> foo, bar
>>
>> static size_t length()
>> { return 2; }
>>
>> };
>
> Even if we allow adding member functions to enumeration types, this
> does not *automatically* mean that these functions can have the same
> names as enumerators.
>
> The following very similar example is ill-formed:
>
> struct S {
> enum E { length };
> void length();
> };
>
Sure, it just shows that it is possible to make Foobar::length() be=20
valid, without automatically mapping it to just any enumerator named=20
'length' (which might not even be the last one in the set).
Personally I don't think I have ever felt the need to iterate over=20
non-consecutive enumerators. They seem to be bitmaps or targets in a=20
case-statement, not something to iterate over.
And if they are consecutive, adding a last 'length', 'max', or 'count'=20
works pretty well.
Bo Persson
--=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/o9m46k%24lt6%241%40blaine.gmane.org.
.