Topic: Proposal: allow idiomatic use of += and
Author: mihailnajdenov@gmail.com
Date: Fri, 14 Oct 2016 11:25:01 -0700 (PDT)
Raw View
------=_Part_314_1479078600.1476469501245
Content-Type: multipart/alternative;
boundary="----=_Part_315_1084384695.1476469501245"
------=_Part_315_1084384695.1476469501245
Content-Type: text/plain; charset=UTF-8
Can't continue a; be implemented in terms of std::next ?
--
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/c75d8640-f479-43a6-86e4-a26e6086aab2%40isocpp.org.
------=_Part_315_1084384695.1476469501245
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Can't continue a; be implemented in terms of std::next=
?</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/c75d8640-f479-43a6-86e4-a26e6086aab2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c75d8640-f479-43a6-86e4-a26e6086aab2=
%40isocpp.org</a>.<br />
------=_Part_315_1084384695.1476469501245--
------=_Part_314_1479078600.1476469501245--
.
Author: szollosi.lorand@gmail.com
Date: Fri, 14 Oct 2016 11:27:51 -0700 (PDT)
Raw View
------=_Part_1129_1917973392.1476469671311
Content-Type: multipart/alternative;
boundary="----=_Part_1130_295443728.1476469671311"
------=_Part_1130_295443728.1476469671311
Content-Type: text/plain; charset=UTF-8
Hi,
>
>
> enum { a = 10, b += 5 };
>
> would be equivalent to:
>
> enum { a = 10, b = 15 };
>
My intuition said everything but 15, sorry. You can write it very clear as:
enum { a = 10, b = a + 5 };
What's wrong with that?
>
>
With the above definition, this:
>
> continue a
>
> would be equivalent to:
>
> b
>
> `continue` is a continuation. What you wanted perhaps is:
enum E { a = 10, b = a + 5 };
E x = a;
++x; // or std::next(x);
assert(x == b);
(and:
>
> continue b
>
> could be an anonymous constant, whose value would be the "next" value, 16
> in the example, after b.)
>
Negative. Enum is there because it's type-safe. A reasonable code will
expect that only the values listed should be contained. It'll use it for
indexing without checks.
/* The same reason is why I propagate *not* having an after-last element
*in* the enum, but having a separate enum / const for that. */
Thanks,
-lorro
--
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/0973917f-ad3c-4caa-9196-e01ed1bd4476%40isocpp.org.
------=_Part_1130_295443728.1476469671311
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<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"><br><div>enum { a =3D 10, b +=3D 5 };</div><div><br></div><div>wou=
ld be equivalent to:</div><div><br></div><div>enum { a =3D 10, b =3D 15 };<=
/div><div></div></div></blockquote><div>My intuition said everything but 15=
, sorry. You can write it very clear as:<br>enum { a =3D 10, b =3D a + 5 };=
<br>What's wrong with that?<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div dir=3D"ltr"><div>=C2=A0<br></div></div></blockquote><blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></div><div>With=
the above definition, this:</div><div><br></div><div>continue a</div><div>=
<br></div><div>would be equivalent to:</div><div><br></div><div>b</div><div=
><br></div></div></blockquote><div>`continue` is a continuation. What you w=
anted perhaps is:<br>enum E { a =3D 10, b =3D a + 5 };<br><br>E x =3D a;<br=
>++x; // or std::next(x);<br>assert(x =3D=3D b);<br><br></div><blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
#ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></div><div>(and:</div=
><div><br></div><div>continue b</div><div><br></div><div>could be an anonym=
ous constant, whose value would be the "next" value, 16 in the ex=
ample, after b.)</div></div></blockquote><div>Negative. Enum is there becau=
se it's type-safe. A reasonable code will expect that only the values l=
isted should be contained. It'll use it for indexing without checks.<br=
>/* The same reason is why I propagate <i>not</i> having an after-last elem=
ent <i>in</i> the enum, but having a separate enum / const for that. */<br>=
<br>Thanks,<br>-lorro<br><div dir=3D"ltr"><div><br></div></div></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/0973917f-ad3c-4caa-9196-e01ed1bd4476%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0973917f-ad3c-4caa-9196-e01ed1bd4476=
%40isocpp.org</a>.<br />
------=_Part_1130_295443728.1476469671311--
------=_Part_1129_1917973392.1476469671311--
.
Author: szollosi.lorand@gmail.com
Date: Fri, 14 Oct 2016 11:36:27 -0700 (PDT)
Raw View
------=_Part_493_257444859.1476470187485
Content-Type: multipart/alternative;
boundary="----=_Part_494_745448334.1476470187486"
------=_Part_494_745448334.1476470187486
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
2016. okt=C3=B3ber 14., p=C3=A9ntek 20:25:01 UTC+2 id=C5=91pontban mihailn.=
...@gmail.com a=20
k=C3=B6vetkez=C5=91t =C3=ADrta:
>
> Can't continue a; be implemented in terms of std::next ?
>
Actually, range-based for loops over enum would be very cool..=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/d15cb2ac-f17c-4ef8-9dd8-e489395d59db%40isocpp.or=
g.
------=_Part_494_745448334.1476470187486
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>2016. okt=C3=B3ber 14., p=C3=A9ntek 20:25:01 UTC+2=
id=C5=91pontban mihailn...@gmail.com a k=C3=B6vetkez=C5=91t =C3=ADrta:<blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Can't continu=
e a; be implemented in terms of std::next ?</div></blockquote><div>Actually=
, range-based for loops over enum would be very cool.. <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/d15cb2ac-f17c-4ef8-9dd8-e489395d59db%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d15cb2ac-f17c-4ef8-9dd8-e489395d59db=
%40isocpp.org</a>.<br />
------=_Part_494_745448334.1476470187486--
------=_Part_493_257444859.1476470187485--
.
Author: "'Walt Karas' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Fri, 14 Oct 2016 12:26:42 -0700 (PDT)
Raw View
------=_Part_613_1346391354.1476473202139
Content-Type: multipart/alternative;
boundary="----=_Part_614_1151350732.1476473202139"
------=_Part_614_1151350732.1476473202139
Content-Type: text/plain; charset=UTF-8
On Friday, October 14, 2016 at 2:27:51 PM UTC-4, szollos...@gmail.com wrote:
>
> Hi,
>>
>>
>> enum { a = 10, b += 5 };
>>
>> would be equivalent to:
>>
>> enum { a = 10, b = 15 };
>>
> My intuition said everything but 15, sorry. You can write it very clear as:
> enum { a = 10, b = a + 5 };
> What's wrong with that?
>
Enum values can have long names, so repetition is not ideal. How about:
enum { a = 10, b = continue + 4 };
>>
> With the above definition, this:
>>
>> continue a
>>
>> would be equivalent to:
>>
>> b
>>
>> `continue` is a continuation. What you wanted perhaps is:
> enum E { a = 10, b = a + 5 };
>
> E x = a;
> ++x; // or std::next(x);
> assert(x == b);
>
> (and:
>>
>> continue b
>>
>> could be an anonymous constant, whose value would be the "next" value, 16
>> in the example, after b.)
>>
> Negative. Enum is there because it's type-safe. A reasonable code will
> expect that only the values listed should be contained. It'll use it for
> indexing without checks.
> /* The same reason is why I propagate *not* having an after-last element
> *in* the enum, but having a separate enum / const for that. */
>
Pardon my brain fart, the use of continue I proposed here would not
actually be of much use.
>
> Thanks,
> -lorro
>
>
--
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/481a6fd1-b86d-4bd0-9372-2c84fc95839a%40isocpp.org.
------=_Part_614_1151350732.1476473202139
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, October 14, 2016 at 2:27:51 PM UTC-4, szollos..=
..@gmail.com 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">Hi,<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br><div>e=
num { a =3D 10, b +=3D 5 };</div><div><br></div><div>would be equivalent to=
:</div><div><br></div><div>enum { a =3D 10, b =3D 15 };</div><div></div></d=
iv></blockquote><div>My intuition said everything but 15, sorry. You can wr=
ite it very clear as:<br>enum { a =3D 10, b =3D a + 5 };<br>What's wron=
g with that?<br></div></div></blockquote><div><br></div><div>Enum values ca=
n have long names, so repetition is not ideal. =C2=A0How about:</div><div><=
br></div><div>enum { a =3D 10, b =3D continue + 4 };<br></div><div><br></di=
v><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div></div>=
<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"><div>=C2=A0<br></d=
iv></div></blockquote><blockquote class=3D"gmail_quote" style=3D"margin:0;m=
argin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><div></div><div>With the above definition, this:</div><div><br></div><d=
iv>continue a</div><div><br></div><div>would be equivalent to:</div><div><b=
r></div><div>b</div><div><br></div></div></blockquote><div>`continue` is a =
continuation. What you wanted perhaps is:<br>enum E { a =3D 10, b =3D a + 5=
};<br><br>E x =3D a;<br>++x; // or std::next(x);<br>assert(x =3D=3D b);<br=
><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:=
0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div></=
div><div>(and:</div><div><br></div><div>continue b</div><div><br></div><div=
>could be an anonymous constant, whose value would be the "next" =
value, 16 in the example, after b.)</div></div></blockquote><div>Negative. =
Enum is there because it's type-safe. A reasonable code will expect tha=
t only the values listed should be contained. It'll use it for indexing=
without checks.<br>/* The same reason is why I propagate <i>not</i> having=
an after-last element <i>in</i> the enum, but having a separate enum / con=
st for that. */<br></div></div></blockquote><div><br></div><div>Pardon my b=
rain fart, the use of continue I proposed here would not actually be of muc=
h use.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><=
div dir=3D"ltr"><div><br>Thanks,<br>-lorro<br><div dir=3D"ltr"><div><br></d=
iv></div></div></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/481a6fd1-b86d-4bd0-9372-2c84fc95839a%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/481a6fd1-b86d-4bd0-9372-2c84fc95839a=
%40isocpp.org</a>.<br />
------=_Part_614_1151350732.1476473202139--
------=_Part_613_1346391354.1476473202139--
.