Topic: Switch Argument Dependent Lookup (SADL)
Author: corentin.schreiber@cea.fr
Date: Sun, 6 Jul 2014 15:12:00 -0700 (PDT)
Raw View
------=_Part_125_32390727.1404684720668
Content-Type: text/plain; charset=UTF-8
Maybe this has been discussed before, but I could not find any trace of it.
I have uploaded a short text to propose the addition of a new lookup rule
for switch case labels:
https://github.com/cschreib/cpp/blob/master/sadl/sadl.md
This is not a proper proposal per say, I just wanted to post an informal
message here, but for some reason the Google Group interface refused to
send it.
I would be interested in knowing what you think about such an addition to
the language.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_125_32390727.1404684720668
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Maybe this has been discussed before, but I could not find=
any trace of it.<br>I have uploaded a short text to propose the addition o=
f a new lookup rule for switch case labels:<br>https://github.com/cschreib/=
cpp/blob/master/sadl/sadl.md<br><br>This is not a proper proposal per say, =
I just wanted to post an informal message here, but for some reason the Goo=
gle Group interface refused to send it.<br>I would be interested in knowing=
what you think about such an addition to the language.<br><mytubeelement d=
ata=3D"{"bundle":{"label_delimitor":":","=
;percentage":"%","smart_buffer":"Smart Buffer=
","start_playing_when_buffered":"Start playing when buf=
fered","sound":"Sound","desktop_notification&=
quot;:"Desktop Notification","continuation_on_next_line"=
;:"-","loop":"Loop","only_notify":&=
quot;Only Notify","estimated_time":"Estimated Time"=
;,"global_preferences":"Global Preferences","no_no=
tification_supported_on_your_browser":"No notification style supp=
orted on your browser version","video_buffered":"Video =
Buffered","buffered":"Buffered","hyphen"=
:"-","buffered_message":"The video has been buffer=
ed as requested and is ready to play.","not_supported":"=
;Not Supported","on":"On","off":"Of=
f","click_to_enable_for_this_site":"Click to enable for=
this site","desktop_notification_denied":"You have den=
ied permission for desktop notification for this site","notificat=
ion_status_delimitor":";","error":"Error"=
;,"adblock_interferance_message":"Adblock (or similar extens=
ion) is known to interfere with SmartVideo. Please add this url to adblock =
whitelist.","calculating":"Calculating","wait=
ing":"Waiting","will_start_buffering_when_initialized&q=
uot;:"Will start buffering when initialized","will_start_pla=
ying_when_initialized":"Will start playing when initialized"=
,"completed":"Completed","buffering_stalled":=
"Buffering is stalled. Will stop.","stopped":"Stop=
ped","hr":"Hr","min":"Min",&qu=
ot;sec":"Sec","any_moment":"Any Moment",=
"popup_donate_to":"Donate to","extension_id":=
null},"prefs":{"desktopNotification":true,"soundNo=
tification":false,"logLevel":0,"enable":true,"=
;loop":false,"hidePopup":true,"autoPlay":false,&qu=
ot;autoBuffer":false,"autoPlayOnBuffer":false,"autoPlay=
OnBufferPercentage":42,"autoPlayOnSmartBuffer":true,"qu=
ality":"default","fshd":false,"onlyNotificati=
on":true,"enableFullScreen":true,"saveBandwidth":f=
alse,"hideAnnotations":true,"turnOffPagedBuffering":tru=
e}}" event=3D"preferencesUpdated" id=3D"myTubeRelayElementToPage"></mytubee=
lement><mytubeelement data=3D"{"loadBundle":true}" event=3D"relay=
Prefs" id=3D"myTubeRelayElementToTab"></mytubeelement></div>
<p></p>
-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_125_32390727.1404684720668--
.
Author: David Krauss <potswa@gmail.com>
Date: Mon, 7 Jul 2014 06:21:53 +0800
Raw View
--Apple-Mail=_E78D5EB2-0EC6-418B-B912-238774D68238
Content-Type: text/plain; charset=ISO-8859-1
On 2014-07-07, at 6:12 AM, corentin.schreiber@cea.fr wrote:
> Maybe this has been discussed before, but I could not find any trace of it.
> I have uploaded a short text to propose the addition of a new lookup rule for switch case labels:
> https://github.com/cschreib/cpp/blob/master/sadl/sadl.md
>
> This is not a proper proposal per say, I just wanted to post an informal message here, but for some reason the Google Group interface refused to send it.
> I would be interested in knowing what you think about such an addition to the language.
I think you've identified the general problem that scoped enumeration qualification is redundant when initializing an object of the given type.
However, in your case, you can simply declare the type inside the switch block.
switch (p.reason) {
using reason_t = packet::connection_failed::reason_t;
// Handle all possible cases and react accordingly
case reason_t::too_many_clients:
This eliminates the supposed local scope namespace pollution.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--Apple-Mail=_E78D5EB2-0EC6-418B-B912-238774D68238
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;07–07, at 6:12 AM, <a href=3D"mailto:corentin.schreiber@cea.fr"=
>corentin.schreiber@cea.fr</a> wrote:</div><br class=3D"Apple-interchange-n=
ewline"><blockquote type=3D"cite"><div dir=3D"ltr">Maybe this has been disc=
ussed before, but I could not find any trace of it.<br>I have uploaded a sh=
ort text to propose the addition of a new lookup rule for switch case label=
s:<br><a href=3D"https://github.com/cschreib/cpp/blob/master/sadl/sadl.md">=
https://github.com/cschreib/cpp/blob/master/sadl/sadl.md</a><br><br>This is=
not a proper proposal per say, I just wanted to post an informal message h=
ere, but for some reason the Google Group interface refused to send it.<br>=
I would be interested in knowing what you think about such an addition to t=
he language.<br><mytubeelement data=3D"{"bundle":{"label_del=
imitor":":","percentage":"%","smart=
_buffer":"Smart Buffer","start_playing_when_buffered&qu=
ot;:"Start playing when buffered","sound":"Sound&q=
uot;,"desktop_notification":"Desktop Notification",&quo=
t;continuation_on_next_line":"-","loop":"Loop=
","only_notify":"Only Notify","estimated_time=
":"Estimated Time","global_preferences":"Glob=
al Preferences","no_notification_supported_on_your_browser":=
"No notification style supported on your browser version","v=
ideo_buffered":"Video Buffered","buffered":"B=
uffered","hyphen":"-","buffered_message"=
:"The video has been buffered as requested and is ready to play."=
,"not_supported":"Not Supported","on":"O=
n","off":"Off","click_to_enable_for_this_site=
":"Click to enable for this site","desktop_notification=
_denied":"You have denied permission for desktop notification for=
this site","notification_status_delimitor":";",&q=
uot;error":"Error","adblock_interferance_message":=
"Adblock (or similar extension) is known to interfere with SmartVideo.=
Please add this url to adblock whitelist.","calculating":&q=
uot;Calculating","waiting":"Waiting","will_st=
art_buffering_when_initialized":"Will start buffering when initia=
lized","will_start_playing_when_initialized":"Will star=
t playing when initialized","completed":"Completed"=
;,"buffering_stalled":"Buffering is stalled. Will stop."=
;,"stopped":"Stopped","hr":"Hr",&qu=
ot;min":"Min","sec":"Sec","any_mome=
nt":"Any Moment","popup_donate_to":"Donate to=
","extension_id":null},"prefs":{"desktopNotif=
ication":true,"soundNotification":false,"logLevel"=
:0,"enable":true,"loop":false,"hidePopup":tru=
e,"autoPlay":false,"autoBuffer":false,"autoPlayOnB=
uffer":false,"autoPlayOnBufferPercentage":42,"autoPlayO=
nSmartBuffer":true,"quality":"default","fshd&=
quot;:false,"onlyNotification":true,"enableFullScreen":=
true,"saveBandwidth":false,"hideAnnotations":true,"=
;turnOffPagedBuffering":true}}" event=3D"preferencesUpdated" id=3D"myT=
ubeRelayElementToPage"></mytubeelement><mytubeelement data=3D"{"loadBu=
ndle":true}" event=3D"relayPrefs" id=3D"myTubeRelayElementToTab"></myt=
ubeelement></div></blockquote><br></div><div>I think you’ve identifie=
d the general problem that scoped enumeration qualification is redundant wh=
en initializing an object of the given type.</div><br><div>However, in your=
case, you can simply declare the type inside the switch block.</div><div><=
br></div><div><div><font face=3D"Courier"> switch (p.reas=
on) {</font></div><font face=3D"Courier"> u=
sing reason_t =3D packet::connection_failed::reason_t;</font=
></div><div><font face=3D"Courier"><br></font><div><font face=3D"Courier">&=
nbsp; // Handle all possible cases and react according=
ly</font></div><div><font face=3D"Courier"> case=
reason_t::too_many_clients:</font></div></div><div><br></div><div>Thi=
s eliminates the supposed local scope namespace pollution.</div><div><br></=
div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_E78D5EB2-0EC6-418B-B912-238774D68238--
.
Author: Corentin Schreiber <corentin.schreiber@cea.fr>
Date: Mon, 07 Jul 2014 01:26:35 +0200
Raw View
This is a multi-part message in MIME format.
--------------030706020909080603020201
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
On Monday, July 7, 2014 12:22:06 AM UTC+2, David Krauss wrote:
I think you've identified the general problem that scoped
enumeration qualification is redundant when initializing an object
of the given type.
You mean the same philosophy could apply to the following cases?
|
packet::connection_failed::reason_t rsn =too_many_clients;// [1]
voidfoo(packet::connection_failed::reason_t rsn);// [2]
foo(too_many_clients);
|
I believe case [1] is ok and straightforward, although it can still can
be replaced by
|
autorsn =|packet::connection_failed::reason_t::||too_many_clients;|
|
This is not applicable to member initializer lists though.
Case [2] can be tricky to mix with overload resolution and template type
deduction, but that should be doable as well. Is it worth the trouble, I
don't know. The switch however is probably where enums are used most, so
I would think there is a substantial amount of clarity to be gained here
for very little cost.
However, in your case, you can simply declare the type inside the
switch block.
switch (p.reason) {
using reason_t = packet::connection_failed::reason_t;
// Handle all possible cases and react accordingly
case reason_t::too_many_clients:
This eliminates the supposed local scope namespace pollution.
That's true, I didn't realize you could do that. Now that is still some
unnecessary typing, given that the actual type of 'p.reason' is known to
the compiler.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--------------030706020909080603020201
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3DISO-8859-1"
http-equiv=3D"Content-Type">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
On Monday, July 7, 2014 12:22:06 AM UTC+2, David Krauss wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div style=3D"word-wrap:break-word"><br>
<div>I think you’ve identified the general problem that scope=
d
enumeration qualification is redundant when initializing an
object of the given type.</div>
</div>
</blockquote>
<div><br>
You mean the same philosophy could apply to the following cases?<br>
<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"subprettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify">packet</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span
style=3D"color: #000;" class=3D"styled-by-prettify">connectio=
n_failed</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span
style=3D"color: #000;" class=3D"styled-by-prettify">reason_t
rsn </span><span style=3D"color: #660;"
class=3D"styled-by-prettify">=3D</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"> too_many_clients</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: #800;" class=3D"styled-by-prettify">// [1]</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
<br>
</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">void</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> foo</spa=
n><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span
style=3D"color: #000;" class=3D"styled-by-prettify">packet</s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span
style=3D"color: #000;" class=3D"styled-by-prettify">connectio=
n_failed</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span
style=3D"color: #000;" class=3D"styled-by-prettify">reason_t
rsn</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: #800;" class=3D"styled-by-prettify">// [2]</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
foo</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">(</span><span style=3D"color:
#000;" class=3D"styled-by-prettify">too_many_clients</span><s=
pan
style=3D"color: #660;" class=3D"styled-by-prettify">);</span>=
<span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span></div>
</code></div>
<br>
I believe case [1] is ok and straightforward, although it can
still can be replaced by<br>
<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"subprettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">auto</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"> rsn </span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span=
><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify"> packet</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
style=3D"color: #000;" class=3D"styled-by-prettify">connect=
ion_failed</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><span
style=3D"color: #000;" class=3D"styled-by-prettify">reason_=
t::</span></code><code
class=3D"prettyprint"><span style=3D"color: #000;"
class=3D"styled-by-prettify">too_many_clients</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
></code></div>
</code></div>
This is not applicable to member initializer lists though.<br>
<br>
Case [2] can be tricky to mix with overload resolution and
template type deduction, but that should be doable as well. Is it
worth the trouble, I don't know. The switch however is probably
where enums are used most, so I would think there is a substantial
amount of clarity to be gained here for very little cost.<br>
</div>
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div style=3D"word-wrap:break-word">
<div>However, in your case, you can simply declare the type
inside the switch block.</div>
<div><br>
</div>
<div>
<div><font face=3D"Courier"> switch (p.reason)&=
nbsp;{</font></div>
<font face=3D"Courier"> using rea=
son_t =3D packet::<wbr>connection_failed::reason_t;</font></div>
<div><font face=3D"Courier"><br>
</font>
<div><font face=3D"Courier"> // Handle=
all possible cases
and react accordingly</font></div>
<div><font face=3D"Courier"> case =
;reason_t::too_many_<wbr>clients:</font></div>
</div>
<div><br>
</div>
<div>This eliminates the supposed local scope namespace
pollution.</div>
</div>
</blockquote>
<div><br>
That's true, I didn't realize you could do that. Now that is still
some unnecessary typing, given that the actual type of 'p.reason'
is known to the compiler.<br>
</div>
<mytubeelement
data=3D"{"bundle":{"label_delimitor":":"=
;,"percentage":"%","smart_buffer":"Smart
Buffer","start_playing_when_buffered":"Start
playing when
buffered","sound":"Sound","desktop_noti=
fication":"Desktop
Notification","continuation_on_next_line":"-"=
;,"loop":"Loop","only_notify":"Only
Notify","estimated_time":"Estimated
Time","global_preferences":"Global
Preferences","no_notification_supported_on_your_browser&quo=
t;:"No
notification style supported on your browser
version","video_buffered":"Video
Buffered","buffered":"Buffered","hyphen=
":"-","buffered_message":"The
video has been buffered as requested and is ready to
play.","not_supported":"Not
Supported","on":"On","off":"O=
ff","click_to_enable_for_this_site":"Click
to enable for this
site","desktop_notification_denied":"You have
denied permission for desktop notification for this
site","notification_status_delimitor":";",&q=
uot;error":"Error","adblock_interferance_message":=
"Adblock
(or similar extension) is known to interfere with SmartVideo.
Please add this url to adblock
whitelist.","calculating":"Calculating",&quo=
t;waiting":"Waiting","will_start_buffering_when_initial=
ized":"Will
start buffering when
initialized","will_start_playing_when_initialized":&qu=
ot;Will
start playing when
initialized","completed":"Completed","b=
uffering_stalled":"Buffering
is stalled. Will
stop.","stopped":"Stopped","hr":&q=
uot;Hr","min":"Min","sec":"Sec"=
;,"any_moment":"Any
Moment","popup_donate_to":"Donate
to","extension_id":null},"prefs":{"desktopNot=
ification":true,"soundNotification":false,"logLevel&quo=
t;:0,"enable":true,"loop":false,"hidePopup":t=
rue,"autoPlay":false,"autoBuffer":false,"autoPlayO=
nBuffer":false,"autoPlayOnBufferPercentage":42,"autoPla=
yOnSmartBuffer":true,"quality":"default","fsh=
d":false,"onlyNotification":true,"enableFullScreen"=
;:true,"saveBandwidth":false,"hideAnnotations":true,&qu=
ot;turnOffPagedBuffering":true}}"
event=3D"preferencesUpdated" id=3D"myTubeRelayElementToPage"></mytube=
element><mytubeelement
data=3D"{"loadBundle":true}" event=3D"relayPrefs"
id=3D"myTubeRelayElementToTab"></mytubeelement>
</body>
</html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--------------030706020909080603020201--
.
Author: David Krauss <potswa@gmail.com>
Date: Mon, 7 Jul 2014 07:56:26 +0800
Raw View
--Apple-Mail=_F76A9250-AB72-43AB-B32B-BF2ADA2FF4A6
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1
On 2014-07-07, at 7:26 AM, Corentin Schreiber <corentin.schreiber@cea.fr> w=
rote:
> I believe case [1] is ok and straightforward, although it can still can b=
e replaced by
> auto rsn =3D packet::connection_failed::reason_t::too_many_clients;
> This is not applicable to member initializer lists though.
Yes, auto is generally a bit brittle.
> Case [2] can be tricky to mix with overload resolution and template type =
deduction, but that should be doable as well. Is it worth the trouble, I do=
n't know.
I think function arguments are the most common case. There was some discuss=
ion here a while back, "function-local enumerators." An almost-equivalent f=
eature was proposed independent of the other cases of enumeration initializ=
ation. Yes, it's tricky to mix with overload resolution. I think it would b=
e worth the trouble, but a better approach to feature proposal might be to =
elaborate the simpler cases first, and then suggest overloading as a future=
direction.
Since function-call and braced-ini-list syntaxes are both used roughly equi=
valently to initialize objects, ideally they should work the same way.
> The switch however is probably where enums are used most, so I would thin=
k there is a substantial amount of clarity to be gained here for very littl=
e cost.
Well, many folks simply never use switch.
> That's true, I didn't realize you could do that. Now that is still some u=
nnecessary typing, given that the actual type of 'p.reason' is known to the=
compiler.
OK, you can say using reason_t =3D decltype(p.reason);. If you're feeling r=
eally meta, you can make a macro:
#define E_SWITCH( EXPR ) \
switch( EXPR ) { \
typedef decltype( EXPR ) case_t;
This only works for controlling expressions, not declarations.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--Apple-Mail=_F76A9250-AB72-43AB-B32B-BF2ADA2FF4A6
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;07–07, at 7:26 AM, Corentin Schreiber <<a href=3D"mailto:cor=
entin.schreiber@cea.fr">corentin.schreiber@cea.fr</a>> wrote:</div><br c=
lass=3D"Apple-interchange-newline"><blockquote type=3D"cite">
=20
<meta content=3D"text/html; charset=3DISO-8859-1" http-equiv=3D"Content=
-Type">
=20
<div bgcolor=3D"#FFFFFF" text=3D"#000000"><div>I believe case [1] is ok a=
nd straightforward, although it can
still can be replaced by<br>
<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"prettypri=
nt">
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"" class=3D"styled-by-pret=
tify"> rsn </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><code class=3D"prettyprint"><span style=3D"" class=3D"styled-by-=
prettify"> packet</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"" class=3D"styled-by-prettify">connection_fa=
iled</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"" class=3D"styled-by-prettify">reason_t::</span></code><c=
ode class=3D"prettyprint"><span style=3D"" class=3D"styled-by-prettify">too=
_many_clients</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span></code></div>
</code></div>
This is not applicable to member initializer lists though.<br></div><=
/div></blockquote><div><br></div><div>Yes, <font face=3D"Courier">auto</fon=
t> is generally a bit brittle.</div><br><blockquote type=3D"cite"><div bgco=
lor=3D"#FFFFFF" text=3D"#000000"><div>
=20
Case [2] can be tricky to mix with overload resolution and
template type deduction, but that should be doable as well. Is it
worth the trouble, I don't know.</div></div></blockquote><div><br></d=
iv><div>I think function arguments are the most common case. There was some=
discussion here a while back, “function-local enumerators.” An=
almost-equivalent feature was proposed independent of the other cases of e=
numeration initialization. Yes, it’s tricky to mix with overload reso=
lution. I think it would be worth the trouble, but a better approach to fea=
ture proposal might be to elaborate the simpler cases first, and then sugge=
st overloading as a future direction.</div><div><br></div><div>Since functi=
on-call and braced-ini-list syntaxes are both used roughly equivalently to =
initialize objects, ideally they should work the same way.</div><br><blockq=
uote type=3D"cite"><div bgcolor=3D"#FFFFFF" text=3D"#000000"><div>The switc=
h however is probably
where enums are used most, so I would think there is a substantial
amount of clarity to be gained here for very little cost.<br></div></=
div></blockquote><div><br></div><div>Well, many folks simply never use <fon=
t face=3D"Courier">switch</font>.</div><br><blockquote type=3D"cite"><div b=
gcolor=3D"#FFFFFF" text=3D"#000000"><div>That's true, I didn't realize you =
could do that. Now that is still
some unnecessary typing, given that the actual type of 'p.reason'
is known to the compiler.</div></div></blockquote><br></div><div>OK, =
you can say <font face=3D"Courier">using reason_t =3D decltype(p.reason);</=
font>. If you’re feeling really meta, you can make a macro:</div><div=
><br></div><div><font face=3D"Courier">#define E_SWITCH( EXPR ) \</font></d=
iv><div><font face=3D"Courier"> switch( EXPR ) { \</font></div=
><div><font face=3D"Courier"> typedef decltype( =
EXPR ) case_t;</font></div><div><br></div>This only works for controlling e=
xpressions, not declarations.<div><br></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_F76A9250-AB72-43AB-B32B-BF2ADA2FF4A6--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 7 Jul 2014 03:30:05 -0700 (PDT)
Raw View
------=_Part_145_17735461.1404729005179
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Monday, 7 July 2014 00:56:39 UTC+1, David Krauss wrote:
> OK, you can say using reason_t =3D decltype(p.reason);. If you=E2=80=99r=
e feeling=20
> really meta, you can make a macro:
>
> #define E_SWITCH( EXPR ) \
> switch( EXPR ) { \
> typedef decltype( EXPR ) case_t;
>
> This only works for controlling expressions, not declarations.=20
>
> Hmm, so any use of E_SWITCH would necessitate an unmatched close brace?
=20
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_145_17735461.1404729005179
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><DIV><BR>On Monday, 7 July 2014 00:56:39 UTC+1, David Krau=
ss wrote:</DIV>
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>
<DIV style=3D"WORD-WRAP: break-word">
<DIV>OK, you can say <FONT face=3DCourier>using reason_t =3D decltype(p.rea=
son);</FONT>. If you=E2=80=99re feeling really meta, you can make a macro:<=
/DIV>
<DIV><BR></DIV>
<DIV><FONT face=3DCourier>#define E_SWITCH( EXPR ) \</FONT></DIV>
<DIV><FONT face=3DCourier> switch( EXPR ) { \</FONT></DIV>
<DIV><FONT face=3DCourier> typedef decltype( EXP=
R ) case_t;</FONT></DIV>
<DIV><BR></DIV>This only works for controlling expressions, not declaration=
s.=20
<DIV><BR></DIV></DIV></BLOCKQUOTE>
<DIV>Hmm, so any use of E_SWITCH would necessitate an unmatched close brace=
?</DIV>
<DIV> </DIV></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_145_17735461.1404729005179--
.
Author: David Krauss <potswa@gmail.com>
Date: Mon, 7 Jul 2014 18:47:35 +0800
Raw View
--Apple-Mail=_84D44EBF-720A-4E64-9407-C373BB24DE9F
Content-Type: text/plain; charset=ISO-8859-1
On 2014-07-07, at 6:30 PM, Douglas Boffey <douglas.boffey@gmail.com> wrote:
>
> On Monday, 7 July 2014 00:56:39 UTC+1, David Krauss wrote:
> OK, you can say using reason_t = decltype(p.reason);. If you're feeling really meta, you can make a macro:
>
> #define E_SWITCH( EXPR ) \
> switch( EXPR ) { \
> typedef decltype( EXPR ) case_t;
>
> This only works for controlling expressions, not declarations.
>
> Hmm, so any use of E_SWITCH would necessitate an unmatched close brace?
I'm not being particularly serious. Actually doing this sort of thing involves a game-plan to make it usable. However, it is significant that the boilerplate is reduced to something tractable even to the preprocessor.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--Apple-Mail=_84D44EBF-720A-4E64-9407-C373BB24DE9F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;07–07, at 6:30 PM, Douglas Boffey <<a href=3D"mailto:douglas=
..boffey@gmail.com">douglas.boffey@gmail.com</a>> wrote:</div><br class=
=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><=
div><br>On Monday, 7 July 2014 00:56:39 UTC+1, David Krauss wrote:</div>
<blockquote style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3D"gmail_quote">
<div style=3D"WORD-WRAP: break-word">
<div>OK, you can say <font face=3D"Courier">using reason_t =3D decltype(p.r=
eason);</font>. If you’re feeling really meta, you can make a macro:<=
/div>
<div><br></div>
<div><font face=3D"Courier">#define E_SWITCH( EXPR ) \</font></div>
<div><font face=3D"Courier"> switch( EXPR ) { \</font></div>
<div><font face=3D"Courier"> typedef decltype( E=
XPR ) case_t;</font></div>
<div><br></div>This only works for controlling expressions, not declaration=
s.=20
<div><br></div></div></blockquote>
<div>Hmm, so any use of E_SWITCH would necessitate an unmatched close brace=
?</div>
</div></blockquote><br></div><div>I’m not being particularly serious.=
Actually doing this sort of thing involves a game-plan to make it usable. =
However, it is significant that the boilerplate is reduced to something tra=
ctable even to the preprocessor.</div><div><br></div></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--Apple-Mail=_84D44EBF-720A-4E64-9407-C373BB24DE9F--
.