220 9045 <37df8922-491a-43cf-b597-fc44f8e78f0a@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Daryle Walker <darylew@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: General anonymous class proposal
Date: Mon, 3 Feb 2014 17:59:36 -0800 (PST)
Lines: 161
Approved: news@gmane.org
Message-ID: <37df8922-491a-43cf-b597-fc44f8e78f0a@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1843_11093930.1391479176359"
X-Trace: ger.gmane.org 1391479170 22451 80.91.229.3 (4 Feb 2014 01:59:30 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 4 Feb 2014 01:59:30 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDS6X4FNQMPBBCMTYGLQKGQEPMPJLWQ@isocpp.org Tue Feb 04 02:59:40 2014
Return-path: <std-proposals+bncBDS6X4FNQMPBBCMTYGLQKGQEPMPJLWQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f69.google.com ([209.85.220.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDS6X4FNQMPBBCMTYGLQKGQEPMPJLWQ@isocpp.org>)
	id 1WAVIZ-0001ct-69
	for gclcip-std-proposals@m.gmane.org; Tue, 04 Feb 2014 02:59:39 +0100
Original-Received: by mail-pa0-f69.google.com with SMTP id fa1sf21263593pad.4
        for <gclcip-std-proposals@m.gmane.org>; Mon, 03 Feb 2014 17:59:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe:content-type;
        bh=NBurF2z5nZFI1x/w3kBQSY27hSmAtu/InxBLchmuUbk=;
        b=wRDD4kN/QRNd4iP81rlNSdBZ7IPqCxsUG2NdoHi8Apphblth6/wnqJrUREIwnQbPK0
         FNYOs2zrKWzNrNK/j8d/nxehGTiOYHYx8i3J4jixi5SVQ7uBXONxmtmaVpJkUrJDFMYL
         O19ZbI8Jc4XoHnWqWk3OuNs/XRcvfR3UdDnfAYxaUWxgjW0Vs4vrGhlpSzpxpu+U5PTt
         +mGxepTxJhoQz++WGdbz0Po5CS/wR4n3lfgrFTYswE2hL2vibh7K3g/iM1/B3ySxNvfO
         CdXQMskCEs7gqpNCncZaxPCTRWm6UnNSxeuhQ6aA5Y3GnjDTc3oFNSv6JQzHGjOKqRoF
         4DDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=NBurF2z5nZFI1x/w3kBQSY27hSmAtu/InxBLchmuUbk=;
        b=KX0DYBwMHjNd+s2v3Fo+0YyX4kfCpVbYhVsCrRVc98GlbOrMJSnWp8wZ2gSWWMlYZM
         cOJxS9AUjw4MWthx41cUCtXCE8FUJnZbgzYpOyUICFpvESEe/cJcb7fJUyZmJIzcqlAS
         J+tuQ+4hfn1Gk5VV5GSLpOdwR4fRq239PfAQWw9soE1jsKdJJnVlFS8eB9Pez5pO0yHm
         /A8VzFbwinRJ5pmG4Dqtj5+AiSOWnwLOqBt5J6PHgwR1qyhkBjfuxwowAvOsbPtpjmP2
         OvD07q9kJljaMC16SumBuRyYd1eRTP+3in747kG3W22+HH5AuJPFKV1zf5rbCyv3Esru
         VN/A==
X-Gm-Message-State: ALoCoQkIcYQKxaGV9/LkaZdjPrTxII+r4+rivMLDWUhhpvRcELbZpIv1WbEuIzAgPmygdmiV/jsj
X-Received: by 10.66.137.43 with SMTP id qf11mr14679000pab.28.1391479177983;
        Mon, 03 Feb 2014 17:59:37 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.80.98 with SMTP id b89ls2243795qgd.9.gmail; Mon, 03 Feb
 2014 17:59:36 -0800 (PST)
X-Received: by 10.140.47.43 with SMTP id l40mr1130qga.11.1391479176863;
        Mon, 03 Feb 2014 17:59:36 -0800 (PST)
X-Original-Sender: darylew@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:9045
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9045>

------=_Part_1843_11093930.1391479176359
Content-Type: text/plain; charset=UTF-8

I got a proposal for anonymous classes<http://htmlpreview.github.io/?https://raw.github.com/CTMacUser/multiarray-iso-proposal/master/anonymous-class-proposal.html>uploaded on my GitHub pages. It generalizes the C++ anonymous union feature 
in a way that should be compatible with the C11 anonymous structure & union 
feature. I'm looking if I missed something in the sections I proposed to 
change, and if I need to change more sections.

Handling of anonymous unions in the C++ way has been (mostly) changed to 
the C11 way:

struct A {
  int a; union { int b; /*...*/ };
} x = { 1, { 2 } }, y = { 3, 4 };


In current C++, the second initializer term in x is the proper way to 
initialize the anonymous union, and the version in y is the slack version 
in that braces are elided. In C11, the official-ness is reversed: the 
second initializer term in y is the proper way to initialize the b member 
(Named members of anonymous composites are spewed to their enclosing scope, 
recursively if needed.) and the version in x is the slack version with a 
gratuitous pair of braces. My proposal goes the C11 way, which is a 
"breaking" change with no effect (I hope).

Due to arbitrary nesting and that an anonymous struct may be a member of a 
union, the variant branches of a union may have multiple co-variants 
instead of always exactly one co-variant per variant branch. I added the 
terms "conflicting members" and "non-conflicting members" to replace the 
idea that a class's variants are always distinct and mutually-exclusive.

I call considering the members of an anonymous class to be part of the 
encloser's scope to be their "elevated scope." Members nested in at least 
two anonymous classes bubble up to use the outermost's class's enclosing 
scope.

When an anonymous class member is empty, the member is considered part of 
the enclosing class. This is the C++ way of handling empty classes, instead 
of the C11 way of never considering anonymous class subobjects as 
themselves. This shouldn't break anything because empty composites are 
illegal in C(11)! (C requires structs and unions to have at least one 
member; they can't be empty. Please notify me if I got this wrong.)

Daryle W.

-- 

--- 
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_1843_11093930.1391479176359
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I got a <a href=3D"http://htmlpreview.github.io/?http=
s://raw.github.com/CTMacUser/multiarray-iso-proposal/master/anonymous-class=
-proposal.html">proposal for anonymous classes</a> uploaded on my GitHub pa=
ges. It generalizes the C++ anonymous union feature in a way that should be=
 compatible with the C11 anonymous structure &amp; union feature. I'm looki=
ng if I missed something in the sections I proposed to change, and if I nee=
d to change more sections.</div><div><br></div><div>Handling of anonymous u=
nions in the C++ way has been (mostly) changed to the C11 way:</div><div><b=
r></div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(187, 187,=
 187); border-image: none; -ms-word-wrap: break-word; background-color: rgb=
(250, 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><font color=3D"#000088"><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(0, 0, 136);">struct</span></font><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 0, 0);"> A </span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify=
" style=3D"color: rgb(0, 0, 0);"><br>&nbsp; </span><span class=3D"styled-by=
-prettify" style=3D"color: rgb(0, 0, 136);">int</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(0, 0, 0);"> a</span><span class=3D"styled=
-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><span class=3D"sty=
led-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styl=
ed-by-prettify" style=3D"color: rgb(0, 0, 136);">union</span><span class=3D=
"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"=
styled-by-prettify" style=3D"color: rgb(102, 102, 0);">{</span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span class=
=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 136);">int</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> b</span><span cl=
ass=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">;</span><span=
 class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span><span =
class=3D"styled-by-prettify" style=3D"color: rgb(136, 0, 0);">/*...*/</span=
><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"> </span>=
<span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);">};</s=
pan><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);"><br><=
/span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, 0);"=
>}</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0, 0);">=
 x </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 102, =
0);">=3D</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 0,=
 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(102, 1=
02, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, =
0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb(0, 1=
02, 102);">1</span><span class=3D"styled-by-prettify" style=3D"color: rgb(1=
02, 102, 0);">,</span><span class=3D"styled-by-prettify" style=3D"color: rg=
b(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: rgb=
(102, 102, 0);">{</span><span class=3D"styled-by-prettify" style=3D"color: =
rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color: r=
gb(0, 102, 102);">2</span><span class=3D"styled-by-prettify" style=3D"color=
: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"color:=
 rgb(102, 102, 0);">}</span><span class=3D"styled-by-prettify" style=3D"col=
or: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" style=3D"colo=
r: rgb(102, 102, 0);">},</span><span class=3D"styled-by-prettify" style=3D"=
color: rgb(0, 0, 0);"> y </span><span class=3D"styled-by-prettify" style=3D=
"color: rgb(102, 102, 0);">=3D</span><span class=3D"styled-by-prettify" sty=
le=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" styl=
e=3D"color: rgb(102, 102, 0);">{</span><span class=3D"styled-by-prettify" s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettify" st=
yle=3D"color: rgb(0, 102, 102);">3</span><span class=3D"styled-by-prettify"=
 style=3D"color: rgb(102, 102, 0);">,</span><span class=3D"styled-by-pretti=
fy" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prettif=
y" style=3D"color: rgb(0, 102, 102);">4</span><span class=3D"styled-by-pret=
tify" style=3D"color: rgb(0, 0, 0);"> </span><span class=3D"styled-by-prett=
ify" style=3D"color: rgb(102, 102, 0);">};</span><span class=3D"styled-by-p=
rettify" style=3D"color: rgb(0, 0, 0);"><br></span></div></code></div><p><b=
r></p><div>In current C++, the second initializer term in <font face=3D"cou=
rier new,monospace">x</font> is the proper way to initialize the anonymous =
union, and the version in <font face=3D"courier new,monospace">y</font> is =
the slack version in that braces are elided. In C11, the official-ness is r=
eversed: the second initializer term in <font face=3D"courier new,monospace=
">y</font> is the proper way to initialize the <font face=3D"courier new,mo=
nospace">b</font> member (Named members of anonymous composites are spewed =
to their enclosing scope, recursively if needed.) and the version in <font =
face=3D"courier new,monospace">x</font> is the slack version with a gratuit=
ous pair of braces. My proposal goes the C11 way, which&nbsp;is a "breaking=
" change with no effect (I hope).</div><div><br></div><div>Due to arbitrary=
 nesting and that an anonymous struct may be a member of a union, the varia=
nt branches of a union may have multiple co-variants instead of always exac=
tly one co-variant per variant branch. I added the terms "conflicting membe=
rs" and "non-conflicting members" to replace the idea that a class's varian=
ts are always distinct and mutually-exclusive.</div><div><br></div><div>I c=
all considering the members of an anonymous class to be part of the enclose=
r's scope to be their "elevated scope." Members nested in at least two anon=
ymous classes bubble up to use the outermost's class's enclosing scope.</di=
v><div><br></div><div>When an anonymous class member is empty, the member i=
s considered part of the enclosing class. This is the C++ way of handling e=
mpty classes, instead of the C11 way of never considering anonymous class s=
ubobjects as themselves. This shouldn't break anything because empty compos=
ites are illegal in C(11)! (C requires structs and unions to have at least =
one member; they can't be empty. Please notify me if I got this wrong.)</di=
v><div><br></div><div>Daryle W.</div><div><br></div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_1843_11093930.1391479176359--

.
