Topic: Hierarchical enumerations
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Mon, 1 Sep 2014 04:41:28 -0700 (PDT)
Raw View
------=_Part_1083_679449981.1409571688361
Content-Type: text/plain; charset=UTF-8
How about extending and restricting existing enumerations, for example,
given the definition:
enum class Weekday {Monday, Tuesday, Wednesday, Thursday, Friday};
allowing this to be extended, thus:
enum class Day : Weekday {Saturday, Sunday};
This would allow Day to have all the members of Weekday, plus Saturday and
Sunday. Weekday can be coerced to Day, but not vice-versa.
Contriwise, given the definition:
enum class Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
Sunday};
should that be able to be restricted, thus:
enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
Again, the Weekday can be coerced to Day, but not the other way round.
--
---
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_1083_679449981.1409571688361
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">How about extending and restricting existing enumerations,=
for example, given the definition:<br><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 clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">enum</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Weekday</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: #606;" class=3D"styled-by-prettify">Monday</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: #6=
06;" class=3D"styled-by-prettify">Tuesday</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: #606;" class=3D"style=
d-by-prettify">Wednesday</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Thur=
sday</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">Friday</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br><br></span></div></code></div><b=
r><br>allowing this to be extended, thus:<br><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;"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color:=
#008;" class=3D"styled-by-prettify">enum</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">class</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Day</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">Weekday</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">Saturday</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Sunday</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r><br></span></div></code></div><br><br>This would allow Day to have all th=
e members of Weekday, plus Saturday and Sunday. Weekday can be coerce=
d to Day, but not vice-versa.<br><br>Contriwise, given the definition:<br><=
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"subprett=
yprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">enum</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">class</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Day</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: #606;" class=3D"style=
d-by-prettify">Monday</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: #606;" class=3D"styled-by-prettify">Tuesday=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Wednesday</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: #606;" =
class=3D"styled-by-prettify">Thursday</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">Friday</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Saturday</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Sunday</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br><br></span></div></code></div><br>should =
that be able to be restricted, thus:<br><br><div class=3D"prettyprint" styl=
e=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187)=
; border-style: solid; border-width: 1px; word-wrap: break-word;"><code cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">enum</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Weekday</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 styl=
e=3D"color: #606;" class=3D"styled-by-prettify">Day</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">[</span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Monday</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-=
prettify">Tuesday</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">Wednesday</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Thursday</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: #606;" =
class=3D"styled-by-prettify">Friday</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">];</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br></span></div></code></div><br>Again, the Weekday c=
an be coerced to Day, but not the other way round.<br><br></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_1083_679449981.1409571688361--
.
Author: Pablo Oliva <pabloliva87@gmail.com>
Date: Mon, 1 Sep 2014 10:27:41 -0300
Raw View
--047d7bb03ee2a162c0050200f7c0
Content-Type: text/plain; charset=UTF-8
It sounds really interesting. Just a couple of questions, to clarify:
Would multiple inheritance be allowed?
Could you inherit from an enumeration with a different underlying type? For
instance:
enum A : short int {x,y,z};
enum B : long int A {v,w}; // Valid? How is it handled?
2014-09-01 8:41 GMT-03:00 Douglas Boffey <douglas.boffey@gmail.com>:
> How about extending and restricting existing enumerations, for example,
> given the definition:
>
> enum class Weekday {Monday, Tuesday, Wednesday, Thursday, Friday};
>
>
>
> allowing this to be extended, thus:
>
> enum class Day : Weekday {Saturday, Sunday};
>
>
>
> This would allow Day to have all the members of Weekday, plus Saturday and
> Sunday. Weekday can be coerced to Day, but not vice-versa.
>
> Contriwise, given the definition:
>
> enum class Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
> Sunday};
>
>
> should that be able to be restricted, thus:
>
> enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
>
>
> Again, the Weekday can be coerced to Day, but not the other way round.
>
> --
>
> ---
> 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/.
>
--
---
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/.
--047d7bb03ee2a162c0050200f7c0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">It sounds really interesting. Just a couple of questions, =
to clarify:<div><br></div><div>Would multiple inheritance be allowed?</div>=
<div><br></div><div>Could you inherit from an enumeration with a different =
underlying type? For instance:<br>
</div><div><br></div><div><pre style=3D"margin-top:0px;margin-bottom:0px;co=
lor:rgb(0,0,0);font-size:12px"><code><var style=3D"font-style:normal;color:=
rgb(0,0,176)">enum</var> A : <var style=3D"font-style:normal;color:rgb(0,0,=
176)">short int</var> {x,y,z};</code></pre>
<pre style=3D"margin-top:0px;margin-bottom:0px;color:rgb(0,0,0);font-size:1=
2px"><code><br></code></pre><pre style=3D"margin-top:0px;margin-bottom:0px;=
color:rgb(0,0,0);font-size:12px"><code>enum B : long int A {v,w}; // Valid?=
How is it handled?</code></pre>
</div></div><div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">2=
014-09-01 8:41 GMT-03:00 Douglas Boffey <span dir=3D"ltr"><<a href=3D"ma=
ilto:douglas.boffey@gmail.com" target=3D"_blank">douglas.boffey@gmail.com</=
a>></span>:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">How about extending and res=
tricting existing enumerations, for example, given the definition:<br><br><=
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">enum</span><span style=3D"color:#000"=
> </span><span style=3D"color:#008">class</span><span style=3D"color:#000">=
</span><span style=3D"color:#606">Weekday</span><span style=3D"color:#000"=
> </span><span style=3D"color:#660">{</span><span style=3D"color:#606">Mond=
ay</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#606">Tuesday</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> </span><span style=3D"color:#606">Wednesda=
y</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#606">Thursday</span><span style=3D"color:#660">,</=
span><span style=3D"color:#000"> </span><span style=3D"color:#606">Friday</=
span><span style=3D"color:#660">};</span><span style=3D"color:#000"><br>
<br></span></div></code></div><br><br>allowing this to be extended, thus:<b=
r><br><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><d=
iv>
<span style=3D"color:#008">enum</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#008">class</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#606">Day</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">:</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Weekday</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#660">{</span><span style=3D"color:#606">Saturday</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Sunday</span><span style=3D"color:#660">};</span><span styl=
e=3D"color:#000"><br>
<br></span></div></code></div><br><br>This would allow Day to have all the =
members of Weekday, plus Saturday and Sunday.=C2=A0 Weekday can be coerced =
to Day, but not vice-versa.<br><br>Contriwise, given the definition:<br><br=
>
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px;word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">enum</span><span style=3D"color:#000"> </span><span=
style=3D"color:#008">class</span><span style=3D"color:#000"> </span><span =
style=3D"color:#606">Day</span><span style=3D"color:#000"> </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#606">Monday</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">Tuesday</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#606">Wednesday</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Thursday</span><span style=3D"color:#660">,</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#606">Friday</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">Saturday</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#606">Sunday</span><span style=
=3D"color:#660">};</span><span style=3D"color:#000"><br>
<br></span></div></code></div><br>should that be able to be restricted, thu=
s:<br><br><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"><cod=
e><div>
<span style=3D"color:#008">enum</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#008">class</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#606">Weekday</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">:</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#606">Day</span><span style=3D"color:#660">[</span><span styl=
e=3D"color:#606">Monday</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#606">Tuesday</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">Wednesday</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000"> </span><span style=3D"color:#606">Thursday</span><span sty=
le=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=3D=
"color:#606">Friday</span><span style=3D"color:#660">];</span><span style=
=3D"color:#000"><br>
<br></span></div></code></div><br>Again, the Weekday can be coerced to Day,=
but not the other way round.<span class=3D"HOEnZb"><font color=3D"#888888"=
><br><br></font></span></div><span class=3D"HOEnZb"><font color=3D"#888888"=
>
<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" target=3D"_=
blank">std-proposals+unsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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 />
--047d7bb03ee2a162c0050200f7c0--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Tue, 2 Sep 2014 04:54:57 -0700 (PDT)
Raw View
------=_Part_21_391052959.1409658897907
Content-Type: text/plain; charset=UTF-8
On Monday, 1 September 2014 14:27:44 UTC+1, Pablo Oliva wrote:
>
> It sounds really interesting. Just a couple of questions, to clarify:
>
> Would multiple inheritance be allowed?
>
> The only problem I see with multiple inheritance is that the base enums
would generally have overlapping values. Otherwise, I would say yes.
If base enums have the same tag name, the tags must be qualified with the
base name, not the derived name.
> Could you inherit from an enumeration with a different underlying type?
> For instance:
>
> enum A : short int {x,y,z};
>
>
> enum B : long int A {v,w}; // Valid? How is it handled?
>
>
>
>
>
Possibly. If so, B::x == 0L, B::y == 1L, B::z == 2L, B::v == 3L and B::w
== 4L.
The default value for the first extension tag (v in your example) would be
max(base tags) + 1.
As far as any conversions from A to B are concerned, it would be just like
converting from the base type short int to long int. Although in the OP, I
mentioned about coercion in the safe direction, I would expect to be able
to static_cast in the opposite direction.
>
>
2014-09-01 8:41 GMT-03:00 Douglas Boffey <douglas...@gmail.com <javascript:>
> >:
>
>> How about extending and restricting existing enumerations, for example,
>> given the definition:
>>
>> enum class Weekday {Monday, Tuesday, Wednesday, Thursday, Friday};
>>
>>
>>
>> allowing this to be extended, thus:
>>
>> enum class Day : Weekday {Saturday, Sunday};
>>
>>
>>
>> This would allow Day to have all the members of Weekday, plus Saturday
>> and Sunday. Weekday can be coerced to Day, but not vice-versa.
>>
>> Contriwise, given the definition:
>>
>> enum class Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
>> Sunday};
>>
>>
>> should that be able to be restricted, thus:
>>
>> enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
>>
>>
>> Again, the Weekday can be coerced to Day, but not the other way round.
>>
>> --
>>
>> ---
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
--
---
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_21_391052959.1409658897907
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br>On Monday, 1 September 2014 14:27:44 UTC+1, Pablo Oliv=
a wrote:<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex;=
border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left=
-style: solid;" class=3D"gmail_quote"><div dir=3D"ltr">It sounds really int=
eresting. Just a couple of questions, to clarify:<div><br></div><div>Would =
multiple inheritance be allowed?</div><div><br></div></div></blockquote><di=
v>The only problem I see with multiple inheritance is that the base en=
ums would generally have overlapping values. Otherwise, I w=
ould say yes. If base enums have the same tag name, th=
e tags must be qualified with the base name, not the derived name.</div><bl=
ockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left=
-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: soli=
d;" class=3D"gmail_quote"><div dir=3D"ltr"><div></div><div>Could you inheri=
t from an enumeration with a different underlying type? For instance:<br>
</div><div><br></div><div><pre style=3D"color: rgb(0, 0, 0); font-size: 12p=
x; margin-top: 0px; margin-bottom: 0px;"><code><var style=3D"color: rgb(0, =
0, 176); font-style: normal;">enum</var> A : <var style=3D"color: rgb(0, 0,=
176); font-style: normal;">short int</var> {x,y,z};</code></pre>
<pre style=3D"color: rgb(0, 0, 0); font-size: 12px; margin-top: 0px; margin=
-bottom: 0px;"><code><br></code></pre><pre style=3D"color: rgb(0, 0, 0); fo=
nt-size: 12px; margin-top: 0px; margin-bottom: 0px;"><code>enum B : long in=
t A {v,w}; // Valid? How is it handled?</code></pre>
</div></div><div><br><br> </div></blockquote><div>Possibly. If s=
o, B::x =3D=3D 0L, B::y =3D=3D 1L, B::z =3D=3D 2L, B::v =3D=3D 3L and B::w =
=3D=3D 4L.</div><div> </div><div>The default value for the first exten=
sion tag (v in your example) would be max(base tags) + 1.</div><div> <=
/div><div>As far as any conversions from A to B are concerned, it would be =
just like converting from the base type short int to long int. Althou=
gh in the OP, I mentioned about coercion in the safe direction, I would exp=
ect to be able to static_cast in the opposite direction.</div><blockquote s=
tyle=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rg=
b(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class=
=3D"gmail_quote"><div> </div></blockquote><blockquote style=3D"margin:=
0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204=
); border-left-width: 1px; border-left-style: solid;" class=3D"gmail_quote"=
><div><div class=3D"gmail_quote">2014-09-01 8:41 GMT-03:00 Douglas Boffey <=
span dir=3D"ltr"><<a onmousedown=3D"this.href=3D'javascript:';return tru=
e;" onclick=3D"this.href=3D'javascript:';return true;" href=3D"javascript:"=
target=3D"_blank" gdf-obfuscated-mailto=3D"r5YkyQo61-YJ">douglas...@gmail.=
com</a>></span>:<br>
<blockquote style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-l=
eft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: s=
olid;" class=3D"gmail_quote"><div dir=3D"ltr">How about extending and restr=
icting existing enumerations, for example, given the definition:<br><br><di=
v style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; bac=
kground-color: rgb(250, 250, 250);">
<code><div><span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(102, 0, 102);">Weekday</span><span style=3D"color: rgb(0, 0, 0);"> </spa=
n><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rg=
b(102, 0, 102);">Monday</span><span style=3D"color: rgb(102, 102, 0);">,</s=
pan><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(=
102, 0, 102);">Tuesday</span><span style=3D"color: rgb(102, 102, 0);">,</sp=
an><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(1=
02, 0, 102);">Wednesday</span><span style=3D"color: rgb(102, 102, 0);">,</s=
pan><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(=
102, 0, 102);">Thursday</span><span style=3D"color: rgb(102, 102, 0);">,</s=
pan><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(=
102, 0, 102);">Friday</span><span style=3D"color: rgb(102, 102, 0);">};</sp=
an><span style=3D"color: rgb(0, 0, 0);"><br>
<br></span></div></code></div><br><br>allowing this to be extended, thus:<b=
r><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-=
word; background-color: rgb(250, 250, 250);"><code><div>
<span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, =
102);">Day</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rgb(0, 0, 0);">=
</span><span style=3D"color: rgb(102, 0, 102);">Weekday</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">=
{</span><span style=3D"color: rgb(102, 0, 102);">Saturday</span><span style=
=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);">=
</span><span style=3D"color: rgb(102, 0, 102);">Sunday</span><span style=
=3D"color: rgb(102, 102, 0);">};</span><span style=3D"color: rgb(0, 0, 0);"=
><br>
<br></span></div></code></div><br><br>This would allow Day to have all the =
members of Weekday, plus Saturday and Sunday. Weekday can be coerced =
to Day, but not vice-versa.<br><br>Contriwise, given the definition:<br><br=
>
<div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-word; =
background-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb=
(0, 0, 136);">enum</span><span style=3D"color: rgb(0, 0, 0);"> </span><span=
style=3D"color: rgb(0, 0, 136);">class</span><span style=3D"color: rgb(0, =
0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">Day</span><span st=
yle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0)=
;">{</span><span style=3D"color: rgb(102, 0, 102);">Monday</span><span styl=
e=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"=
> </span><span style=3D"color: rgb(102, 0, 102);">Tuesday</span><span style=
=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);">=
</span><span style=3D"color: rgb(102, 0, 102);">Wednesday</span><span styl=
e=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"=
> </span><span style=3D"color: rgb(102, 0, 102);">Thursday</span><span styl=
e=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"=
> </span><span style=3D"color: rgb(102, 0, 102);">Friday</span><span style=
=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);">=
</span><span style=3D"color: rgb(102, 0, 102);">Saturday</span><span style=
=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);">=
</span><span style=3D"color: rgb(102, 0, 102);">Sunday</span><span style=
=3D"color: rgb(102, 102, 0);">};</span><span style=3D"color: rgb(0, 0, 0);"=
><br>
<br></span></div></code></div><br>should that be able to be restricted, thu=
s:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: br=
eak-word; background-color: rgb(250, 250, 250);"><code><div>
<span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, =
102);">Weekday</span><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rgb(0, 0, 0);=
"> </span><span style=3D"color: rgb(102, 0, 102);">Day</span><span style=3D=
"color: rgb(102, 102, 0);">[</span><span style=3D"color: rgb(102, 0, 102);"=
>Monday</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">=
Tuesday</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">=
Wednesday</span><span style=3D"color: rgb(102, 102, 0);">,</span><span styl=
e=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);"=
>Thursday</span><span style=3D"color: rgb(102, 102, 0);">,</span><span styl=
e=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);"=
>Friday</span><span style=3D"color: rgb(102, 102, 0);">];</span><span style=
=3D"color: rgb(0, 0, 0);"><br>
<br></span></div></code></div><br>Again, the Weekday can be coerced to Day,=
but not the other way round.<span><font color=3D"#888888"><br><br></font><=
/span></div><span><font color=3D"#888888">
<p></p>
-- <br>
<br>
--- <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 onmousedown=3D"this.href=3D'javascript:';return true;" onclick=
=3D"this.href=3D'javascript:';return true;" href=3D"javascript:" target=3D"=
_blank" gdf-obfuscated-mailto=3D"r5YkyQo61-YJ">std-proposal...@<wbr>isocpp.=
org</a>.<br>
To post to this group, send email to <a onmousedown=3D"this.href=3D'javascr=
ipt:';return true;" onclick=3D"this.href=3D'javascript:';return true;" href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"r5YkyQo61-YJ">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;" hr=
ef=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" target=3D=
"_blank">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</font></span></blockquote></div><br></div>
</blockquote></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_21_391052959.1409658897907--
.
Author: oggy22@gmail.com
Date: Thu, 25 Sep 2014 17:19:51 -0700 (PDT)
Raw View
------=_Part_197_1714384639.1411690792066
Content-Type: text/plain; charset=UTF-8
I think that's an excellent idea as well, and actually I was going to
propose the very similar thing. Just a few things:
I think this should be called strictly "extension" rather than
"inheritance", the reason being that these two have quite opposite meaning.
The inheritance specializes on the base class limiting the space of
possibilities, while the extension extends it. Accordingly your syntax
might impose a problem because it looks like inheritance while it's not.
This involves, for examples, teachability issues. I am not sure what might
be the best syntax but I am considering something along these lines:
enum class Day : using Weekday { Saturday, Sunday };enum class Day : extends Weekday { Saturday, Sunday };enum class Day { using Weekday ; Saturday, Sunday };enum class Day { using Weekday , Saturday, Sunday };
As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
it does not follow the DRY principle (Do Not Repeat Yourself). Anyways, this one (the opposite direction) should be called inheritance though.
On Monday, September 1, 2014 4:41:28 AM UTC-7, Douglas Boffey wrote:
How about extending and restricting existing enumerations, for example,
> given the definition:
>
> enum class Weekday {Monday, Tuesday, Wednesday, Thursday, Friday};
>
>
>
> allowing this to be extended, thus:
>
> enum class Day : Weekday {Saturday, Sunday};
>
>
>
> This would allow Day to have all the members of Weekday, plus Saturday and
> Sunday. Weekday can be coerced to Day, but not vice-versa.
>
> Contriwise, given the definition:
>
> enum class Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
> Sunday};
>
>
> should that be able to be restricted, thus:
>
> enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
>
>
> Again, the Weekday can be coerced to Day, but not the other way round.
>
>
--
---
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_197_1714384639.1411690792066
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I think that's an excellent idea as well, and actuall=
y I was going to propose the very similar thing. Just a few things:</d=
iv><div>I think this should be called strictly "extension" rather than "inh=
eritance", the reason being that these two have quite opposite meaning. The=
inheritance specializes on the base class limiting the space of possibilit=
ies, while the extension extends it. Accordingly your syntax might imp=
ose a problem because it looks like inheritance while it's not. This involv=
es, for examples, teachability issues. I am not sure what might b=
e the best syntax but I am considering something along these lines:</div><d=
iv><pre style=3D"color: rgb(0, 0, 0); text-transform: none; line-height: no=
rmal; text-indent: 0px; letter-spacing: normal; font-style: normal; font-va=
riant: normal; font-weight: normal; word-spacing: 0px; -webkit-text-stroke-=
width: 0px;"><code><span style=3D"color: rgb(0, 0, 136);"><br></span></code=
></pre><pre style=3D"color: rgb(0, 0, 0); text-transform: none; line-height=
: normal; text-indent: 0px; letter-spacing: normal; font-style: normal; fon=
t-variant: normal; font-weight: normal; word-spacing: 0px; -webkit-text-str=
oke-width: 0px;"><code><span style=3D"color: rgb(0, 0, 136);">enum</span><s=
pan style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, =
136);">class</span><span style=3D"color: rgb(0, 0, 0);"> <span style=3D"col=
or: rgb(102, 0, 102);">Day</span><span style=3D"color: rgb(0, 0, 0);"> </sp=
an><span style=3D"color: rgb(102, 102, 0);"></span></span>: using <span sty=
le=3D"color: rgb(102, 0, 102);">Weekday</span><span style=3D"color: rgb(0, =
0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);"></span> { <span st=
yle=3D"color: rgb(102, 0, 102);">Saturday</span><span style=3D"color: rgb(1=
02, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </span><span st=
yle=3D"color: rgb(102, 0, 102);">Sunday </span><span style=3D"color: rgb(10=
2, 102, 0);"></span>};
<span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class</span><spa=
n style=3D"color: rgb(0, 0, 0);"> <span style=3D"color: rgb(102, 0, 102);">=
Day</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(102, 102, 0);"></span></span>: extends <span style=3D"color: rgb(102,=
0, 102);">Weekday</span><span style=3D"color: rgb(0, 0, 0);"> </span><span=
style=3D"color: rgb(102, 102, 0);"></span> { <span style=3D"color: rgb(102=
, 0, 102);">Saturday</span><span style=3D"color: rgb(102, 102, 0);">,</span=
><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102=
, 0, 102);">Sunday </span><span style=3D"color: rgb(102, 102, 0);"></span>}=
;
<span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class</span><spa=
n style=3D"color: rgb(0, 0, 0);"> <span style=3D"color: rgb(102, 0, 102);">=
Day</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(102, 102, 0);"></span></span>{ using <span style=3D"color: rgb(102, 0=
, 102);">Weekday</span><span style=3D"color: rgb(0, 0, 0);"> </span><span s=
tyle=3D"color: rgb(102, 102, 0);"></span>; <span style=3D"color: rgb(102, 0=
, 102);">Saturday</span><span style=3D"color: rgb(102, 102, 0);">,</span><s=
pan style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0=
, 102);">Sunday</span><span style=3D"color: rgb(102, 102, 0);"></span> };
<span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D"color: rgb=
(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class</span><spa=
n style=3D"color: rgb(0, 0, 0);"> <span style=3D"color: rgb(102, 0, 102);">=
Day</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(102, 102, 0);"></span></span>{ using <span style=3D"color: rgb(102, 0=
, 102);">Weekday</span><span style=3D"color: rgb(0, 0, 0);"> </span><span s=
tyle=3D"color: rgb(102, 102, 0);"></span>, <span style=3D"color: rgb(102, 0=
, 102);">Saturday</span><span style=3D"color: rgb(102, 102, 0);">,</span><s=
pan style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0=
, 102);">Sunday</span><span style=3D"color: rgb(102, 102, 0);"></span> };</=
code></pre><pre style=3D"color: rgb(0, 0, 0); text-transform: none; line-he=
ight: normal; text-indent: 0px; letter-spacing: normal; font-style: normal;=
font-variant: normal; font-weight: normal; word-spacing: 0px; -webkit-text=
-stroke-width: 0px;"><code><br></code></pre><pre style=3D"color: rgb(0, 0, =
0); text-transform: none; line-height: normal; text-indent: 0px; letter-spa=
cing: normal; font-style: normal; font-variant: normal; font-weight: normal=
; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><code>As for <span st=
yle=3D"color: rgb(0, 0, 136);">enum</span><span style=3D"color: rgb(0, 0, 0=
);"> </span><span style=3D"color: rgb(0, 0, 136);">class</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">=
Weekday</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"c=
olor: rgb(102, 102, 0);">:</span><span style=3D"color: rgb(0, 0, 0);"> </sp=
an><span style=3D"color: rgb(102, 0, 102);">Day</span><span style=3D"color:=
rgb(102, 102, 0);">[</span><span style=3D"color: rgb(102, 0, 102);">Monday=
</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"colo=
r: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">Tuesday<=
/span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color=
: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">Wednesday=
</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"colo=
r: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">Thursday=
</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"colo=
r: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">Friday</=
span><span style=3D"color: rgb(102, 102, 0);">];</span><span style=3D"color=
: rgb(0, 0, 0);"><br></span></code>it does not follow the DRY principle (Do=
Not Repeat Yourself). Anyways, this one (the opposite direction) should be=
called inheritance though.</pre><pre style=3D"color: rgb(0, 0, 0); text-tr=
ansform: none; line-height: normal; text-indent: 0px; letter-spacing: norma=
l; font-style: normal; font-variant: normal; font-weight: normal; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px;"><br>On Monday, September 1, 2014=
4:41:28 AM UTC-7, Douglas Boffey wrote:</pre></div><blockquote class=3D"gm=
ail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-le=
ft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: so=
lid;"><div dir=3D"ltr">How about extending and restricting existing enumera=
tions, for example, given the definition:<br><br><div style=3D"border: 1px =
solid rgb(187, 187, 187); border-image: none; -ms-word-wrap: break-word; ba=
ckground-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0=
, 0, 136);">enum</span><span style=3D"color: rgb(0, 0, 0);"> </span><span s=
tyle=3D"color: rgb(0, 0, 136);">class</span><span style=3D"color: rgb(0, 0,=
0);"> </span><span style=3D"color: rgb(102, 0, 102);">Weekday</span><span =
style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, =
0);">{</span><span style=3D"color: rgb(102, 0, 102);">Monday</span><span st=
yle=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(102, 0, 102);">Tuesday</span><span sty=
le=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);=
"> </span><span style=3D"color: rgb(102, 0, 102);">Wednesday</span><span st=
yle=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(102, 0, 102);">Thursday</span><span st=
yle=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(102, 0, 102);">Friday</span><span styl=
e=3D"color: rgb(102, 102, 0);">};</span><span style=3D"color: rgb(0, 0, 0);=
"><br><br></span></div></code></div><br><br>allowing this to be extended, t=
hus:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); border-imag=
e: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, 250);">=
<code><div><span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(102, 0, 102);">Day</span><span style=3D"color: rgb(0, 0, 0);"> </span><s=
pan style=3D"color: rgb(102, 102, 0);">:</span><span style=3D"color: rgb(0,=
0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">Weekday</span><sp=
an style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 10=
2, 0);">{</span><span style=3D"color: rgb(102, 0, 102);">Saturday</span><sp=
an style=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, =
0, 0);"> </span><span style=3D"color: rgb(102, 0, 102);">Sunday</span><span=
style=3D"color: rgb(102, 102, 0);">};</span><span style=3D"color: rgb(0, 0=
, 0);"><br><br></span></div></code></div><br><br>This would allow Day to ha=
ve all the members of Weekday, plus Saturday and Sunday. Weekday can =
be coerced to Day, but not vice-versa.<br><br>Contriwise, given the definit=
ion:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); border-imag=
e: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, 250);">=
<code><div><span style=3D"color: rgb(0, 0, 136);">enum</span><span style=3D=
"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">class=
</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: r=
gb(102, 0, 102);">Day</span><span style=3D"color: rgb(0, 0, 0);"> </span><s=
pan style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(10=
2, 0, 102);">Monday</span><span style=3D"color: rgb(102, 102, 0);">,</span>=
<span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102,=
0, 102);">Tuesday</span><span style=3D"color: rgb(102, 102, 0);">,</span><=
span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, =
0, 102);">Wednesday</span><span style=3D"color: rgb(102, 102, 0);">,</span>=
<span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102,=
0, 102);">Thursday</span><span style=3D"color: rgb(102, 102, 0);">,</span>=
<span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102,=
0, 102);">Friday</span><span style=3D"color: rgb(102, 102, 0);">,</span><s=
pan style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0=
, 102);">Saturday</span><span style=3D"color: rgb(102, 102, 0);">,</span><s=
pan style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 0=
, 102);">Sunday</span><span style=3D"color: rgb(102, 102, 0);">};</span><sp=
an style=3D"color: rgb(0, 0, 0);"><br><br></span></div></code></div><br>sho=
uld that be able to be restricted, thus:<br><br><div style=3D"border: 1px s=
olid rgb(187, 187, 187); border-image: none; -ms-word-wrap: break-word; bac=
kground-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rgb(0,=
0, 136);">enum</span><span style=3D"color: rgb(0, 0, 0);"> </span><span st=
yle=3D"color: rgb(0, 0, 136);">class</span><span style=3D"color: rgb(0, 0, =
0);"> </span><span style=3D"color: rgb(102, 0, 102);">Weekday</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0=
);">:</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"col=
or: rgb(102, 0, 102);">Day</span><span style=3D"color: rgb(102, 102, 0);">[=
</span><span style=3D"color: rgb(102, 0, 102);">Monday</span><span style=3D=
"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </=
span><span style=3D"color: rgb(102, 0, 102);">Tuesday</span><span style=3D"=
color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </s=
pan><span style=3D"color: rgb(102, 0, 102);">Wednesday</span><span style=3D=
"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </=
span><span style=3D"color: rgb(102, 0, 102);">Thursday</span><span style=3D=
"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"> </=
span><span style=3D"color: rgb(102, 0, 102);">Friday</span><span style=3D"c=
olor: rgb(102, 102, 0);">];</span><span style=3D"color: rgb(0, 0, 0);"><br>=
<br></span></div></code></div><br>Again, the Weekday can be coerced to Day,=
but not the other way round.<br><br></div></blockquote></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_197_1714384639.1411690792066--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Fri, 26 Sep 2014 07:45:08 -0700 (PDT)
Raw View
------=_Part_234_1428828013.1411742708836
Content-Type: text/plain; charset=UTF-8
On Friday, 26 September 2014 01:19:52 UTC+1, ogg...@gmail.com wrote:
>
> I think that's an excellent idea as well, and actually I was going to
> propose the very similar thing. Just a few things:
> I think this should be called strictly "extension" rather than
> "inheritance", the reason being that these two have quite opposite meaning.
> The inheritance specializes on the base class limiting the space of
> possibilities, while the extension extends it. Accordingly your syntax
> might impose a problem because it looks like inheritance while it's not.
> This involves, for examples, teachability issues. I am not sure what might
> be the best syntax but I am considering something along these lines:
>
I am not sure I understand: in what way does the base class limit the range
of possibilities?
Given:
class B {
public:
int foo;
};
is
class D : public B {
public:
char bar;
};
limited by B or an extension of B?
> As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
> it does not follow the DRY principle (Do Not Repeat Yourself). Anyways, this one (the opposite direction) should be called inheritance though.
>
>
> On Monday, September 1, 2014 4:41:28 AM UTC-7, Douglas Boffey wrote:
>
> How about extending and restricting existing enumerations, for example,
>> given the definition:
>>
>> enum class Weekday {Monday, Tuesday, Wednesday, Thursday, Friday};
>>
>>
>>
>> allowing this to be extended, thus:
>>
>> enum class Day : Weekday {Saturday, Sunday};
>>
>>
>>
>> This would allow Day to have all the members of Weekday, plus Saturday
>> and Sunday. Weekday can be coerced to Day, but not vice-versa.
>>
>> Contriwise, given the definition:
>>
>> enum class Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
>> Sunday};
>>
>>
>> should that be able to be restricted, thus:
>>
>> enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
>>
>>
>> Again, the Weekday can be coerced to Day, but not the other way round.
>>
>>
--
---
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_234_1428828013.1411742708836
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><BR>On Friday, 26 September 2014 01:19:52 UTC+1, ogg...@gm=
ail.com wrote:=20
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>
<DIV dir=3Dltr>
<DIV>I think that's an excellent idea as well, and actually I was going to =
propose the very similar thing. Just a few things:</DIV>
<DIV>I think this should be called strictly "extension" rather than "inheri=
tance", the reason being that these two have quite opposite meaning. The in=
heritance specializes on the base class limiting the space of possibilities=
, while the extension extends it. Accordingly your syntax might impose=
a problem because it looks like inheritance while it's not. This involves,=
for examples, teachability issues. I am not sure what might be t=
he best syntax but I am considering something along these lines:</DIV></DIV=
></BLOCKQUOTE>
<DIV> </DIV>
<DIV>I am not sure I understand: in what way does the base class limit=
the range of possibilities?</DIV>
<DIV> </DIV>
<DIV>Given:</DIV>
<DIV> </DIV>
<DIV>class B {</DIV>
<DIV>public:</DIV>
<DIV> int foo;</DIV>
<DIV>};</DIV>
<DIV> </DIV>
<DIV>is</DIV>
<DIV> </DIV>
<DIV>class D : public B {</DIV>
<DIV>public:</DIV>
<DIV> char bar;</DIV>
<DIV>};</DIV>
<DIV> </DIV>
<DIV>limited by B or an extension of B?</DIV>
<DIV> </DIV>
<BLOCKQUOTE style=3D"BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex=
; PADDING-LEFT: 1ex" class=3Dgmail_quote>
<DIV dir=3Dltr>
<DIV><PRE style=3D"LINE-HEIGHT: normal; TEXT-TRANSFORM: none; FONT-VARIANT:=
normal; FONT-STYLE: normal; TEXT-INDENT: 0px; LETTER-SPACING: normal; COLO=
R: rgb(0,0,0); FONT-WEIGHT: normal; WORD-SPACING: 0px"><CODE>As for <SPAN s=
tyle=3D"COLOR: rgb(0,0,136)">enum</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> =
</SPAN><SPAN style=3D"COLOR: rgb(0,0,136)">class</SPAN><SPAN style=3D"COLOR=
: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Weekday</SPAN><=
SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,102,=
0)">:</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR:=
rgb(102,0,102)">Day</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">[</SPAN><S=
PAN style=3D"COLOR: rgb(102,0,102)">Monday</SPAN><SPAN style=3D"COLOR: rgb(=
102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=
=3D"COLOR: rgb(102,0,102)">Tuesday</SPAN><SPAN style=3D"COLOR: rgb(102,102,=
0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR:=
rgb(102,0,102)">Wednesday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">,</S=
PAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102=
,0,102)">Thursday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">,</SPAN><SPAN=
style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">=
Friday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">];</SPAN><SPAN style=3D"=
COLOR: rgb(0,0,0)"><BR></SPAN></CODE>it does not follow the DRY principle (=
Do Not Repeat Yourself). Anyways, this one (the opposite direction) should =
be called inheritance though.</PRE><PRE style=3D"LINE-HEIGHT: normal; TEXT-=
TRANSFORM: none; FONT-VARIANT: normal; FONT-STYLE: normal; TEXT-INDENT: 0px=
; LETTER-SPACING: normal; COLOR: rgb(0,0,0); FONT-WEIGHT: normal; WORD-SPAC=
ING: 0px"><BR>On Monday, September 1, 2014 4:41:28 AM UTC-7, Douglas Boffey=
wrote:</PRE></DIV>
<BLOCKQUOTE style=3D"BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0=
px 0px 0.8ex; PADDING-LEFT: 1ex" class=3Dgmail_quote>
<DIV dir=3Dltr>How about extending and restricting existing enumerations, f=
or example, given the definition:<BR><BR>
<DIV style=3D"BORDER-BOTTOM: rgb(187,187,187) 1px solid; BORDER-LEFT: rgb(1=
87,187,187) 1px solid; BACKGROUND-COLOR: rgb(250,250,250); BORDER-TOP: rgb(=
187,187,187) 1px solid; BORDER-RIGHT: rgb(187,187,187) 1px solid"><CODE>
<DIV><SPAN style=3D"COLOR: rgb(0,0,136)">enum</SPAN><SPAN style=3D"COLOR: r=
gb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(0,0,136)">class</SPAN><SPAN st=
yle=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Wee=
kday</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: =
rgb(102,102,0)">{</SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Monday</SPAN>=
<SPAN style=3D"COLOR: rgb(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0=
,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Tuesday</SPAN><SPAN styl=
e=3D"COLOR: rgb(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SP=
AN><SPAN style=3D"COLOR: rgb(102,0,102)">Wednesday</SPAN><SPAN style=3D"COL=
OR: rgb(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN=
style=3D"COLOR: rgb(102,0,102)">Thursday</SPAN><SPAN style=3D"COLOR: rgb(1=
02,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D=
"COLOR: rgb(102,0,102)">Friday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">=
};</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"><BR><BR></SPAN></DIV></CODE></DI=
V><BR><BR>allowing this to be extended, thus:<BR><BR>
<DIV style=3D"BORDER-BOTTOM: rgb(187,187,187) 1px solid; BORDER-LEFT: rgb(1=
87,187,187) 1px solid; BACKGROUND-COLOR: rgb(250,250,250); BORDER-TOP: rgb(=
187,187,187) 1px solid; BORDER-RIGHT: rgb(187,187,187) 1px solid"><CODE>
<DIV><SPAN style=3D"COLOR: rgb(0,0,136)">enum</SPAN><SPAN style=3D"COLOR: r=
gb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(0,0,136)">class</SPAN><SPAN st=
yle=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Day=
</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(=
102,102,0)">:</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=
=3D"COLOR: rgb(102,0,102)">Weekday</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)">=
</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">{</SPAN><SPAN style=3D"COLOR:=
rgb(102,0,102)">Saturday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">,</SP=
AN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,=
0,102)">Sunday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">};</SPAN><SPAN s=
tyle=3D"COLOR: rgb(0,0,0)"><BR><BR></SPAN></DIV></CODE></DIV><BR><BR>This w=
ould allow Day to have all the members of Weekday, plus Saturday and Sunday=
.. Weekday can be coerced to Day, but not vice-versa.<BR><BR>Contriwis=
e, given the definition:<BR><BR>
<DIV style=3D"BORDER-BOTTOM: rgb(187,187,187) 1px solid; BORDER-LEFT: rgb(1=
87,187,187) 1px solid; BACKGROUND-COLOR: rgb(250,250,250); BORDER-TOP: rgb(=
187,187,187) 1px solid; BORDER-RIGHT: rgb(187,187,187) 1px solid"><CODE>
<DIV><SPAN style=3D"COLOR: rgb(0,0,136)">enum</SPAN><SPAN style=3D"COLOR: r=
gb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(0,0,136)">class</SPAN><SPAN st=
yle=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Day=
</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(=
102,102,0)">{</SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Monday</SPAN><SPA=
N style=3D"COLOR: rgb(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"=
> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Tuesday</SPAN><SPAN style=3D=
"COLOR: rgb(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><=
SPAN style=3D"COLOR: rgb(102,0,102)">Wednesday</SPAN><SPAN style=3D"COLOR: =
rgb(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN sty=
le=3D"COLOR: rgb(102,0,102)">Thursday</SPAN><SPAN style=3D"COLOR: rgb(102,1=
02,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COL=
OR: rgb(102,0,102)">Friday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">,</S=
PAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102=
,0,102)">Saturday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">,</SPAN><SPAN=
style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">=
Sunday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">};</SPAN><SPAN style=3D"=
COLOR: rgb(0,0,0)"><BR><BR></SPAN></DIV></CODE></DIV><BR>should that be abl=
e to be restricted, thus:<BR><BR>
<DIV style=3D"BORDER-BOTTOM: rgb(187,187,187) 1px solid; BORDER-LEFT: rgb(1=
87,187,187) 1px solid; BACKGROUND-COLOR: rgb(250,250,250); BORDER-TOP: rgb(=
187,187,187) 1px solid; BORDER-RIGHT: rgb(187,187,187) 1px solid"><CODE>
<DIV><SPAN style=3D"COLOR: rgb(0,0,136)">enum</SPAN><SPAN style=3D"COLOR: r=
gb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(0,0,136)">class</SPAN><SPAN st=
yle=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Wee=
kday</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: =
rgb(102,102,0)">:</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN sty=
le=3D"COLOR: rgb(102,0,102)">Day</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)=
">[</SPAN><SPAN style=3D"COLOR: rgb(102,0,102)">Monday</SPAN><SPAN style=3D=
"COLOR: rgb(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><=
SPAN style=3D"COLOR: rgb(102,0,102)">Tuesday</SPAN><SPAN style=3D"COLOR: rg=
b(102,102,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=
=3D"COLOR: rgb(102,0,102)">Wednesday</SPAN><SPAN style=3D"COLOR: rgb(102,10=
2,0)">,</SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLO=
R: rgb(102,0,102)">Thursday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">,</=
SPAN><SPAN style=3D"COLOR: rgb(0,0,0)"> </SPAN><SPAN style=3D"COLOR: rgb(10=
2,0,102)">Friday</SPAN><SPAN style=3D"COLOR: rgb(102,102,0)">];</SPAN><SPAN=
style=3D"COLOR: rgb(0,0,0)"><BR><BR></SPAN></DIV></CODE></DIV><BR>Again, t=
he Weekday can be coerced to Day, but not the other way round.<BR><BR></DIV=
></BLOCKQUOTE></DIV></BLOCKQUOTE></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_234_1428828013.1411742708836--
.
Author: "'Geoffrey Romer' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Fri, 26 Sep 2014 11:45:36 -0700
Raw View
--001a11c307bea556910503fc5202
Content-Type: text/plain; charset=UTF-8
Here's another way of putting the same concern: right now, "enum class E :
<type>" always means that E's values are a subset of the values of <type>.
Under your proposal, they would sometimes be a subset, and sometimes a
superset, depending on what <type> is. If <type> is a typedef, this could
create substantial confusion. This is particularly problematic because it's
fairly common to change code that uses an enum to use an integral type
instead, or vice-versa. Right now, as far as I know, changing a typedef
from an enum to an integral type or vice-versa would be safe, if it
compiles at all, but under your scheme such a change could drastically
change the meaning of the code.
On Fri, Sep 26, 2014 at 7:45 AM, Douglas Boffey <douglas.boffey@gmail.com>
wrote:
>
> On Friday, 26 September 2014 01:19:52 UTC+1, ogg...@gmail.com wrote:
>>
>> I think that's an excellent idea as well, and actually I was going to
>> propose the very similar thing. Just a few things:
>> I think this should be called strictly "extension" rather than
>> "inheritance", the reason being that these two have quite opposite meaning.
>> The inheritance specializes on the base class limiting the space of
>> possibilities, while the extension extends it. Accordingly your syntax
>> might impose a problem because it looks like inheritance while it's not.
>> This involves, for examples, teachability issues. I am not sure what might
>> be the best syntax but I am considering something along these lines:
>>
>
> I am not sure I understand: in what way does the base class limit the
> range of possibilities?
>
> Given:
>
> class B {
> public:
> int foo;
> };
>
> is
>
> class D : public B {
> public:
> char bar;
> };
>
> limited by B or an extension of B?
>
>
>> As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
>> it does not follow the DRY principle (Do Not Repeat Yourself). Anyways, this one (the opposite direction) should be called inheritance though.
>>
>>
>> On Monday, September 1, 2014 4:41:28 AM UTC-7, Douglas Boffey wrote:
>>
>> How about extending and restricting existing enumerations, for example,
>>> given the definition:
>>>
>>> enum class Weekday {Monday, Tuesday, Wednesday, Thursday, Friday};
>>>
>>>
>>>
>>> allowing this to be extended, thus:
>>>
>>> enum class Day : Weekday {Saturday, Sunday};
>>>
>>>
>>>
>>> This would allow Day to have all the members of Weekday, plus Saturday
>>> and Sunday. Weekday can be coerced to Day, but not vice-versa.
>>>
>>> Contriwise, given the definition:
>>>
>>> enum class Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
>>> Sunday};
>>>
>>>
>>> should that be able to be restricted, thus:
>>>
>>> enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
>>>
>>>
>>> Again, the Weekday can be coerced to Day, but not the other way round.
>>>
>>> --
>
> ---
> 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/.
>
--
---
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/.
--001a11c307bea556910503fc5202
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">Here's another way of putti=
ng the same concern: right now, "enum class E : <type>" alw=
ays means that E's values are a subset of the values of <type>. U=
nder your proposal, they would sometimes be a subset, and sometimes a super=
set, depending on what <type> is. If <type> is a typedef, this =
could create substantial confusion. This is particularly problematic becaus=
e it's fairly common to change code that uses an enum to use an integra=
l type instead, or vice-versa. Right now, as far as I know, changing a type=
def from an enum to an integral type or vice-versa would be safe, if it com=
piles at all, but under your scheme such a change could drastically change =
the meaning of the code.</div><div class=3D"gmail_extra"><br><div class=3D"=
gmail_quote">On Fri, Sep 26, 2014 at 7:45 AM, Douglas Boffey <span dir=3D"l=
tr"><<a href=3D"mailto:douglas.boffey@gmail.com" target=3D"_blank">dougl=
as.boffey@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-col=
or:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"l=
tr"><span class=3D""><br>On Friday, 26 September 2014 01:19:52 UTC+1, <a hr=
ef=3D"mailto:ogg...@gmail.com" target=3D"_blank">ogg...@gmail.com</a> wrote=
:=20
<blockquote style=3D"border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class=
=3D"gmail_quote">
<div dir=3D"ltr">
<div>I think that's an excellent idea as well, and actually I was going=
to propose the very similar thing. Just a=C2=A0few things:</div>
<div>I think this should be called strictly "extension" rather th=
an "inheritance", the reason being that these two have quite oppo=
site meaning. The inheritance specializes on the base class limiting the sp=
ace of possibilities, while the extension extends it. Accordingly=C2=A0your=
syntax might impose a problem because it looks like inheritance while it&#=
39;s not. This involves, for examples, teachability=C2=A0issues.=C2=A0I am =
not sure what might be the best syntax but I am considering something along=
these lines:</div></div></blockquote>
<div>=C2=A0</div>
</span><div>I am not sure I understand:=C2=A0in what way does the base clas=
s limit the range of possibilities?</div>
<div>=C2=A0</div>
<div>Given:</div>
<div>=C2=A0</div>
<div>class B {</div>
<div>public:</div>
<div>=C2=A0 int foo;</div>
<div>};</div>
<div>=C2=A0</div>
<div>is</div>
<div>=C2=A0</div>
<div>class D : public=C2=A0B {</div>
<div>public:</div>
<div>=C2=A0 char bar;</div>
<div>};</div>
<div>=C2=A0</div>
<div>limited by B or an extension of B?</div></div></blockquote><blockquote=
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:=
1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left=
:1ex"><div dir=3D"ltr"><span class=3D"">
<div>=C2=A0</div>
<blockquote style=3D"border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class=
=3D"gmail_quote">
<div dir=3D"ltr">
<div><pre style=3D"line-height:normal;text-transform:none;font-variant:norm=
al;font-style:normal;text-indent:0px;letter-spacing:normal;color:rgb(0,0,0)=
;font-weight:normal;word-spacing:0px"><code>As for <span style=3D"color:rgb=
(0,0,136)">enum</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"> </spa=
n><span style=3D"color:rgb(102,0,102)">Weekday</span><span style=3D"color:r=
gb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">:</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Day</spa=
n><span style=3D"color:rgb(102,102,0)">[</span><span style=3D"color:rgb(102=
,0,102)">Monday</span><span style=3D"color:rgb(102,102,0)">,</span><span st=
yle=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Tuesd=
ay</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:=
rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Wednesday</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"=
> </span><span style=3D"color:rgb(102,0,102)">Thursday</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><sp=
an style=3D"color:rgb(102,0,102)">Friday</span><span style=3D"color:rgb(102=
,102,0)">];</span><span style=3D"color:rgb(0,0,0)"><br></span></code>it doe=
s not follow the DRY principle (Do Not Repeat Yourself). Anyways, this one =
(the opposite direction) should be called inheritance though.</pre><pre sty=
le=3D"line-height:normal;text-transform:none;font-variant:normal;font-style=
:normal;text-indent:0px;letter-spacing:normal;color:rgb(0,0,0);font-weight:=
normal;word-spacing:0px"><br>On Monday, September 1, 2014 4:41:28 AM UTC-7,=
Douglas Boffey wrote:</pre></div>
<blockquote style=3D"border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class=
=3D"gmail_quote">
<div dir=3D"ltr">How about extending and restricting existing enumerations,=
for example, given the definition:<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Weekday<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,102,0)">{</span><span style=3D"color:rgb(102,0,102)">Monday</span><span st=
yle=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,0,102)">Tuesday</span><span style=3D"color:=
rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(102,0,102)">Wednesday</span><span style=3D"color:rgb(102,102=
,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:=
rgb(102,0,102)">Thursday</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,10=
2)">Friday</span><span style=3D"color:rgb(102,102,0)">};</span><span style=
=3D"color:rgb(0,0,0)"><br><br></span></div></code></div><br><br>allowing th=
is to be extended, thus:<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Day</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">:</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:=
rgb(102,0,102)">Weekday</span><span style=3D"color:rgb(0,0,0)"> </span><spa=
n style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(102,0,102=
)">Saturday</span><span style=3D"color:rgb(102,102,0)">,</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Sunday</=
span><span style=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb=
(0,0,0)"><br><br></span></div></code></div><br><br>This would allow Day to =
have all the members of Weekday, plus Saturday and Sunday.=C2=A0 Weekday ca=
n be coerced to Day, but not vice-versa.<br><br>Contriwise, given the defin=
ition:<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Day</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">{</span><span style=3D"color:rgb(102,0,102)">Monday</span><span style=
=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span>=
<span style=3D"color:rgb(102,0,102)">Tuesday</span><span style=3D"color:rgb=
(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,0,102)">Wednesday</span><span style=3D"color:rgb(102,102,=
0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(102,0,102)">Thursday</span><span style=3D"color:rgb(102,102,0)">,</span>=
<span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102=
)">Friday</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D=
"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Saturday</s=
pan><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0=
,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Sunday</span><span styl=
e=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb(0,0,0)"><br><b=
r></span></div></code></div><br>should that be able to be restricted, thus:=
<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Weekday<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,102,0)">:</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(102,0,102)">Day</span><span style=3D"color:rgb(102,102,0)">[</span>=
<span style=3D"color:rgb(102,0,102)">Monday</span><span style=3D"color:rgb(=
102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D=
"color:rgb(102,0,102)">Tuesday</span><span style=3D"color:rgb(102,102,0)">,=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(10=
2,0,102)">Wednesday</span><span style=3D"color:rgb(102,102,0)">,</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">T=
hursday</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"c=
olor:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Friday</span>=
<span style=3D"color:rgb(102,102,0)">];</span><span style=3D"color:rgb(0,0,=
0)"><br><br></span></div></code></div><br>Again, the Weekday can be coerced=
to Day, but not the other way round.<br><br></div></blockquote></div></blo=
ckquote></span></div><div class=3D""><div class=3D"h5">
<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" target=3D"_=
blank">std-proposals+unsubscribe@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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></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 />
--001a11c307bea556910503fc5202--
.
Author: Ognjen Sobajic <oggy22@gmail.com>
Date: Fri, 26 Sep 2014 12:04:55 -0700
Raw View
--001a11c1ee24b6e0a20503fc9780
Content-Type: text/plain; charset=UTF-8
I completely agree with Geoffrey Romer. If <type> is a typedel, as he said,
this leads to confusion. That's why I think we need a different syntax
which would clearly make a difference from defining the underlying type.
On Fri, Sep 26, 2014 at 11:45 AM, Geoffrey Romer <gromer@google.com> wrote:
> Here's another way of putting the same concern: right now, "enum class E :
> <type>" always means that E's values are a subset of the values of <type>.
> Under your proposal, they would sometimes be a subset, and sometimes a
> superset, depending on what <type> is. If <type> is a typedef, this could
> create substantial confusion. This is particularly problematic because it's
> fairly common to change code that uses an enum to use an integral type
> instead, or vice-versa. Right now, as far as I know, changing a typedef
> from an enum to an integral type or vice-versa would be safe, if it
> compiles at all, but under your scheme such a change could drastically
> change the meaning of the code.
>
> On Fri, Sep 26, 2014 at 7:45 AM, Douglas Boffey <douglas.boffey@gmail.com>
> wrote:
>
>>
>> On Friday, 26 September 2014 01:19:52 UTC+1, ogg...@gmail.com wrote:
>>>
>>> I think that's an excellent idea as well, and actually I was going to
>>> propose the very similar thing. Just a few things:
>>> I think this should be called strictly "extension" rather than
>>> "inheritance", the reason being that these two have quite opposite meaning.
>>> The inheritance specializes on the base class limiting the space of
>>> possibilities, while the extension extends it. Accordingly your syntax
>>> might impose a problem because it looks like inheritance while it's not.
>>> This involves, for examples, teachability issues. I am not sure what might
>>> be the best syntax but I am considering something along these lines:
>>>
>>
>> I am not sure I understand: in what way does the base class limit the
>> range of possibilities?
>>
>> Given:
>>
>> class B {
>> public:
>> int foo;
>> };
>>
>> is
>>
>> class D : public B {
>> public:
>> char bar;
>> };
>>
>> limited by B or an extension of B?
>>
>
>>
>>> As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
>>> it does not follow the DRY principle (Do Not Repeat Yourself). Anyways, this one (the opposite direction) should be called inheritance though.
>>>
>>>
>>> On Monday, September 1, 2014 4:41:28 AM UTC-7, Douglas Boffey wrote:
>>>
>>> How about extending and restricting existing enumerations, for
>>>> example, given the definition:
>>>>
>>>> enum class Weekday {Monday, Tuesday, Wednesday, Thursday, Friday};
>>>>
>>>>
>>>>
>>>> allowing this to be extended, thus:
>>>>
>>>> enum class Day : Weekday {Saturday, Sunday};
>>>>
>>>>
>>>>
>>>> This would allow Day to have all the members of Weekday, plus Saturday
>>>> and Sunday. Weekday can be coerced to Day, but not vice-versa.
>>>>
>>>> Contriwise, given the definition:
>>>>
>>>> enum class Day {Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
>>>> , Sunday};
>>>>
>>>>
>>>> should that be able to be restricted, thus:
>>>>
>>>> enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday
>>>> ];
>>>>
>>>>
>>>> Again, the Weekday can be coerced to Day, but not the other way round.
>>>>
>>>> --
>>
>> ---
>> 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/.
>>
>
>
--
Best Regards,
Ognjen Sobajic
--
---
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/.
--001a11c1ee24b6e0a20503fc9780
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I completely agree with Geoffrey Romer. If <type> is=
a typedel, as he said, this leads to confusion. That's why I think we =
need a different syntax which would clearly make a difference from defining=
the underlying type.</div><div class=3D"gmail_extra"><br><div class=3D"gma=
il_quote">On Fri, Sep 26, 2014 at 11:45 AM, Geoffrey Romer <span dir=3D"ltr=
"><<a href=3D"mailto:gromer@google.com" target=3D"_blank">gromer@google.=
com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr=
"><div class=3D"gmail_extra">Here's another way of putting the same con=
cern: right now, "enum class E : <type>" always means that =
E's values are a subset of the values of <type>. Under your propo=
sal, they would sometimes be a subset, and sometimes a superset, depending =
on what <type> is. If <type> is a typedef, this could create su=
bstantial confusion. This is particularly problematic because it's fair=
ly common to change code that uses an enum to use an integral type instead,=
or vice-versa. Right now, as far as I know, changing a typedef from an enu=
m to an integral type or vice-versa would be safe, if it compiles at all, b=
ut under your scheme such a change could drastically change the meaning of =
the code.</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote"><d=
iv><div class=3D"h5">On Fri, Sep 26, 2014 at 7:45 AM, Douglas Boffey <span =
dir=3D"ltr"><<a href=3D"mailto:douglas.boffey@gmail.com" target=3D"_blan=
k">douglas.boffey@gmail.com</a>></span> wrote:<br><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-=
left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div =
dir=3D"ltr"><span><br>On Friday, 26 September 2014 01:19:52 UTC+1, <a href=
=3D"mailto:ogg...@gmail.com" target=3D"_blank">ogg...@gmail.com</a> wrote:=
=20
<blockquote style=3D"border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class=
=3D"gmail_quote">
<div dir=3D"ltr">
<div>I think that's an excellent idea as well, and actually I was going=
to propose the very similar thing. Just a=C2=A0few things:</div>
<div>I think this should be called strictly "extension" rather th=
an "inheritance", the reason being that these two have quite oppo=
site meaning. The inheritance specializes on the base class limiting the sp=
ace of possibilities, while the extension extends it. Accordingly=C2=A0your=
syntax might impose a problem because it looks like inheritance while it&#=
39;s not. This involves, for examples, teachability=C2=A0issues.=C2=A0I am =
not sure what might be the best syntax but I am considering something along=
these lines:</div></div></blockquote>
<div>=C2=A0</div>
</span><div>I am not sure I understand:=C2=A0in what way does the base clas=
s limit the range of possibilities?</div>
<div>=C2=A0</div>
<div>Given:</div>
<div>=C2=A0</div>
<div>class B {</div>
<div>public:</div>
<div>=C2=A0 int foo;</div>
<div>};</div>
<div>=C2=A0</div>
<div>is</div>
<div>=C2=A0</div>
<div>class D : public=C2=A0B {</div>
<div>public:</div>
<div>=C2=A0 char bar;</div>
<div>};</div>
<div>=C2=A0</div>
<div>limited by B or an extension of B?</div></div></blockquote></div></div=
><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border=
-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;=
padding-left:1ex"><div><div class=3D"h5"><div dir=3D"ltr"><span>
<div>=C2=A0</div>
<blockquote style=3D"border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class=
=3D"gmail_quote">
<div dir=3D"ltr">
<div><pre style=3D"line-height:normal;text-transform:none;font-variant:norm=
al;font-style:normal;text-indent:0px;letter-spacing:normal;color:rgb(0,0,0)=
;font-weight:normal;word-spacing:0px"><code>As for <span style=3D"color:rgb=
(0,0,136)">enum</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(0,0,136)">class</span><span style=3D"color:rgb(0,0,0)"> </spa=
n><span style=3D"color:rgb(102,0,102)">Weekday</span><span style=3D"color:r=
gb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">:</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Day</spa=
n><span style=3D"color:rgb(102,102,0)">[</span><span style=3D"color:rgb(102=
,0,102)">Monday</span><span style=3D"color:rgb(102,102,0)">,</span><span st=
yle=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Tuesd=
ay</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:=
rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Wednesday</span><s=
pan style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"=
> </span><span style=3D"color:rgb(102,0,102)">Thursday</span><span style=3D=
"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><sp=
an style=3D"color:rgb(102,0,102)">Friday</span><span style=3D"color:rgb(102=
,102,0)">];</span><span style=3D"color:rgb(0,0,0)"><br></span></code>it doe=
s not follow the DRY principle (Do Not Repeat Yourself). Anyways, this one =
(the opposite direction) should be called inheritance though.</pre><pre sty=
le=3D"line-height:normal;text-transform:none;font-variant:normal;font-style=
:normal;text-indent:0px;letter-spacing:normal;color:rgb(0,0,0);font-weight:=
normal;word-spacing:0px"><br>On Monday, September 1, 2014 4:41:28 AM UTC-7,=
Douglas Boffey wrote:</pre></div>
<blockquote style=3D"border-left-color:rgb(204,204,204);border-left-width:1=
px;border-left-style:solid;margin:0px 0px 0px 0.8ex;padding-left:1ex" class=
=3D"gmail_quote">
<div dir=3D"ltr">How about extending and restricting existing enumerations,=
for example, given the definition:<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Weekday<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,102,0)">{</span><span style=3D"color:rgb(102,0,102)">Monday</span><span st=
yle=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,0,102)">Tuesday</span><span style=3D"color:=
rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span styl=
e=3D"color:rgb(102,0,102)">Wednesday</span><span style=3D"color:rgb(102,102=
,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:=
rgb(102,0,102)">Thursday</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,10=
2)">Friday</span><span style=3D"color:rgb(102,102,0)">};</span><span style=
=3D"color:rgb(0,0,0)"><br><br></span></div></code></div><br><br>allowing th=
is to be extended, thus:<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Day</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">:</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:=
rgb(102,0,102)">Weekday</span><span style=3D"color:rgb(0,0,0)"> </span><spa=
n style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(102,0,102=
)">Saturday</span><span style=3D"color:rgb(102,102,0)">,</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Sunday</=
span><span style=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb=
(0,0,0)"><br><br></span></div></code></div><br><br>This would allow Day to =
have all the members of Weekday, plus Saturday and Sunday.=C2=A0 Weekday ca=
n be coerced to Day, but not vice-versa.<br><br>Contriwise, given the defin=
ition:<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Day</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)">{</span><span style=3D"color:rgb(102,0,102)">Monday</span><span style=
=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span>=
<span style=3D"color:rgb(102,0,102)">Tuesday</span><span style=3D"color:rgb=
(102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=
=3D"color:rgb(102,0,102)">Wednesday</span><span style=3D"color:rgb(102,102,=
0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:r=
gb(102,0,102)">Thursday</span><span style=3D"color:rgb(102,102,0)">,</span>=
<span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102=
)">Friday</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D=
"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Saturday</s=
pan><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0=
,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Sunday</span><span styl=
e=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb(0,0,0)"><br><b=
r></span></div></code></div><br>should that be able to be restricted, thus:=
<br><br>
<div style=3D"border:1px solid rgb(187,187,187);background-color:rgb(250,25=
0,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">enum</span><span style=3D"color:rgb=
(0,0,0)"> </span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Weekday<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,102,0)">:</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(102,0,102)">Day</span><span style=3D"color:rgb(102,102,0)">[</span>=
<span style=3D"color:rgb(102,0,102)">Monday</span><span style=3D"color:rgb(=
102,102,0)">,</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D=
"color:rgb(102,0,102)">Tuesday</span><span style=3D"color:rgb(102,102,0)">,=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(10=
2,0,102)">Wednesday</span><span style=3D"color:rgb(102,102,0)">,</span><spa=
n style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">T=
hursday</span><span style=3D"color:rgb(102,102,0)">,</span><span style=3D"c=
olor:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Friday</span>=
<span style=3D"color:rgb(102,102,0)">];</span><span style=3D"color:rgb(0,0,=
0)"><br><br></span></div></code></div><br>Again, the Weekday can be coerced=
to Day, but not the other way round.<br><br></div></blockquote></div></blo=
ckquote></span></div></div></div><div><div><span class=3D"HOEnZb"><font col=
or=3D"#888888">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.</font></span><span class=
=3D""><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>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</span></div></div></blockquote></div><br></div></div>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>Best Regards=
,<br><br>Ognjen Sobajic
</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 />
--001a11c1ee24b6e0a20503fc9780--
.
Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Fri, 26 Sep 2014 17:44:50 -0400
Raw View
On 2014-09-25 20:19, oggy22@gmail.com wrote:
> I think that's an excellent idea as well, and actually I was going to
> propose the very similar thing.
Likewise :-D.
> Just a few things:
> I think this should be called strictly "extension" rather than
> "inheritance", the reason being that these two have quite opposite meaning.
> The inheritance specializes on the base class limiting the space of
> possibilities, while the extension extends it. Accordingly your syntax
> might impose a problem because it looks like inheritance while it's not.
> This involves, for examples, teachability issues. I am not sure what might
> be the best syntax but I am considering something along these lines:
>
> enum class Day : using Weekday { Saturday, Sunday };enum class Day : extends Weekday { Saturday, Sunday };enum class Day { using Weekday ; Saturday, Sunday };enum class Day { using Weekday , Saturday, Sunday };
>
> As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, Friday];
> it does not follow the DRY principle (Do Not Repeat Yourself). Anyways, this one (the opposite direction) should be called inheritance though.
I'm also not in love with the claim that "inheritence" is a limiting
process. *In general*, given class B which inherits class A, you can do
everything with a B that you can do with an A, *and then some*. It's the
'enum Foo : int' that's backwards. (And also not "inheritence" in the
sense it's used everywhere else in the language. Maybe 'enum<int> Foo'
would have been better, but too late now...)
I'd prefer not inventing new syntax for an existing concept.
--
Matthew
--
---
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/.
.
Author: Ognjen Sobajic <oggy22@gmail.com>
Date: Fri, 26 Sep 2014 17:08:26 -0700
Raw View
--001a113abd6029c886050400d5cb
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
My explanation might not have been the most precise. I will try to explain
in other words.
In terms of sets, the inheritance means subset such that the set of all the
instances of class Derived is a subset of the set of all the instances of
the class Base. (One can argue that they are not sets but rather classes,
which I agree with, but let's put this fact aside because it's
perpendicular to my point). Given that we can say:
Derived =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Base
and therefore
if object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Derived then a=
lso
object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Base (but not vic=
e
versa). Therefore, we are allowed to convert from Derived to Base.
In the case of enum classes we have a quite opposite situation. If the
value is in the base enum class then it is in its "extension" as well, but
not vice versa. Therefore:
Base =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Extension
Because of that I don't think this is an existing concept, and it is NOT
inheritance. Consequently, the conversion rules are opposite from those in
inheritance: You can convert from the base enum class to its extension, but
you can not convert from extension to its base class safely.
As far as I know no other PL has this concept (please correct me if I am
wrong).
On Fri, Sep 26, 2014 at 2:44 PM, Matthew Woehlke <
mw_triad@users.sourceforge.net> wrote:
> On 2014-09-25 20:19, oggy22@gmail.com wrote:
> > I think that's an excellent idea as well, and actually I was going to
> > propose the very similar thing.
>
> Likewise :-D.
>
> > Just a few things:
> > I think this should be called strictly "extension" rather than
> > "inheritance", the reason being that these two have quite opposite
> meaning.
> > The inheritance specializes on the base class limiting the space of
> > possibilities, while the extension extends it. Accordingly your syntax
> > might impose a problem because it looks like inheritance while it's not=
..
> > This involves, for examples, teachability issues. I am not sure what
> might
> > be the best syntax but I am considering something along these lines:
> >
> > enum class Day : using Weekday { Saturday, Sunday };enum class Day :
> extends Weekday { Saturday, Sunday };enum class Day { using Weekday ;
> Saturday, Sunday };enum class Day { using Weekday , Saturday, Sunday };
> >
> > As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday,
> Friday];
> > it does not follow the DRY principle (Do Not Repeat Yourself). Anyways,
> this one (the opposite direction) should be called inheritance though.
>
> I'm also not in love with the claim that "inheritence" is a limiting
> process. *In general*, given class B which inherits class A, you can do
> everything with a B that you can do with an A, *and then some*. It's the
> 'enum Foo : int' that's backwards. (And also not "inheritence" in the
> sense it's used everywhere else in the language. Maybe 'enum<int> Foo'
> would have been better, but too late now...)
>
> I'd prefer not inventing new syntax for an existing concept.
>
> --
> Matthew
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/pFTWYkhGmtg/=
unsubscribe
> .
> To unsubscribe from this group and all its topics, 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/.
>
--=20
Best Regards,
Ognjen Sobajic
--=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/.
--001a113abd6029c886050400d5cb
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">My explanation might not have been the most precise. I wil=
l try to explain in other words.<div>In terms of sets, the inheritance mean=
s subset such that the set of all the instances of class Derived is a subse=
t of the set of all the instances of the class Base. (One can argue that th=
ey are not sets but rather classes, which I agree with, but let's put t=
his fact aside because it's perpendicular to my point). Given that we c=
an say:</div><div>Derived=C2=A0<a href=3D"http://en.wikipedia.org/wiki/%E2%=
8A%86" title=3D"=E2=8A=86" class=3D"" style=3D"color:rgb(11,0,128);font-fam=
ily:sans-serif;font-size:large;line-height:28.7999992370605px;text-align:ce=
nter;text-decoration:none!important;background-image:none;background-repeat=
:initial">=E2=8A=86</a>=C2=A0Base</div><div>and therefore</div><div>if obje=
ct=C2=A0<a href=3D"http://en.wikipedia.org/wiki/%E2%88%88" title=3D"=E2=88=
=88" class=3D"" style=3D"color:rgb(11,0,128);font-family:sans-serif;font-si=
ze:large;line-height:28.7999992370605px;text-align:center;text-decoration:n=
one!important;background-image:none;background-repeat:initial">=E2=88=88</a=
>=C2=A0Derived then also object=C2=A0<a href=3D"http://en.wikipedia.org/wik=
i/%E2%88%88" title=3D"=E2=88=88" class=3D"" style=3D"color:rgb(11,0,128);fo=
nt-family:sans-serif;font-size:large;line-height:28.7999992370605px;text-al=
ign:center;text-decoration:none!important;background-image:none;background-=
repeat:initial">=E2=88=88</a>=C2=A0Base (but not vice versa). Therefore, we=
are allowed to convert from Derived to Base.</div><div>In the case of enum=
classes we have a quite opposite situation. If the value is in the base en=
um class then it is in its "extension" as well, but not vice vers=
a. Therefore:</div><div>Base=C2=A0<a href=3D"http://en.wikipedia.org/wiki/%=
E2%8A%86" title=3D"=E2=8A=86" class=3D"" style=3D"color:rgb(11,0,128);font-=
family:sans-serif;font-size:large;line-height:28.7999992370605px;text-align=
:center;text-decoration:none!important;background-image:none;background-rep=
eat:initial">=E2=8A=86</a>=C2=A0Extension</div><div><br></div><div>Because =
of that I don't think this is an existing concept, and it is NOT inheri=
tance. Consequently, the conversion rules are opposite from those in inheri=
tance: You can convert from the base enum class to its extension, but you c=
an not convert from extension to its base class safely.</div><div><br></div=
><div>As far as I know no other PL has this concept (please correct me if I=
am wrong).</div><div><br></div></div><div class=3D"gmail_extra"><br><div c=
lass=3D"gmail_quote">On Fri, Sep 26, 2014 at 2:44 PM, Matthew Woehlke <span=
dir=3D"ltr"><<a href=3D"mailto:mw_triad@users.sourceforge.net" target=
=3D"_blank">mw_triad@users.sourceforge.net</a>></span> wrote:<br><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex"><span class=3D"">On 2014-09-25 20:19, <a href=3D"ma=
ilto:oggy22@gmail.com">oggy22@gmail.com</a> wrote:<br>
> I think that's an excellent idea as well, and actually I was going=
to<br>
> propose the very similar thing.<br>
<br>
</span>Likewise :-D.<br>
<span class=3D""><br>
> Just a few things:<br>
> I think this should be called strictly "extension" rather th=
an<br>
> "inheritance", the reason being that these two have quite op=
posite meaning.<br>
> The inheritance specializes on the base class limiting the space of<br=
>
> possibilities, while the extension extends it. Accordingly your syntax=
<br>
> might impose a problem because it looks like inheritance while it'=
s not.<br>
> This involves, for examples, teachability issues. I am not sure what m=
ight<br>
> be the best syntax but I am considering something along these lines:<b=
r>
><br>
> enum class Day : using Weekday=C2=A0 { Saturday, Sunday };enum class D=
ay : extends Weekday=C2=A0 { Saturday, Sunday };enum class Day { using Week=
day ; Saturday, Sunday };enum class Day { using Weekday , Saturday, Sunday =
};<br>
><br>
> As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, =
Friday];<br>
> it does not follow the DRY principle (Do Not Repeat Yourself). Anyways=
, this one (the opposite direction) should be called inheritance though.<br=
>
<br>
</span>I'm also not in love with the claim that "inheritence"=
is a limiting<br>
process. *In general*, given class B which inherits class A, you can do<br>
everything with a B that you can do with an A, *and then some*. It's th=
e<br>
'enum Foo : int' that's backwards. (And also not "inherite=
nce" in the<br>
sense it's used everywhere else in the language. Maybe 'enum<int=
> Foo'<br>
would have been better, but too late now...)<br>
<br>
I'd prefer not inventing new syntax for an existing concept.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
Matthew<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/pFTWYkhGmtg/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/pFTWYkhGmtg=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-proposals+unsubscrib=
e@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/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
Best Regards,<br><br>Ognjen Sobajic
</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 />
--001a113abd6029c886050400d5cb--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Sat, 27 Sep 2014 11:52:38 -0700 (PDT)
Raw View
------=_Part_1732_649129923.1411843958878
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Thanks for clarifying that=E2=80=94I now understand your point.
On Saturday, 27 September 2014 01:08:28 UTC+1, Ognjen Sobajic wrote:
>
> My explanation might not have been the most precise. I will try to explai=
n=20
> in other words.
> In terms of sets, the inheritance means subset such that the set of all=
=20
> the instances of class Derived is a subset of the set of all the instance=
s=20
> of the class Base. (One can argue that they are not sets but rather=20
> classes, which I agree with, but let's put this fact aside because it's=
=20
> perpendicular to my point). Given that we can say:
> Derived =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Base
> and therefore
> if object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Derived then=
also=20
> object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Base (but not v=
ice=20
> versa). Therefore, we are allowed to convert from Derived to Base.
> In the case of enum classes we have a quite opposite situation. If the=20
> value is in the base enum class then it is in its "extension" as well, bu=
t=20
> not vice versa. Therefore:
> Base =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Extension
>
> Because of that I don't think this is an existing concept, and it is NOT=
=20
> inheritance. Consequently, the conversion rules are opposite from those i=
n=20
> inheritance: You can convert from the base enum class to its extension, b=
ut=20
> you can not convert from extension to its base class safely.
>
> As far as I know no other PL has this concept (please correct me if I am=
=20
> wrong).
>
>
> On Fri, Sep 26, 2014 at 2:44 PM, Matthew Woehlke <
> mw_t...@users.sourceforge.net <javascript:>> wrote:
>
>> On 2014-09-25 20:19, ogg...@gmail.com <javascript:> wrote:
>> > I think that's an excellent idea as well, and actually I was going to
>> > propose the very similar thing.
>>
>> Likewise :-D.
>>
>> > Just a few things:
>> > I think this should be called strictly "extension" rather than
>> > "inheritance", the reason being that these two have quite opposite=20
>> meaning.
>> > The inheritance specializes on the base class limiting the space of
>> > possibilities, while the extension extends it. Accordingly your syntax
>> > might impose a problem because it looks like inheritance while it's no=
t.
>> > This involves, for examples, teachability issues. I am not sure what=
=20
>> might
>> > be the best syntax but I am considering something along these lines:
>> >
>> > enum class Day : using Weekday { Saturday, Sunday };enum class Day :=
=20
>> extends Weekday { Saturday, Sunday };enum class Day { using Weekday ;=
=20
>> Saturday, Sunday };enum class Day { using Weekday , Saturday, Sunday };
>> >
>> > As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday,=
=20
>> Friday];
>> > it does not follow the DRY principle (Do Not Repeat Yourself). Anyways=
,=20
>> this one (the opposite direction) should be called inheritance though.
>>
>> I'm also not in love with the claim that "inheritence" is a limiting
>> process. *In general*, given class B which inherits class A, you can do
>> everything with a B that you can do with an A, *and then some*. It's the
>> 'enum Foo : int' that's backwards. (And also not "inheritence" in the
>> sense it's used everywhere else in the language. Maybe 'enum<int> Foo'
>> would have been better, but too late now...)
>>
>> I'd prefer not inventing new syntax for an existing concept.
>>
>> --
>> Matthew
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to a topic in the=
=20
>> Google Groups "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this topic, visit=20
>> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/pFTWYkhGmtg=
/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to=20
>> std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
>
> --=20
> Best Regards,
>
> Ognjen Sobajic=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_1732_649129923.1411843958878
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Thanks for clarifying that=E2=80=94I now understand your p=
oint.<br><br>On Saturday, 27 September 2014 01:08:28 UTC+1, Ognjen Sobajic =
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">My exp=
lanation might not have been the most precise. I will try to explain in oth=
er words.<div>In terms of sets, the inheritance means subset such that the =
set of all the instances of class Derived is a subset of the set of all the=
instances of the class Base. (One can argue that they are not sets but rat=
her classes, which I agree with, but let's put this fact aside because it's=
perpendicular to my point). Given that we can say:</div><div>Derived =
<a href=3D"http://en.wikipedia.org/wiki/%E2%8A%86" title=3D"=E2=8A=86" styl=
e=3D"color:rgb(11,0,128);font-family:sans-serif;font-size:large;line-height=
:28.7999992370605px;text-align:center;text-decoration:none!important;backgr=
ound-image:none;background-repeat:initial" target=3D"_blank" onmousedown=3D=
"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2=
Fwiki%2F%25E2%258A%2586\46sa\75D\46sntz\0751\46usg\75AFQjCNFtDGIOL4HI5RlVv-=
wBbobgcv0r9Q';return true;" onclick=3D"this.href=3D'http://www.google.com/u=
rl?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%258A%2586\46sa\75D\46sn=
tz\0751\46usg\75AFQjCNFtDGIOL4HI5RlVv-wBbobgcv0r9Q';return true;">=E2=8A=86=
</a> Base</div><div>and therefore</div><div>if object <a href=3D"=
http://en.wikipedia.org/wiki/%E2%88%88" title=3D"=E2=88=88" style=3D"color:=
rgb(11,0,128);font-family:sans-serif;font-size:large;line-height:28.7999992=
370605px;text-align:center;text-decoration:none!important;background-image:=
none;background-repeat:initial" target=3D"_blank" onmousedown=3D"this.href=
=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%2=
5E2%2588%2588\46sa\75D\46sntz\0751\46usg\75AFQjCNF6AFxJzUCinJJOT6_3q4FfOC5E=
SA';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\75htt=
p%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%2588%2588\46sa\75D\46sntz\0751\46=
usg\75AFQjCNF6AFxJzUCinJJOT6_3q4FfOC5ESA';return true;">=E2=88=88</a> =
Derived then also object <a href=3D"http://en.wikipedia.org/wiki/%E2%8=
8%88" title=3D"=E2=88=88" style=3D"color:rgb(11,0,128);font-family:sans-ser=
if;font-size:large;line-height:28.7999992370605px;text-align:center;text-de=
coration:none!important;background-image:none;background-repeat:initial" ta=
rget=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75h=
ttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%2588%2588\46sa\75D\46sntz\0751\=
46usg\75AFQjCNF6AFxJzUCinJJOT6_3q4FfOC5ESA';return true;" onclick=3D"this.h=
ref=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2=
F%25E2%2588%2588\46sa\75D\46sntz\0751\46usg\75AFQjCNF6AFxJzUCinJJOT6_3q4FfO=
C5ESA';return true;">=E2=88=88</a> Base (but not vice versa). Therefor=
e, we are allowed to convert from Derived to Base.</div><div>In the case of=
enum classes we have a quite opposite situation. If the value is in the ba=
se enum class then it is in its "extension" as well, but not vice versa. Th=
erefore:</div><div>Base <a href=3D"http://en.wikipedia.org/wiki/%E2%8A=
%86" title=3D"=E2=8A=86" style=3D"color:rgb(11,0,128);font-family:sans-seri=
f;font-size:large;line-height:28.7999992370605px;text-align:center;text-dec=
oration:none!important;background-image:none;background-repeat:initial" tar=
get=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75ht=
tp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%258A%2586\46sa\75D\46sntz\0751\4=
6usg\75AFQjCNFtDGIOL4HI5RlVv-wBbobgcv0r9Q';return true;" onclick=3D"this.hr=
ef=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2F=
%25E2%258A%2586\46sa\75D\46sntz\0751\46usg\75AFQjCNFtDGIOL4HI5RlVv-wBbobgcv=
0r9Q';return true;">=E2=8A=86</a> Extension</div><div><br></div><div>B=
ecause of that I don't think this is an existing concept, and it is NOT inh=
eritance. Consequently, the conversion rules are opposite from those in inh=
eritance: You can convert from the base enum class to its extension, but yo=
u can not convert from extension to its base class safely.</div><div><br></=
div><div>As far as I know no other PL has this concept (please correct me i=
f I am wrong).</div><div><br></div></div><div><br><div class=3D"gmail_quote=
">On Fri, Sep 26, 2014 at 2:44 PM, Matthew Woehlke <span dir=3D"ltr"><<a=
href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"UEbxFS1KPA=
cJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.=
href=3D'javascript:';return true;">mw_t...@users.sourceforge.<wbr>net</a>&g=
t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
.8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 2014-09-25 20:1=
9, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"UEbxF=
S1KPAcJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"=
this.href=3D'javascript:';return true;">ogg...@gmail.com</a> wrote:<br>
> I think that's an excellent idea as well, and actually I was going to<=
br>
> propose the very similar thing.<br>
<br>
</span>Likewise :-D.<br>
<span><br>
> Just a few things:<br>
> I think this should be called strictly "extension" rather than<br>
> "inheritance", the reason being that these two have quite opposite mea=
ning.<br>
> The inheritance specializes on the base class limiting the space of<br=
>
> possibilities, while the extension extends it. Accordingly your syntax=
<br>
> might impose a problem because it looks like inheritance while it's no=
t.<br>
> This involves, for examples, teachability issues. I am not sure what m=
ight<br>
> be the best syntax but I am considering something along these lines:<b=
r>
><br>
> enum class Day : using Weekday { Saturday, Sunday };enum class D=
ay : extends Weekday { Saturday, Sunday };enum class Day { using Week=
day ; Saturday, Sunday };enum class Day { using Weekday , Saturday, Sunday =
};<br>
><br>
> As for enum class Weekday : Day[Monday, Tuesday, Wednesday, Thursday, =
Friday];<br>
> it does not follow the DRY principle (Do Not Repeat Yourself). Anyways=
, this one (the opposite direction) should be called inheritance though.<br=
>
<br>
</span>I'm also not in love with the claim that "inheritence" is a limiting=
<br>
process. *In general*, given class B which inherits class A, you can do<br>
everything with a B that you can do with an A, *and then some*. It's the<br=
>
'enum Foo : int' that's backwards. (And also not "inheritence" in the<br>
sense it's used everywhere else in the language. Maybe 'enum<int> Foo=
'<br>
would have been better, but too late now...)<br>
<br>
I'd prefer not inventing new syntax for an existing concept.<br>
<span><font color=3D"#888888"><br>
--<br>
Matthew<br>
</font></span><div><div><br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Goog=
le Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/pFTWYkhGmtg/unsubscribe" target=3D"_blan=
k" onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/top=
ic/std-proposals/pFTWYkhGmtg/unsubscribe';return true;" onclick=3D"this.hre=
f=3D'https://groups.google.com/a/isocpp.org/d/topic/std-proposals/pFTWYkhGm=
tg/unsubscribe';return true;">https://groups.google.com/a/<wbr>isocpp.org/d=
/topic/std-<wbr>proposals/pFTWYkhGmtg/<wbr>unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"UEbxFS1KPAcJ" o=
nmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.href=
=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"UEbxFS1KPAcJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
Best Regards,<br><br>Ognjen Sobajic
</div>
</blockquote></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_1732_649129923.1411843958878--
.
Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Mon, 29 Sep 2014 15:27:52 -0400
Raw View
On 2014-09-26 20:08, Ognjen Sobajic wrote:
> My explanation might not have been the most precise. I will try to explai=
n
> in other words.
> In terms of sets, the inheritance means subset such that the set of all t=
he
> instances of class Derived is a subset of the set of all the instances of
> the class Base. (One can argue that they are not sets but rather classes,
> which I agree with, but let's put this fact aside because it's
> perpendicular to my point). Given that we can say:
> Derived =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Base
> and therefore
> if object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Derived then=
also
> object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Base (but not v=
ice
> versa). Therefore, we are allowed to convert from Derived to Base.
> In the case of enum classes we have a quite opposite situation. If the
> value is in the base enum class then it is in its "extension" as well, bu=
t
> not vice versa. Therefore:
> Base =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Extension
>=20
> Because of that I don't think this is an existing concept, and it is NOT
> inheritance. Consequently, the conversion rules are opposite from those i=
n
> inheritance: You can convert from the base enum class to its extension, b=
ut
> you can not convert from extension to its base class safely.
Okay, now I see where you're coming from. Thanks.
I'm still not convinced this difference is sufficient to justify
something other than the "natural" syntax for this mechanism, but since
I don't get an official vote, I guess that's just MHO...
For what it's worth, I feel rather more strongly that related enums
should be by "extension" and not by subsetting, mainly because of DRY;
the syntax for the latter is going to be really verbose, and especially
unwieldy in the case of enums having a lot of values. There's also
nothing even remotely like it in the language currently.
--=20
Matthew
--=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/.
.
Author: oggy22@gmail.com
Date: Thu, 2 Oct 2014 10:07:35 -0700 (PDT)
Raw View
------=_Part_3979_1716575572.1412269655932
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I strongly agree with you: Subseting doesn't seem to be a good idea because=
=20
of DRY and verbosity.
On Monday, September 29, 2014 12:28:47 PM UTC-7, Matthew Woehlke wrote:
>
> On 2014-09-26 20:08, Ognjen Sobajic wrote:=20
> > My explanation might not have been the most precise. I will try to=20
> explain=20
> > in other words.=20
> > In terms of sets, the inheritance means subset such that the set of all=
=20
> the=20
> > instances of class Derived is a subset of the set of all the instances=
=20
> of=20
> > the class Base. (One can argue that they are not sets but rather=20
> classes,=20
> > which I agree with, but let's put this fact aside because it's=20
> > perpendicular to my point). Given that we can say:=20
> > Derived =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Base=20
> > and therefore=20
> > if object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Derived th=
en also=20
> > object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Base (but not=
vice=20
> > versa). Therefore, we are allowed to convert from Derived to Base.=20
> > In the case of enum classes we have a quite opposite situation. If the=
=20
> > value is in the base enum class then it is in its "extension" as well,=
=20
> but=20
> > not vice versa. Therefore:=20
> > Base =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Extension=20
> >=20
> > Because of that I don't think this is an existing concept, and it is NO=
T=20
> > inheritance. Consequently, the conversion rules are opposite from those=
=20
> in=20
> > inheritance: You can convert from the base enum class to its extension,=
=20
> but=20
> > you can not convert from extension to its base class safely.=20
>
> Okay, now I see where you're coming from. Thanks.=20
>
> I'm still not convinced this difference is sufficient to justify=20
> something other than the "natural" syntax for this mechanism, but since=
=20
> I don't get an official vote, I guess that's just MHO...=20
>
> For what it's worth, I feel rather more strongly that related enums=20
> should be by "extension" and not by subsetting, mainly because of DRY;=20
> the syntax for the latter is going to be really verbose, and especially=
=20
> unwieldy in the case of enums having a lot of values. There's also=20
> nothing even remotely like it in the language currently.=20
>
> --=20
> Matthew=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_3979_1716575572.1412269655932
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I strongly agree with you: Subseting doesn't seem to be a =
good idea because of DRY and verbosity.<br><br>On Monday, September 29, 201=
4 12:28:47 PM UTC-7, Matthew Woehlke wrote:<blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;">On 2014-09-26 20:08, Ognjen Sobajic wrote:
<br>> My explanation might not have been the most precise. I will try to=
explain
<br>> in other words.
<br>> In terms of sets, the inheritance means subset such that the set o=
f all the
<br>> instances of class Derived is a subset of the set of all the insta=
nces of
<br>> the class Base. (One can argue that they are not sets but rather c=
lasses,
<br>> which I agree with, but let's put this fact aside because it's
<br>> perpendicular to my point). Given that we can say:
<br>> Derived =E2=8A=86 <<a href=3D"http://en.wikipedia.org/wiki/%E2%=
8A%86" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/=
url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%258A%2586\46sa\75D\46s=
ntz\0751\46usg\75AFQjCNFtDGIOL4HI5RlVv-wBbobgcv0r9Q';return true;" onclick=
=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.or=
g%2Fwiki%2F%25E2%258A%2586\46sa\75D\46sntz\0751\46usg\75AFQjCNFtDGIOL4HI5Rl=
Vv-wBbobgcv0r9Q';return true;">http://en.wikipedia.org/wiki/<wbr>%E2%8A%86<=
/a>> Base
<br>> and therefore
<br>> if object =E2=88=88 <<a href=3D"http://en.wikipedia.org/wiki/%E=
2%88%88" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.co=
m/url?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%2588%2588\46sa\75D\4=
6sntz\0751\46usg\75AFQjCNF6AFxJzUCinJJOT6_3q4FfOC5ESA';return true;" onclic=
k=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.o=
rg%2Fwiki%2F%25E2%2588%2588\46sa\75D\46sntz\0751\46usg\75AFQjCNF6AFxJzUCinJ=
JOT6_3q4FfOC5ESA';return true;">http://en.wikipedia.org/wiki/<wbr>%E2%88%88=
</a>> Derived then also
<br>> object =E2=88=88 <<a href=3D"http://en.wikipedia.org/wiki/%E2%8=
8%88" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/u=
rl?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%2588%2588\46sa\75D\46sn=
tz\0751\46usg\75AFQjCNF6AFxJzUCinJJOT6_3q4FfOC5ESA';return true;" onclick=
=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.or=
g%2Fwiki%2F%25E2%2588%2588\46sa\75D\46sntz\0751\46usg\75AFQjCNF6AFxJzUCinJJ=
OT6_3q4FfOC5ESA';return true;">http://en.wikipedia.org/wiki/<wbr>%E2%88%88<=
/a>> Base (but not vice
<br>> versa). Therefore, we are allowed to convert from Derived to Base.
<br>> In the case of enum classes we have a quite opposite situation. If=
the
<br>> value is in the base enum class then it is in its "extension" as w=
ell, but
<br>> not vice versa. Therefore:
<br>> Base =E2=8A=86 <<a href=3D"http://en.wikipedia.org/wiki/%E2%8A%=
86" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%258A%2586\46sa\75D\46sntz=
\0751\46usg\75AFQjCNFtDGIOL4HI5RlVv-wBbobgcv0r9Q';return true;" onclick=3D"=
this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fen.wikipedia.org%2F=
wiki%2F%25E2%258A%2586\46sa\75D\46sntz\0751\46usg\75AFQjCNFtDGIOL4HI5RlVv-w=
Bbobgcv0r9Q';return true;">http://en.wikipedia.org/wiki/<wbr>%E2%8A%86</a>&=
gt; Extension
<br>>=20
<br>> Because of that I don't think this is an existing concept, and it =
is NOT
<br>> inheritance. Consequently, the conversion rules are opposite from =
those in
<br>> inheritance: You can convert from the base enum class to its exten=
sion, but
<br>> you can not convert from extension to its base class safely.
<br>
<br>Okay, now I see where you're coming from. Thanks.
<br>
<br>I'm still not convinced this difference is sufficient to justify
<br>something other than the "natural" syntax for this mechanism, but since
<br>I don't get an official vote, I guess that's just MHO...
<br>
<br>For what it's worth, I feel rather more strongly that related enums
<br>should be by "extension" and not by subsetting, mainly because of DRY;
<br>the syntax for the latter is going to be really verbose, and especially
<br>unwieldy in the case of enums having a lot of values. There's also
<br>nothing even remotely like it in the language currently.
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote></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_3979_1716575572.1412269655932--
.
Author: oggy22@gmail.com
Date: Sat, 23 Apr 2016 22:22:46 -0700 (PDT)
Raw View
------=_Part_4355_1895917325.1461475366164
Content-Type: multipart/alternative;
boundary="----=_Part_4356_1573997325.1461475366164"
------=_Part_4356_1573997325.1461475366164
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Are there any news on this? Did anybody write a proposal?
It's been year and half already...
On Thursday, October 2, 2014 at 10:07:36 AM UTC-7, ogg...@gmail.com wrote:
>
> I strongly agree with you: Subseting doesn't seem to be a good idea=20
> because of DRY and verbosity.
>
> On Monday, September 29, 2014 12:28:47 PM UTC-7, Matthew Woehlke wrote:
>>
>> On 2014-09-26 20:08, Ognjen Sobajic wrote:=20
>> > My explanation might not have been the most precise. I will try to=20
>> explain=20
>> > in other words.=20
>> > In terms of sets, the inheritance means subset such that the set of al=
l=20
>> the=20
>> > instances of class Derived is a subset of the set of all the instances=
=20
>> of=20
>> > the class Base. (One can argue that they are not sets but rather=20
>> classes,=20
>> > which I agree with, but let's put this fact aside because it's=20
>> > perpendicular to my point). Given that we can say:=20
>> > Derived =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Base=20
>> > and therefore=20
>> > if object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Derived t=
hen also=20
>> > object =E2=88=88 <http://en.wikipedia.org/wiki/%E2%88%88> Base (but no=
t vice=20
>> > versa). Therefore, we are allowed to convert from Derived to Base.=20
>> > In the case of enum classes we have a quite opposite situation. If the=
=20
>> > value is in the base enum class then it is in its "extension" as well,=
=20
>> but=20
>> > not vice versa. Therefore:=20
>> > Base =E2=8A=86 <http://en.wikipedia.org/wiki/%E2%8A%86> Extension=20
>> >=20
>> > Because of that I don't think this is an existing concept, and it is=
=20
>> NOT=20
>> > inheritance. Consequently, the conversion rules are opposite from thos=
e=20
>> in=20
>> > inheritance: You can convert from the base enum class to its extension=
,=20
>> but=20
>> > you can not convert from extension to its base class safely.=20
>>
>> Okay, now I see where you're coming from. Thanks.=20
>>
>> I'm still not convinced this difference is sufficient to justify=20
>> something other than the "natural" syntax for this mechanism, but since=
=20
>> I don't get an official vote, I guess that's just MHO...=20
>>
>> For what it's worth, I feel rather more strongly that related enums=20
>> should be by "extension" and not by subsetting, mainly because of DRY;=
=20
>> the syntax for the latter is going to be really verbose, and especially=
=20
>> unwieldy in the case of enums having a lot of values. There's also=20
>> nothing even remotely like it in the language currently.=20
>>
>> --=20
>> Matthew=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/59d48c49-99fd-4d64-9f61-f0b7fcc8cbad%40isocpp.or=
g.
------=_Part_4356_1573997325.1461475366164
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Are there any news on this? Did anybody write a proposal?<=
div>It's been year and half already...<br><br>On Thursday, October 2, 2=
014 at 10:07:36 AM UTC-7, ogg...@gmail.com wrote:<blockquote class=3D"gmail=
_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;p=
adding-left: 1ex;"><div dir=3D"ltr">I strongly agree with you: Subseting do=
esn't seem to be a good idea because of DRY and verbosity.<br><br>On Mo=
nday, September 29, 2014 12:28:47 PM UTC-7, Matthew Woehlke wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1p=
x #ccc solid;padding-left:1ex">On 2014-09-26 20:08, Ognjen Sobajic wrote:
<br>> My explanation might not have been the most precise. I will try to=
explain
<br>> in other words.
<br>> In terms of sets, the inheritance means subset such that the set o=
f all the
<br>> instances of class Derived is a subset of the set of all the insta=
nces of
<br>> the class Base. (One can argue that they are not sets but rather c=
lasses,
<br>> which I agree with, but let's put this fact aside because it&#=
39;s
<br>> perpendicular to my point). Given that we can say:
<br>> Derived =E2=8A=86 <<a href=3D"http://en.wikipedia.org/wiki/%E2%=
8A%86" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'h=
ttp://www.google.com/url?q\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%=
258A%2586\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFtDGIOL4HI5RlVv-wBbobgcv0=
r9Q';return true;" onclick=3D"this.href=3D'http://www.google.com/ur=
l?q\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%258A%2586\x26sa\x3dD\x2=
6sntz\x3d1\x26usg\x3dAFQjCNFtDGIOL4HI5RlVv-wBbobgcv0r9Q';return true;">=
http://en.wikipedia.org/wiki/<wbr>%E2%8A%86</a>> Base
<br>> and therefore
<br>> if object =E2=88=88 <<a href=3D"http://en.wikipedia.org/wiki/%E=
2%88%88" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'=
;http://www.google.com/url?q\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E=
2%2588%2588\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF6AFxJzUCinJJOT6_3q4FfO=
C5ESA';return true;" onclick=3D"this.href=3D'http://www.google.com/=
url?q\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%2588%2588\x26sa\x3dD\=
x26sntz\x3d1\x26usg\x3dAFQjCNF6AFxJzUCinJJOT6_3q4FfOC5ESA';return true;=
">http://en.wikipedia.org/wiki/<wbr>%E2%88%88</a>> Derived then also
<br>> object =E2=88=88 <<a href=3D"http://en.wikipedia.org/wiki/%E2%8=
8%88" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'ht=
tp://www.google.com/url?q\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%2=
588%2588\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNF6AFxJzUCinJJOT6_3q4FfOC5E=
SA';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%2588%2588\x26sa\x3dD\x26=
sntz\x3d1\x26usg\x3dAFQjCNF6AFxJzUCinJJOT6_3q4FfOC5ESA';return true;">h=
ttp://en.wikipedia.org/wiki/<wbr>%E2%88%88</a>> Base (but not vice
<br>> versa). Therefore, we are allowed to convert from Derived to Base.
<br>> In the case of enum classes we have a quite opposite situation. If=
the
<br>> value is in the base enum class then it is in its "extension&=
quot; as well, but
<br>> not vice versa. Therefore:
<br>> Base =E2=8A=86 <<a href=3D"http://en.wikipedia.org/wiki/%E2%8A%=
86" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http=
://www.google.com/url?q\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%258=
A%2586\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFtDGIOL4HI5RlVv-wBbobgcv0r9Q=
';return true;" onclick=3D"this.href=3D'http://www.google.com/url?q=
\x3dhttp%3A%2F%2Fen.wikipedia.org%2Fwiki%2F%25E2%258A%2586\x26sa\x3dD\x26sn=
tz\x3d1\x26usg\x3dAFQjCNFtDGIOL4HI5RlVv-wBbobgcv0r9Q';return true;">htt=
p://en.wikipedia.org/wiki/<wbr>%E2%8A%86</a>> Extension
<br>>=20
<br>> Because of that I don't think this is an existing concept, and=
it is NOT
<br>> inheritance. Consequently, the conversion rules are opposite from =
those in
<br>> inheritance: You can convert from the base enum class to its exten=
sion, but
<br>> you can not convert from extension to its base class safely.
<br>
<br>Okay, now I see where you're coming from. Thanks.
<br>
<br>I'm still not convinced this difference is sufficient to justify
<br>something other than the "natural" syntax for this mechanism,=
but since
<br>I don't get an official vote, I guess that's just MHO...
<br>
<br>For what it's worth, I feel rather more strongly that related enums
<br>should be by "extension" and not by subsetting, mainly becaus=
e of DRY;
<br>the syntax for the latter is going to be really verbose, and especially
<br>unwieldy in the case of enums having a lot of values. There's also
<br>nothing even remotely like it in the language currently.
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote></div></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/59d48c49-99fd-4d64-9f61-f0b7fcc8cbad%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/59d48c49-99fd-4d64-9f61-f0b7fcc8cbad=
%40isocpp.org</a>.<br />
------=_Part_4356_1573997325.1461475366164--
------=_Part_4355_1895917325.1461475366164--
.