Topic: First draft proposal of pre-constructor scope.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Mon, 11 Feb 2019 23:27:34 +1000
Raw View
--000000000000333e8f05819e46ac
Content-Type: text/plain; charset="UTF-8"
Here is a first scribble of a proposal I am working on called
pre-constructor scope. Feedback appreciated....
*Summary*
We propose allowing constructors to execute statements and declare local
variables after the constructors parameters are in scope but before the
object (this) is in scope and before its data members are in scope and
initialized.
*Motivation*
Classes have data members (and base subobjects, which we will call data
members for this discussion). Constructors take parameters, initialize
data members and then execute a compound statement:
struct S {
// data members
M1 m1; M2 m2; M3 m3;
// constructor
S(P1 p1, P2 p2, P3 p3) // take parameters
: m1(f1(p1,p2,p3)) // initialize data members
, m2(f2(p1,p2,p3))
, m3(f3(p1,p2,p3))
{ g1(p1,p2,p3,m1,m2,m3); } // execute compound statement
};
It comes up often that a constructor designer wishes to execute some code
and/or create some intermediate objects that consume the parameters of the
constructor, and are consumed by the initialization of the data members.
We therefore propose extending the constructor definition to provide a way
to do that.
*Design*
We demonstrate our proposed syntax:
struct S {
// data members
M1 m1; M2 m2; M3 m3;
// constructor
S(P1 p1, P2 p2, P3 p3) // take parameters
{
g1(p1,p2,p3); // execute statements
L1 l1 = h1(p1,p2,p3); // declare local variables
L2 l2 = h2(p1,p2,p3);
L3 l3 = h3(p1,p2,p3);
this; // ERROR: `this` not in scope yet
m1; // ERROR: `this` not in scope yet
this : m1(f1(p1,p2,p3,l1,l2,l3)) // initialize data members
, m2(f2(p1,p2,p3,l1,l2,l3)) // and introduce `this` into
, m3(f3(p1,p2,p3,l1,l2,l3)); // scope and initializes object
this; // OK: `this` in scope
m1; // OK: `this` in scope
g2(p1,p2,p3,l1,l2,l3,m1,m2,m3); // execute statements
}
};
There is a new kind of statement called an object initialization
statement. It is formed by a this keyword token, a colon token followed by
a member-initializer-list, followed by a semi-colon.
A constructor definition may contain at most one member-initializer-list
(either in the normal place or in an object initialization statement).
If a constructor definition contains an object initialization statement it
must appear directly as one of the statements in the statement-seq of the
constructor body. The constructor is then divided into two statement-seqs,
one before the object initialization statement, called the pre-constructor
and one that contains it and the statements after it called the
post-constructor. A scope is introduced at the start of the
pre-constructor that contains the usual scope of a static member function.
That is, it can't see this. A new inner scope of the pre-constructor is
introduced for the post-constructor that has everything from the
pre-constructor in scope plus this. The post-constructor has the scope of
a non-static member function, like normal constructors.
The object (and its members) are initialized by the object initialization
statement.
It's kind of like the object initialization statement "declares" the object
(this).
*Wording*
TODO
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.com.
--000000000000333e8f05819e46ac
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Here is a first scribble of a proposal I am working o=
n called pre-constructor scope.=C2=A0 Feedback appreciated....<br></div><di=
v><b><br></b></div><div><b>Summary</b></div><div><br></div><div>We propose =
allowing constructors to execute statements and declare local variables aft=
er the constructors parameters are in scope but before the object (this) is=
in scope and before its data members are in scope and initialized.</div><d=
iv><br></div><b>Motivation</b><div><br></div><div>Classes have data members=
(and base subobjects, which we will call data members for this discussion)=
..=C2=A0 Constructors take parameters, initialize data members and then exec=
ute a compound statement:</div><div><font face=3D"monospace, monospace"><br=
></font></div><div><font face=3D"monospace, monospace">struct S {</font></d=
iv><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// data members</f=
ont></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0M1 m1; M2 m=
2; M3 m3;</font></div><div><font face=3D"monospace, monospace"><br></font><=
/div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// constructor</=
font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0S(P1 p1, P=
2 p2, P3 p3)=C2=A0 // take parameters</font></div><div><font face=3D"monosp=
ace, monospace">=C2=A0 =C2=A0: m1(f1(p1,p2,p3)) // initialize data members<=
/font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0, m2(f2(p=
1,p2,p3))</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0, m3(f3(p1,p2,p3))</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0{ g1(p1,p2,p3,m1,m2,m3); }=C2=A0 // execute compound statement=
</font></div><div><font face=3D"monospace, monospace">};</font></div><div><=
br></div><div>It comes up often that a constructor designer wishes to execu=
te some code and/or create some intermediate objects that consume the param=
eters of the constructor, and are consumed by the initialization of the dat=
a members.</div><div><br></div><div>We therefore propose extending the cons=
tructor definition to provide a way to do that.</div><div><br></div><div><b=
>Design</b></div><div><br></div><div>We demonstrate our proposed syntax:</d=
iv><div><br></div><div><div><font face=3D"monospace, monospace">struct S {<=
/font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// data m=
embers</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0M1=
m1; M2 m2; M3 m3;</font></div><div><font face=3D"monospace, monospace"><br=
></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// cons=
tructor</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0S=
(P1 p1, P2 p2, P3 p3)=C2=A0 // take parameters</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0{</font></div><div><font face=3D"mon=
ospace, monospace">=C2=A0 =C2=A0 =C2=A0g1(p1,p2,p3); // execute statements<=
/font></div><div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=
=A0L1 l1 =3D h1(p1,p2,p3); // declare local variables</font></div><div><fon=
t face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L2 l2 =3D h2(p1,p2,p3);=
</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L=
3 l3 =3D h3(p1,p2,p3);</font></div><font face=3D"monospace, monospace"><br =
class=3D"gmail-Apple-interchange-newline"></font></div><div><font face=3D"m=
onospace, monospace">=C2=A0 =C2=A0 =C2=A0this; // ERROR: `this` not in scop=
e yet</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =
=C2=A0m1; // ERROR: `this` not in scope yet</font></div><div><font face=3D"=
monospace, monospace">=C2=A0 =C2=A0 =C2=A0</font></div><div><font face=3D"m=
onospace, monospace">=C2=A0 =C2=A0 =C2=A0this : m1(f1(p1,p2,p3,l1,l2,l3))=
=C2=A0 // initialize data members</font></div><div><font face=3D"monospace,=
monospace">=C2=A0 =C2=A0 =C2=A0, m2(f2(p1,p2,p3,l1,l2,l3))=C2=A0 // and in=
troduce `this` into</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0 =C2=A0, m3(f3(p1,p2,p3,l1,l2,l3)); // scope and initializes o=
bject</font></div><div><font face=3D"monospace, monospace"><br></font></div=
><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0this; // OK: =
`this` in scope</font></div><div><font face=3D"monospace, monospace">=C2=A0=
=C2=A0 =C2=A0m1; // OK: `this` in scope</font></div><div><font face=3D"mon=
ospace, monospace"><br></font></div><div><font face=3D"monospace, monospace=
">=C2=A0 =C2=A0 =C2=A0g2(p1,p2,p3,l1,l2,l3,m1,m2,m3); // execute statements=
</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0}</font>=
</div><div><font face=3D"monospace, monospace">};</font></div><br class=3D"=
gmail-Apple-interchange-newline"></div><div>There is a new kind of statemen=
t called an object initialization statement.=C2=A0 It is formed by a this k=
eyword token, a colon token followed by a member-initializer-list, followed=
by a semi-colon.</div><div><br></div><div>A constructor definition may con=
tain at most one member-initializer-list (either in the normal place or in =
an object initialization statement).</div><div><br></div><div>If a construc=
tor definition contains an object initialization statement it must appear d=
irectly as one of the statements in the statement-seq of the constructor bo=
dy.=C2=A0 The constructor is then divided into two statement-seqs, one befo=
re the object initialization statement, called the pre-constructor and one =
that contains it and the statements after it called the post-constructor.=
=C2=A0 A scope is introduced at the start of the pre-constructor that conta=
ins the usual scope of a static member function.=C2=A0 That is, it can'=
t see this.=C2=A0 A new inner scope of the pre-constructor is introduced fo=
r the post-constructor that has everything from the pre-constructor in scop=
e plus this.=C2=A0 The post-constructor has the scope of a non-static membe=
r function, like normal constructors.</div><div><br></div><div>The object (=
and its members) are initialized by the object initialization statement.</d=
iv><div><br></div><div>It's kind of like the object initialization stat=
ement "declares" the object (this).</div><div><br></div><div><b>W=
ording</b></div><div><br></div><div>TODO</div><div><br></div><div><br></div=
></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOO=
DLjSmjwnOjE1QokA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7c=
U53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.com</a>.<br />
--000000000000333e8f05819e46ac--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Mon, 11 Feb 2019 09:52:14 -0500
Raw View
--00000000000018486705819f754c
Content-Type: text/plain; charset="UTF-8"
On Mon, Feb 11, 2019 at 8:27 AM Andrew Tomazos <andrewtomazos@gmail.com>
wrote:
> Here is a first scribble of a proposal I am working on called
> pre-constructor scope. Feedback appreciated....
>
> *Summary*
>
> We propose allowing constructors to execute statements and declare local
> variables after the constructors parameters are in scope but before the
> object (this) is in scope and before its data members are in scope and
> initialized.
>
> *Motivation*
>
> Classes have data members (and base subobjects, which we will call data
> members for this discussion). Constructors take parameters, initialize
> data members and then execute a compound statement:
>
> struct S {
> // data members
> M1 m1; M2 m2; M3 m3;
>
> // constructor
> S(P1 p1, P2 p2, P3 p3) // take parameters
> : m1(f1(p1,p2,p3)) // initialize data members
> , m2(f2(p1,p2,p3))
> , m3(f3(p1,p2,p3))
> { g1(p1,p2,p3,m1,m2,m3); } // execute compound statement
> };
>
> It comes up often that a constructor designer wishes to execute some code
> and/or create some intermediate objects that consume the parameters of the
> constructor, and are consumed by the initialization of the data members.
>
> We therefore propose extending the constructor definition to provide a way
> to do that.
>
> *Design*
>
> We demonstrate our proposed syntax:
>
> struct S {
> // data members
> M1 m1; M2 m2; M3 m3;
>
> // constructor
> S(P1 p1, P2 p2, P3 p3) // take parameters
>
You need syntax up here saying you are in this mode
otherwise...
{
> g1(p1,p2,p3); // execute statements
> L1 l1 = h1(p1,p2,p3); // declare local variables
> L2 l2 = h2(p1,p2,p3);
> L3 l3 = h3(p1,p2,p3);
>
>
how does the compiler know this (pun intended) is an error:
this; // ERROR: `this` not in scope yet
> m1; // ERROR: `this` not in scope yet
>
does it need to *look ahead* through the whole function to find this: (pun
intended)
> this : m1(f1(p1,p2,p3,l1,l2,l3)) // initialize data members
> , m2(f2(p1,p2,p3,l1,l2,l3)) // and introduce `this` into
> , m3(f3(p1,p2,p3,l1,l2,l3)); // scope and initializes object
>
> this; // OK: `this` in scope
> m1; // OK: `this` in scope
>
> g2(p1,p2,p3,l1,l2,l3,m1,m2,m3); // execute statements
> }
> };
>
>
P.S. I don't like the idea. Just don't think it is worth it. And I
suspect it only helps classes that are actually overly complicated, and
that is where the real problem is.
There is a new kind of statement called an object initialization
> statement. It is formed by a this keyword token, a colon token followed by
> a member-initializer-list, followed by a semi-colon.
>
> A constructor definition may contain at most one member-initializer-list
> (either in the normal place or in an object initialization statement).
>
> If a constructor definition contains an object initialization statement it
> must appear directly as one of the statements in the statement-seq of the
> constructor body. The constructor is then divided into two statement-seqs,
> one before the object initialization statement, called the pre-constructor
> and one that contains it and the statements after it called the
> post-constructor. A scope is introduced at the start of the
> pre-constructor that contains the usual scope of a static member function.
> That is, it can't see this. A new inner scope of the pre-constructor is
> introduced for the post-constructor that has everything from the
> pre-constructor in scope plus this. The post-constructor has the scope of
> a non-static member function, like normal constructors.
>
> The object (and its members) are initialized by the object initialization
> statement.
>
> It's kind of like the object initialization statement "declares" the
> object (this).
>
> *Wording*
>
> TODO
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
Be seeing you,
Tony
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbivejf%2BzdSZvxe4E55fcc%2BoOn1f48bCx-xTa_-ErD0J0uA%40mail.gmail.com.
--00000000000018486705819f754c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Mon, Feb 11, 2019 at 8:27 AM Andre=
w Tomazos <<a href=3D"mailto:andrewtomazos@gmail.com">andrewtomazos@gmai=
l.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex"><div dir=3D"ltr"><div>Here is a first scribble of a proposal I am work=
ing on called pre-constructor scope.=C2=A0 Feedback appreciated....<br></di=
v><div><b><br></b></div><div><b>Summary</b></div><div><br></div><div>We pro=
pose allowing constructors to execute statements and declare local variable=
s after the constructors parameters are in scope but before the object (thi=
s) is in scope and before its data members are in scope and initialized.</d=
iv><div><br></div><b>Motivation</b><div><br></div><div>Classes have data me=
mbers (and base subobjects, which we will call data members for this discus=
sion).=C2=A0 Constructors take parameters, initialize data members and then=
execute a compound statement:</div><div><font face=3D"monospace, monospace=
"><br></font></div><div><font face=3D"monospace, monospace">struct S {</fon=
t></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// data membe=
rs</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0M1 m1;=
M2 m2; M3 m3;</font></div><div><font face=3D"monospace, monospace"><br></f=
ont></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// construc=
tor</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0S(P1 =
p1, P2 p2, P3 p3)=C2=A0 // take parameters</font></div><div><font face=3D"m=
onospace, monospace">=C2=A0 =C2=A0: m1(f1(p1,p2,p3)) // initialize data mem=
bers</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0, m2=
(f2(p1,p2,p3))</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0, m3(f3(p1,p2,p3))</font></div><div><font face=3D"monospace, monospac=
e">=C2=A0 =C2=A0{ g1(p1,p2,p3,m1,m2,m3); }=C2=A0 // execute compound statem=
ent</font></div><div><font face=3D"monospace, monospace">};</font></div><di=
v><br></div><div>It comes up often that a constructor designer wishes to ex=
ecute some code and/or create some intermediate objects that consume the pa=
rameters of the constructor, and are consumed by the initialization of the =
data members.</div><div><br></div><div>We therefore propose extending the c=
onstructor definition to provide a way to do that.</div><div><br></div><div=
><b>Design</b></div><div><br></div><div>We demonstrate our proposed syntax:=
</div><div><br></div><div><div><font face=3D"monospace, monospace">struct S=
{</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// dat=
a members</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0M1 m1; M2 m2; M3 m3;</font></div><div><font face=3D"monospace, monospace=
"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0//=
constructor</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0S(P1 p1, P2 p2, P3 p3)=C2=A0 // take parameters</font></div></div></d=
iv></blockquote><div><br></div><div>You need syntax up here saying you are =
in this mode</div><div>otherwise...</div><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><div><font face=3D"m=
onospace, monospace">=C2=A0 =C2=A0{</font></div><div><font face=3D"monospac=
e, monospace">=C2=A0 =C2=A0 =C2=A0g1(p1,p2,p3); // execute statements</font=
></div><div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L1=
l1 =3D h1(p1,p2,p3); // declare local variables</font></div><div><font fac=
e=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L2 l2 =3D h2(p1,p2,p3);</fon=
t></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L3 l3 =
=3D h3(p1,p2,p3);</font></div><font face=3D"monospace, monospace"><br class=
=3D"gmail-m_8915450858215605574gmail-Apple-interchange-newline"></font></di=
v></div></div></blockquote><div><br></div><div>how does the compiler know t=
his (pun intended) is an error:</div><div> <br></div><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204=
,204,204);padding-left:1ex"><div dir=3D"ltr"><div><div><font face=3D"monosp=
ace, monospace"></font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 =C2=A0this; // ERROR: `this` not in scope yet</font></div><div><=
font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0m1; // ERROR: `this`=
not in scope yet</font></div><div><font face=3D"monospace, monospace"></fo=
nt></div></div></div></blockquote><div><br></div><div>does it need to *look=
ahead* through the whole function to find this: (pun intended)<br></div><d=
iv> <br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D=
"ltr"><div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0</f=
ont></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0this=
: m1(f1(p1,p2,p3,l1,l2,l3))=C2=A0 // initialize data members</font></div><=
div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0, m2(f2(p1,p2,p=
3,l1,l2,l3))=C2=A0 // and introduce `this` into</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0, m3(f3(p1,p2,p3,l1,l2,l3)); =
// scope and initializes object</font></div><div><font face=3D"monospace, m=
onospace"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 =C2=A0this; // OK: `this` in scope</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 =C2=A0 =C2=A0m1; // OK: `this` in scope</font></=
div><div><font face=3D"monospace, monospace"><br></font></div><div><font fa=
ce=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0g2(p1,p2,p3,l1,l2,l3,m1,m2,=
m3); // execute statements</font></div><div><font face=3D"monospace, monosp=
ace">=C2=A0 =C2=A0}</font></div><div><font face=3D"monospace, monospace">};=
</font></div><br class=3D"gmail-m_8915450858215605574gmail-Apple-interchang=
e-newline"></div></div></blockquote><div><br></div><div>P.S. I don't li=
ke the idea.=C2=A0 Just don't think it is worth it.=C2=A0 And I suspect=
it only helps classes that are actually overly complicated, and that is wh=
ere the real problem is.</div><div><br></div><div> <br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid=
rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div></div><div>There =
is a new kind of statement called an object initialization statement.=C2=A0=
It is formed by a this keyword token, a colon token followed by a member-i=
nitializer-list, followed by a semi-colon.</div><div><br></div><div>A const=
ructor definition may contain at most one member-initializer-list (either i=
n the normal place or in an object initialization statement).</div><div><br=
></div><div>If a constructor definition contains an object initialization s=
tatement it must appear directly as one of the statements in the statement-=
seq of the constructor body.=C2=A0 The constructor is then divided into two=
statement-seqs, one before the object initialization statement, called the=
pre-constructor and one that contains it and the statements after it calle=
d the post-constructor.=C2=A0 A scope is introduced at the start of the pre=
-constructor that contains the usual scope of a static member function.=C2=
=A0 That is, it can't see this.=C2=A0 A new inner scope of the pre-cons=
tructor is introduced for the post-constructor that has everything from the=
pre-constructor in scope plus this.=C2=A0 The post-constructor has the sco=
pe of a non-static member function, like normal constructors.</div><div><br=
></div><div>The object (and its members) are initialized by the object init=
ialization statement.</div><div><br></div><div>It's kind of like the ob=
ject initialization statement "declares" the object (this).</div>=
<div><br></div><div><b>Wording</b></div><div><br></div><div>TODO</div><div>=
<br></div><div><br></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" 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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOO=
DLjSmjwnOjE1QokA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-pro=
posals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.c=
om</a>.<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g=
mail_signature"><div dir=3D"ltr"><div>Be seeing you,<br></div>Tony<br></div=
></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbivejf%2BzdSZvxe4E55fcc%2BoOn1f4=
8bCx-xTa_-ErD0J0uA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbivejf%2=
BzdSZvxe4E55fcc%2BoOn1f48bCx-xTa_-ErD0J0uA%40mail.gmail.com</a>.<br />
--00000000000018486705819f754c--
.
Author: Bjorn Reese <breese@mail1.stofanet.dk>
Date: Mon, 11 Feb 2019 16:46:17 +0100
Raw View
On 2/11/19 2:27 PM, Andrew Tomazos wrote:
> *Summary*
>
> We propose allowing constructors to execute statements and declare local
> variables after the constructors parameters are in scope but before the
> object (this) is in scope and before its data members are in scope and
> initialized.
Do you have any real examples that cannot be handled by delegating to
private/protected constructors?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/e67d57bf-4a62-41a9-cd3b-92fe78375cd0%40mail1.stofanet.dk.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 11 Feb 2019 07:47:36 -0800 (PST)
Raw View
------=_Part_1280_1322508282.1549900056993
Content-Type: multipart/alternative;
boundary="----=_Part_1281_2075956444.1549900056995"
------=_Part_1281_2075956444.1549900056995
Content-Type: text/plain; charset="UTF-8"
On Monday, February 11, 2019 at 9:52:30 AM UTC-5, Tony V E wrote:
>
>
>
> On Mon, Feb 11, 2019 at 8:27 AM Andrew Tomazos <andrew...@gmail.com
> <javascript:>> wrote:
>
>> Here is a first scribble of a proposal I am working on called
>> pre-constructor scope. Feedback appreciated....
>>
>> *Summary*
>>
>> We propose allowing constructors to execute statements and declare local
>> variables after the constructors parameters are in scope but before the
>> object (this) is in scope and before its data members are in scope and
>> initialized.
>>
>> *Motivation*
>>
>> Classes have data members (and base subobjects, which we will call data
>> members for this discussion). Constructors take parameters, initialize
>> data members and then execute a compound statement:
>>
>> struct S {
>> // data members
>> M1 m1; M2 m2; M3 m3;
>>
>> // constructor
>> S(P1 p1, P2 p2, P3 p3) // take parameters
>> : m1(f1(p1,p2,p3)) // initialize data members
>> , m2(f2(p1,p2,p3))
>> , m3(f3(p1,p2,p3))
>> { g1(p1,p2,p3,m1,m2,m3); } // execute compound statement
>> };
>>
>> It comes up often that a constructor designer wishes to execute some code
>> and/or create some intermediate objects that consume the parameters of the
>> constructor, and are consumed by the initialization of the data members.
>>
>> We therefore propose extending the constructor definition to provide a
>> way to do that.
>>
>> *Design*
>>
>> We demonstrate our proposed syntax:
>>
>> struct S {
>> // data members
>> M1 m1; M2 m2; M3 m3;
>>
>> // constructor
>> S(P1 p1, P2 p2, P3 p3) // take parameters
>>
>
> You need syntax up here saying you are in this mode
> otherwise...
>
> {
>> g1(p1,p2,p3); // execute statements
>> L1 l1 = h1(p1,p2,p3); // declare local variables
>> L2 l2 = h2(p1,p2,p3);
>> L3 l3 = h3(p1,p2,p3);
>>
>>
> how does the compiler know this (pun intended) is an error:
>
> this; // ERROR: `this` not in scope yet
>> m1; // ERROR: `this` not in scope yet
>>
>
> does it need to *look ahead* through the whole function to find this: (pun
> intended)
>
There is also the issue of how the *user* knows that this has taken place.
Having a statement fundamentally change the very nature of the *preceding*
code in the same block is very unusual for C++. I really don't like the
idea that a statement at the bottom of a function can radically change the
meaning of code at the very top. Sure, any breaks will be noisy, but C++ is
usually read top-to-bottom.
If there is going to be some syntax for this, then it really ought to make
a clear, block-level distinction between the code before the member
initializers and the code afterwards.
Also, we already have an adequate solution for this: delegating
constructors. The delegated constructor can take the declared temporaries
as arguments, which it will use as appropriate.
struct S {
// data members
M1 m1; M2 m2; M3 m3;
// constructor
S(P1 p1, P2 p2, P3 p3):
S(p1, p2, p3, h1(p1, p2, p3),
h2(p1, p2, p3),
h3(p1, p2, p3))
{
}
private:
S(P1 p1, P2 p2, P3 p3, L1 l1, L2 l2, L3 l3)
: m1(f1(p1,p2,p3,l1,l2,l3))
, m2(f2(p1,p2,p3,l1,l2,l3))
, m3(f3(p1,p2,p3,l1,l2,l3))
{
g1(p1,p2,p3);
g2(p1,p2,p3,l1,l2,l3,m1,m2,m3); // execute statements
}
};
Note that here, `g1` is called after the object's members are initialized.
That *ought* to be fine; `g1` is a global function whose return value is
discarded. The only way it wouldn't be fine is if `g1` and the initializer
of some of the other members/locals are using external global state. In
which case, I would say... don't do that.
Yes, delegating constructors are a bit cumbersome of a solution. But they
provide a clear, syntactic separation between the code that executes before
the initialization and the code that executes after. Also, given how rarely
this problem comes up, I think the cumbersome nature of this solution is
comparable to the commonality of the problem. That is, it doesn't come up
that often, so having to use a less-than-ideal syntax for it when it does
is OK.
I agree with Tony: the proposed cure is worse than the disease.
If you want to move forward with this, your motivation and design section
needs to explicitly outline:
1: Why it is that delegating constructors are not an acceptable solution.
2: Real-world examples where this syntax would significantly improve code.
The example you provide here is very artificial.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4c22e321-4b77-49e8-9de7-69f3f58b7365%40isocpp.org.
------=_Part_1281_2075956444.1549900056995
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Monday, February 11, 2019 at 9:52:30 AM UTC-5, =
Tony V E 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=
"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr=
">On Mon, Feb 11, 2019 at 8:27 AM Andrew Tomazos <<a href=3D"javascript:=
" target=3D"_blank" gdf-obfuscated-mailto=3D"-k3rMMXpGQAJ" rel=3D"nofollow"=
onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"=
this.href=3D'javascript:';return true;">andrew...@gmail.com</a>>=
wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr"><div>Here is a first scribble of a proposal I am working on called=
pre-constructor scope.=C2=A0 Feedback appreciated....<br></div><div><b><br=
></b></div><div><b>Summary</b></div><div><br></div><div>We propose allowing=
constructors to execute statements and declare local variables after the c=
onstructors parameters are in scope but before the object (this) is in scop=
e and before its data members are in scope and initialized.</div><div><br><=
/div><b>Motivation</b><div><br></div><div>Classes have data members (and ba=
se subobjects, which we will call data members for this discussion).=C2=A0 =
Constructors take parameters, initialize data members and then execute a co=
mpound statement:</div><div><font face=3D"monospace, monospace"><br></font>=
</div><div><font face=3D"monospace, monospace">struct S {</font></div><div>=
<font face=3D"monospace, monospace">=C2=A0 =C2=A0// data members</font></di=
v><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0M1 m1; M2 m2; M3 m3=
;</font></div><div><font face=3D"monospace, monospace"><br></font></div><di=
v><font face=3D"monospace, monospace">=C2=A0 =C2=A0// constructor</font></d=
iv><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0S(P1 p1, P2 p2, P3=
p3)=C2=A0 // take parameters</font></div><div><font face=3D"monospace, mon=
ospace">=C2=A0 =C2=A0: m1(f1(p1,p2,p3)) // initialize data members</font></=
div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0, m2(f2(p1,p2,p3)=
)</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0, m3(f3=
(p1,p2,p3))</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0{ g1(p1,p2,p3,m1,m2,m3); }=C2=A0 // execute compound statement</font></d=
iv><div><font face=3D"monospace, monospace">};</font></div><div><br></div><=
div>It comes up often that a constructor designer wishes to execute some co=
de and/or create some intermediate objects that consume the parameters of t=
he constructor, and are consumed by the initialization of the data members.=
</div><div><br></div><div>We therefore propose extending the constructor de=
finition to provide a way to do that.</div><div><br></div><div><b>Design</b=
></div><div><br></div><div>We demonstrate our proposed syntax:</div><div><b=
r></div><div><div><font face=3D"monospace, monospace">struct S {</font></di=
v><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// data members</fo=
nt></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0M1 m1; M2 m2=
; M3 m3;</font></div><div><font face=3D"monospace, monospace"><br></font></=
div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// constructor</f=
ont></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0S(P1 p1, P2=
p2, P3 p3)=C2=A0 // take parameters</font></div></div></div></blockquote><=
div><br></div><div>You need syntax up here saying you are in this mode</div=
><div>otherwise...</div><div><br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd=
ing-left:1ex"><div dir=3D"ltr"><div><div><font face=3D"monospace, monospace=
">=C2=A0 =C2=A0{</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 =C2=A0g1(p1,p2,p3); // execute statements</font></div><div><div>=
<font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L1 l1 =3D h1(p1,p2,=
p3); // declare local variables</font></div><div><font face=3D"monospace, m=
onospace">=C2=A0 =C2=A0 =C2=A0L2 l2 =3D h2(p1,p2,p3);</font></div><div><fon=
t face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L3 l3 =3D h3(p1,p2,p3);=
</font></div><font face=3D"monospace, monospace"><br></font></div></div></d=
iv></blockquote><div><br></div><div>how does the compiler know this (pun in=
tended) is an error:</div><div> <br></div><blockquote class=3D"gmail_quote"=
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);p=
adding-left:1ex"><div dir=3D"ltr"><div><div><font face=3D"monospace, monosp=
ace"></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =
=C2=A0this; // ERROR: `this` not in scope yet</font></div><div><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0m1; // ERROR: `this` not in s=
cope yet</font></div><div><font face=3D"monospace, monospace"></font></div>=
</div></div></blockquote><div><br></div><div>does it need to *look ahead* t=
hrough the whole function to find this: (pun intended)<br></div></div></div=
></blockquote><div><br></div><div>There is also the issue of how the <i>use=
r</i> knows that this has taken place. Having a statement fundamentally cha=
nge the very nature of the <i>preceding</i> code in the same block is very =
unusual for C++. I really don't like the idea that a statement at the b=
ottom of a function can radically change the meaning of code at the very to=
p. Sure, any breaks will be noisy, but C++ is usually read top-to-bottom.</=
div><div><br></div><div>If there is going to be some syntax for this, then =
it really ought to make a clear, block-level distinction between the code b=
efore the member initializers and the code afterwards.<br></div><div><br></=
div><div>Also, we already have an adequate solution for this: delegating co=
nstructors. The delegated constructor can take the declared temporaries as =
arguments, which it will use as appropriate.</div><div><br></div><div><div =
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, =
187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" c=
lass=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettypri=
nt"><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> S </span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">// data members</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 M1=
m1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> M2 m2</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> M3 m3</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=A0 </span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">// constructor</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 S</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">P1 p1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> P2 p2</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> P3 p3</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">):</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 S</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">p1</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> p2</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> p3</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"> h1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">p1</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> p2</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> p3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0=
=C2=A0 =C2=A0 =C2=A0 h2</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">p1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> p2</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> p3</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 h3</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">p1</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> p2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> p3</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">))</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>=C2=A0 =C2=A0<br></span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">private</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>=C2=A0 =C2=A0 S</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">P1 =
p1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> P2 p2</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> P3 p3</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> L1 l1</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> L2 l2</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> L3 l3</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> m1</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">f1</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">p1</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">p2</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">p3</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
l1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">l2</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">l3</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">))</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> m2</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">f2</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">p1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p2</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">p3</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">l1</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">l2</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">l3=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">))</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> m3</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">f3</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">p1</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">p2</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">p3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">l1</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">l2</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">l3</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">))</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0g1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">p1</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">p2</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">p3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0g2</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">p1</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">p2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">p3</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">l1=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">l2</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">l3</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">m1</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">m2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">m3</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"col=
or: #800;" class=3D"styled-by-prettify">// execute statements</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">};</span></div></code></div><br=
>Note that here, `g1` is called after the object's members are initiali=
zed. That <i>ought</i> to be fine; `g1` is a global function whose return v=
alue is discarded. The only way it wouldn't be fine is if `g1` and the =
initializer of some of the other members/locals are using external global s=
tate. In which case, I would say... don't do that.<br></div><div><br></=
div><div>Yes, delegating constructors are a bit cumbersome of a solution. B=
ut they provide a clear, syntactic separation between the code that execute=
s before the initialization and the code that executes after. Also, given h=
ow rarely this problem comes up, I think the cumbersome nature of this solu=
tion is comparable to the commonality of the problem. That is, it doesn'=
;t come up that often, so having to use a less-than-ideal syntax for it whe=
n it does is OK.<br></div><div><br></div><div>I agree with Tony: the propos=
ed cure is worse than the disease.</div><div><br></div><div>If you want to =
move forward with this, your motivation and design section needs to explici=
tly outline:</div><div><br></div><div>1: Why it is that delegating construc=
tors are not an acceptable solution.</div><div><br></div><div>2: Real-world=
examples where this syntax would significantly improve code. The example y=
ou provide here is very artificial.<br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4c22e321-4b77-49e8-9de7-69f3f58b7365%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4c22e321-4b77-49e8-9de7-69f3f58b7365=
%40isocpp.org</a>.<br />
------=_Part_1281_2075956444.1549900056995--
------=_Part_1280_1322508282.1549900056993--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Tue, 12 Feb 2019 02:00:22 +1000
Raw View
--000000000000c2cb150581a06882
Content-Type: text/plain; charset="UTF-8"
On Tue, Feb 12, 2019 at 12:52 AM Tony V E <tvaneerd@gmail.com> wrote:
>
>
> On Mon, Feb 11, 2019 at 8:27 AM Andrew Tomazos <andrewtomazos@gmail.com>
> wrote:
>
>> Here is a first scribble of a proposal I am working on called
>> pre-constructor scope. Feedback appreciated....
>>
>> *Summary*
>>
>> We propose allowing constructors to execute statements and declare local
>> variables after the constructors parameters are in scope but before the
>> object (this) is in scope and before its data members are in scope and
>> initialized.
>>
>> *Motivation*
>>
>> Classes have data members (and base subobjects, which we will call data
>> members for this discussion). Constructors take parameters, initialize
>> data members and then execute a compound statement:
>>
>> struct S {
>> // data members
>> M1 m1; M2 m2; M3 m3;
>>
>> // constructor
>> S(P1 p1, P2 p2, P3 p3) // take parameters
>> : m1(f1(p1,p2,p3)) // initialize data members
>> , m2(f2(p1,p2,p3))
>> , m3(f3(p1,p2,p3))
>> { g1(p1,p2,p3,m1,m2,m3); } // execute compound statement
>> };
>>
>> It comes up often that a constructor designer wishes to execute some code
>> and/or create some intermediate objects that consume the parameters of the
>> constructor, and are consumed by the initialization of the data members.
>>
>> We therefore propose extending the constructor definition to provide a
>> way to do that.
>>
>> *Design*
>>
>> We demonstrate our proposed syntax:
>>
>> struct S {
>> // data members
>> M1 m1; M2 m2; M3 m3;
>>
>> // constructor
>> S(P1 p1, P2 p2, P3 p3) // take parameters
>>
>
> You need syntax up here saying you are in this mode
> otherwise...
>
> {
>> g1(p1,p2,p3); // execute statements
>> L1 l1 = h1(p1,p2,p3); // declare local variables
>> L2 l2 = h2(p1,p2,p3);
>> L3 l3 = h3(p1,p2,p3);
>>
>>
> how does the compiler know this (pun intended) is an error:
>
> this; // ERROR: `this` not in scope yet
>> m1; // ERROR: `this` not in scope yet
>>
>
> does it need to *look ahead* through the whole function to find this: (pun
> intended)
>
I don't think so. I think it can keep track of whether `this` has been
used as yet, and if it encounters an object initialization statement and
`this` has been used, it can trigger the error then. That's single pass,
and not too different from the problem of untagged coroutine parsing afaik.
>> this : m1(f1(p1,p2,p3,l1,l2,l3)) // initialize data members
>> , m2(f2(p1,p2,p3,l1,l2,l3)) // and introduce `this` into
>> , m3(f3(p1,p2,p3,l1,l2,l3)); // scope and initializes object
>>
>> this; // OK: `this` in scope
>> m1; // OK: `this` in scope
>>
>> g2(p1,p2,p3,l1,l2,l3,m1,m2,m3); // execute statements
>> }
>> };
>>
>>
> P.S. I don't like the idea. Just don't think it is worth it. And I
> suspect it only helps classes that are actually overly complicated, and
> that is where the real problem is.
>
>
> There is a new kind of statement called an object initialization
>> statement. It is formed by a this keyword token, a colon token followed by
>> a member-initializer-list, followed by a semi-colon.
>>
>> A constructor definition may contain at most one member-initializer-list
>> (either in the normal place or in an object initialization statement).
>>
>> If a constructor definition contains an object initialization statement
>> it must appear directly as one of the statements in the statement-seq of
>> the constructor body. The constructor is then divided into two
>> statement-seqs, one before the object initialization statement, called the
>> pre-constructor and one that contains it and the statements after it called
>> the post-constructor. A scope is introduced at the start of the
>> pre-constructor that contains the usual scope of a static member function.
>> That is, it can't see this. A new inner scope of the pre-constructor is
>> introduced for the post-constructor that has everything from the
>> pre-constructor in scope plus this. The post-constructor has the scope of
>> a non-static member function, like normal constructors.
>>
>> The object (and its members) are initialized by the object initialization
>> statement.
>>
>> It's kind of like the object initialization statement "declares" the
>> object (this).
>>
>> *Wording*
>>
>> TODO
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to std-proposals+unsubscribe@isocpp.org.
>> To post to this group, send email to std-proposals@isocpp.org.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.com
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> --
> Be seeing you,
> Tony
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbivejf%2BzdSZvxe4E55fcc%2BoOn1f48bCx-xTa_-ErD0J0uA%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbivejf%2BzdSZvxe4E55fcc%2BoOn1f48bCx-xTa_-ErD0J0uA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KH%2B%3DmMj93WP88ScATwd5X8qz5tHNEkRD7AT-Rju9Tv%2BPdw%40mail.gmail.com.
--000000000000c2cb150581a06882
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Tue, Feb 12, 2019 at 12:52 AM Tony=
V E <<a href=3D"mailto:tvaneerd@gmail.com">tvaneerd@gmail.com</a>> w=
rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr" class=3D"gmail_attr">On Mon, Feb 11, 2019 at 8:27 AM Andrew Tomazo=
s <<a href=3D"mailto:andrewtomazos@gmail.com" target=3D"_blank">andrewto=
mazos@gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad=
ding-left:1ex"><div dir=3D"ltr"><div>Here is a first scribble of a proposal=
I am working on called pre-constructor scope.=C2=A0 Feedback appreciated..=
...<br></div><div><b><br></b></div><div><b>Summary</b></div><div><br></div><=
div>We propose allowing constructors to execute statements and declare loca=
l variables after the constructors parameters are in scope but before the o=
bject (this) is in scope and before its data members are in scope and initi=
alized.</div><div><br></div><b>Motivation</b><div><br></div><div>Classes ha=
ve data members (and base subobjects, which we will call data members for t=
his discussion).=C2=A0 Constructors take parameters, initialize data member=
s and then execute a compound statement:</div><div><font face=3D"monospace,=
monospace"><br></font></div><div><font face=3D"monospace, monospace">struc=
t S {</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// =
data members</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0M1 m1; M2 m2; M3 m3;</font></div><div><font face=3D"monospace, monosp=
ace"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0// constructor</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0S(P1 p1, P2 p2, P3 p3)=C2=A0 // take parameters</font></div><div>=
<font face=3D"monospace, monospace">=C2=A0 =C2=A0: m1(f1(p1,p2,p3)) // init=
ialize data members</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0, m2(f2(p1,p2,p3))</font></div><div><font face=3D"monospace, m=
onospace">=C2=A0 =C2=A0, m3(f3(p1,p2,p3))</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 =C2=A0{ g1(p1,p2,p3,m1,m2,m3); }=C2=A0 // execut=
e compound statement</font></div><div><font face=3D"monospace, monospace">}=
;</font></div><div><br></div><div>It comes up often that a constructor desi=
gner wishes to execute some code and/or create some intermediate objects th=
at consume the parameters of the constructor, and are consumed by the initi=
alization of the data members.</div><div><br></div><div>We therefore propos=
e extending the constructor definition to provide a way to do that.</div><d=
iv><br></div><div><b>Design</b></div><div><br></div><div>We demonstrate our=
proposed syntax:</div><div><br></div><div><div><font face=3D"monospace, mo=
nospace">struct S {</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0// data members</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 =C2=A0M1 m1; M2 m2; M3 m3;</font></div><div><font face=3D"mon=
ospace, monospace"><br></font></div><div><font face=3D"monospace, monospace=
">=C2=A0 =C2=A0// constructor</font></div><div><font face=3D"monospace, mon=
ospace">=C2=A0 =C2=A0S(P1 p1, P2 p2, P3 p3)=C2=A0 // take parameters</font>=
</div></div></div></blockquote><div><br></div><div>You need syntax up here =
saying you are in this mode</div><div>otherwise...</div><div><br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><div><f=
ont face=3D"monospace, monospace">=C2=A0 =C2=A0{</font></div><div><font fac=
e=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0g1(p1,p2,p3); // execute sta=
tements</font></div><div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 =C2=A0L1 l1 =3D h1(p1,p2,p3); // declare local variables</font></div=
><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L2 l2 =3D h2(=
p1,p2,p3);</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 =C2=A0L3 l3 =3D h3(p1,p2,p3);</font></div><font face=3D"monospace, mono=
space"><br class=3D"gmail-m_8666706814611712993gmail-m_8915450858215605574g=
mail-Apple-interchange-newline"></font></div></div></div></blockquote><div>=
<br></div><div>how does the compiler know this (pun intended) is an error:<=
/div><div> <br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div=
dir=3D"ltr"><div><div><font face=3D"monospace, monospace"></font></div><di=
v><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0this; // ERROR: `=
this` not in scope yet</font></div><div><font face=3D"monospace, monospace"=
>=C2=A0 =C2=A0 =C2=A0m1; // ERROR: `this` not in scope yet</font></div><div=
><font face=3D"monospace, monospace"></font></div></div></div></blockquote>=
<div><br></div><div>does it need to *look ahead* through the whole function=
to find this: (pun intended)</div></div></div></blockquote><div>=C2=A0</di=
v><div>I don't think so.=C2=A0 I think it can keep track of whether `th=
is` has been used as yet, and if it encounters an object initialization sta=
tement and `this` has been used, it can trigger the error then.=C2=A0 That&=
#39;s single pass, and not too different from the problem of untagged corou=
tine parsing afaik.</div><div><br></div><div><br></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(2=
04,204,204);padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_quote"><=
div></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr=
"><div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0</font>=
</div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0this : m=
1(f1(p1,p2,p3,l1,l2,l3))=C2=A0 // initialize data members</font></div><div>=
<font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0, m2(f2(p1,p2,p3,l1=
,l2,l3))=C2=A0 // and introduce `this` into</font></div><div><font face=3D"=
monospace, monospace">=C2=A0 =C2=A0 =C2=A0, m3(f3(p1,p2,p3,l1,l2,l3)); // s=
cope and initializes object</font></div><div><font face=3D"monospace, monos=
pace"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 =C2=A0this; // OK: `this` in scope</font></div><div><font face=3D"monos=
pace, monospace">=C2=A0 =C2=A0 =C2=A0m1; // OK: `this` in scope</font></div=
><div><font face=3D"monospace, monospace"><br></font></div><div><font face=
=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0g2(p1,p2,p3,l1,l2,l3,m1,m2,m3=
); // execute statements</font></div><div><font face=3D"monospace, monospac=
e">=C2=A0 =C2=A0}</font></div><div><font face=3D"monospace, monospace">};</=
font></div><br class=3D"gmail-m_8666706814611712993gmail-m_8915450858215605=
574gmail-Apple-interchange-newline"></div></div></blockquote><div><br></div=
><div>P.S. I don't like the idea.=C2=A0 Just don't think it is wort=
h it.=C2=A0 And I suspect it only helps classes that are actually overly co=
mplicated, and that is where the real problem is.</div><div><br></div><div>=
<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"lt=
r"><div></div><div>There is a new kind of statement called an object initia=
lization statement.=C2=A0 It is formed by a this keyword token, a colon tok=
en followed by a member-initializer-list, followed by a semi-colon.</div><d=
iv><br></div><div>A constructor definition may contain at most one member-i=
nitializer-list (either in the normal place or in an object initialization =
statement).</div><div><br></div><div>If a constructor definition contains a=
n object initialization statement it must appear directly as one of the sta=
tements in the statement-seq of the constructor body.=C2=A0 The constructor=
is then divided into two statement-seqs, one before the object initializat=
ion statement, called the pre-constructor and one that contains it and the =
statements after it called the post-constructor.=C2=A0 A scope is introduce=
d at the start of the pre-constructor that contains the usual scope of a st=
atic member function.=C2=A0 That is, it can't see this.=C2=A0 A new inn=
er scope of the pre-constructor is introduced for the post-constructor that=
has everything from the pre-constructor in scope plus this.=C2=A0 The post=
-constructor has the scope of a non-static member function, like normal con=
structors.</div><div><br></div><div>The object (and its members) are initia=
lized by the object initialization statement.</div><div><br></div><div>It&#=
39;s kind of like the object initialization statement "declares" =
the object (this).</div><div><br></div><div><b>Wording</b></div><div><br></=
div><div>TODO</div><div><br></div><div><br></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" 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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOO=
DLjSmjwnOjE1QokA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-pro=
posals/CAB%2B4KHLqG-7cU53K_zQJw6M7ZzUNOHVNOODLjSmjwnOjE1QokA%40mail.gmail.c=
om</a>.<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g=
mail-m_8666706814611712993gmail_signature"><div dir=3D"ltr"><div>Be seeing =
you,<br></div>Tony<br></div></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" 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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbivejf%2BzdSZvxe4E55fcc%2BoOn1f4=
8bCx-xTa_-ErD0J0uA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter" target=3D"_blank">https://groups.google.com/a/isocpp.org/d/msgid/std-p=
roposals/CAOHCbivejf%2BzdSZvxe4E55fcc%2BoOn1f48bCx-xTa_-ErD0J0uA%40mail.gma=
il.com</a>.<br>
</blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KH%2B%3DmMj93WP88ScATwd5X8qz5t=
HNEkRD7AT-Rju9Tv%2BPdw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KH=
%2B%3DmMj93WP88ScATwd5X8qz5tHNEkRD7AT-Rju9Tv%2BPdw%40mail.gmail.com</a>.<br=
/>
--000000000000c2cb150581a06882--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Tue, 12 Feb 2019 02:08:49 +1000
Raw View
--000000000000fdd8c00581a08627
Content-Type: text/plain; charset="UTF-8"
On Tue, Feb 12, 2019 at 1:47 AM Nicol Bolas <jmckesson@gmail.com> wrote:
>
>
> On Monday, February 11, 2019 at 9:52:30 AM UTC-5, Tony V E wrote:
>>
>>
>>
>> On Mon, Feb 11, 2019 at 8:27 AM Andrew Tomazos <andrew...@gmail.com>
>> wrote:
>>
>>> Here is a first scribble of a proposal I am working on called
>>> pre-constructor scope. Feedback appreciated....
>>>
>>> *Summary*
>>>
>>> We propose allowing constructors to execute statements and declare local
>>> variables after the constructors parameters are in scope but before the
>>> object (this) is in scope and before its data members are in scope and
>>> initialized.
>>>
>>> *Motivation*
>>>
>>> Classes have data members (and base subobjects, which we will call data
>>> members for this discussion). Constructors take parameters, initialize
>>> data members and then execute a compound statement:
>>>
>>> struct S {
>>> // data members
>>> M1 m1; M2 m2; M3 m3;
>>>
>>> // constructor
>>> S(P1 p1, P2 p2, P3 p3) // take parameters
>>> : m1(f1(p1,p2,p3)) // initialize data members
>>> , m2(f2(p1,p2,p3))
>>> , m3(f3(p1,p2,p3))
>>> { g1(p1,p2,p3,m1,m2,m3); } // execute compound statement
>>> };
>>>
>>> It comes up often that a constructor designer wishes to execute some
>>> code and/or create some intermediate objects that consume the parameters of
>>> the constructor, and are consumed by the initialization of the data members.
>>>
>>> We therefore propose extending the constructor definition to provide a
>>> way to do that.
>>>
>>> *Design*
>>>
>>> We demonstrate our proposed syntax:
>>>
>>> struct S {
>>> // data members
>>> M1 m1; M2 m2; M3 m3;
>>>
>>> // constructor
>>> S(P1 p1, P2 p2, P3 p3) // take parameters
>>>
>>
>> You need syntax up here saying you are in this mode
>> otherwise...
>>
>> {
>>> g1(p1,p2,p3); // execute statements
>>> L1 l1 = h1(p1,p2,p3); // declare local variables
>>> L2 l2 = h2(p1,p2,p3);
>>> L3 l3 = h3(p1,p2,p3);
>>>
>>>
>> how does the compiler know this (pun intended) is an error:
>>
>> this; // ERROR: `this` not in scope yet
>>> m1; // ERROR: `this` not in scope yet
>>>
>>
>> does it need to *look ahead* through the whole function to find this:
>> (pun intended)
>>
>
> There is also the issue of how the *user* knows that this has taken
> place. Having a statement fundamentally change the very nature of the
> *preceding* code in the same block is very unusual for C++.
>
The only difference is whether `this` is in scope yet. It makes otherwise
not ill-formed code ill-formed. That's not much of a change.
> I really don't like the idea that a statement at the bottom of a function
> can radically change the meaning of code at the very top. Sure, any breaks
> will be noisy, but C++ is usually read top-to-bottom.
>
Meaning of not ill-formed code isn't changed.
> If there is going to be some syntax for this, then it really ought to make
> a clear, block-level distinction between the code before the member
> initializers and the code afterwards.
>
> Also, we already have an adequate solution for this: delegating
> constructors. The delegated constructor can take the declared temporaries
> as arguments, which it will use as appropriate.
>
> struct S {
> // data members
> M1 m1; M2 m2; M3 m3;
>
> // constructor
> S(P1 p1, P2 p2, P3 p3):
> S(p1, p2, p3, h1(p1, p2, p3),
> h2(p1, p2, p3),
> h3(p1, p2, p3))
> {
> }
>
> private:
> S(P1 p1, P2 p2, P3 p3, L1 l1, L2 l2, L3 l3)
> : m1(f1(p1,p2,p3,l1,l2,l3))
> , m2(f2(p1,p2,p3,l1,l2,l3))
> , m3(f3(p1,p2,p3,l1,l2,l3))
> {
> g1(p1,p2,p3);
>
> g2(p1,p2,p3,l1,l2,l3,m1,m2,m3); // execute statements
> }
> };
>
> Note that here, `g1` is called after the object's members are initialized.
> That *ought* to be fine;
>
No it isn't fine. That's one of the motivations. To have side effects
that occur before initialization of the object. Yes there are common and
valid uses of that. No, it doesn't have to be side effects on global state.
> `g1` is a global function whose return value is discarded. The only way it
> wouldn't be fine is if `g1` and the initializer of some of the other
> members/locals are using external global state. In which case, I would
> say... don't do that.
>
> Yes, delegating constructors are a bit cumbersome of a solution. But they
> provide a clear, syntactic separation between the code that executes before
> the initialization and the code that executes after. Also, given how rarely
> this problem comes up, I think the cumbersome nature of this solution is
> comparable to the commonality of the problem. That is, it doesn't come up
> that often, so having to use a less-than-ideal syntax for it when it does
> is OK.
>
>
I agree with Tony: the proposed cure is worse than the disease.
>
I think the problem I'm trying to solve does come up often, and I think
people use factory functions at the moment to deal with it. Here is an
example I posted elsewhere related to this. Notice the symmetry between my
original proposal example and the following:
struct S {
// data members
M1 m1; M2 m2; M3 m3;
// factory function
static S make_s(P1 p1, P2 p2, P3 p3) // take parameters
{
g1(p1,p2,p3); // execute statements
L1 l1 = h1(p1,p2,p3); // declare local variables
L2 l2 = h2(p1,p2,p3);
L3 l3 = h3(p1,p2,p3);
s; // ERROR: `s` not in scope yet
s.m1; // ERROR: `s` not in scope yet
S s(f1(p1,p2,p3,l1,l2,l3) // initialize data members
,f2(p1,p2,p3,l1,l2,l3) // and introduce `this` into
,f3(p1,p2,p3,l1,l2,l3)); // scope and initializes object
s; // OK: `s` in scope
s.m1; // OK: `s` in scope
g2(p1,p2,p3,l1,l2,l3,s.m1,s.m2,s.m3); // execute statements
return s;
}
private:
S(M1 m1, M2 m2, M3 m3) : m1(std::move(m1)), m2(std::move(m2)),
m3(std::move(m3)) {}
};
> If you want to move forward with this, your motivation and design section
> needs to explicitly outline:
>
> 1: Why it is that delegating constructors are not an acceptable solution.
>
> 2: Real-world examples where this syntax would significantly improve code.
> The example you provide here is very artificial.
>
Agreed, thanks.
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4c22e321-4b77-49e8-9de7-69f3f58b7365%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4c22e321-4b77-49e8-9de7-69f3f58b7365%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KH%2BEQiLnQ8gWh4D1VCkWhdHmhvRLQY22_puyzeMJZnF4wg%40mail.gmail.com.
--000000000000fdd8c00581a08627
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Tue, Feb 12, 2019 at 1:47 AM Nicol=
Bolas <<a href=3D"mailto:jmckesson@gmail.com">jmckesson@gmail.com</a>&g=
t; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div d=
ir=3D"ltr"><br><br>On Monday, February 11, 2019 at 9:52:30 AM UTC-5, Tony V=
E wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"=
><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr"=
>On Mon, Feb 11, 2019 at 8:27 AM Andrew Tomazos <<a rel=3D"nofollow">and=
rew...@gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex"><div dir=3D"ltr"><div>Here is a first scribble of a proposa=
l I am working on called pre-constructor scope.=C2=A0 Feedback appreciated.=
....<br></div><div><b><br></b></div><div><b>Summary</b></div><div><br></div>=
<div>We propose allowing constructors to execute statements and declare loc=
al variables after the constructors parameters are in scope but before the =
object (this) is in scope and before its data members are in scope and init=
ialized.</div><div><br></div><b>Motivation</b><div><br></div><div>Classes h=
ave data members (and base subobjects, which we will call data members for =
this discussion).=C2=A0 Constructors take parameters, initialize data membe=
rs and then execute a compound statement:</div><div><font face=3D"monospace=
, monospace"><br></font></div><div><font face=3D"monospace, monospace">stru=
ct S {</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0//=
data members</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0M1 m1; M2 m2; M3 m3;</font></div><div><font face=3D"monospace, monosp=
ace"><br></font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0// constructor</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0S(P1 p1, P2 p2, P3 p3)=C2=A0 // take parameters</font></div><div>=
<font face=3D"monospace, monospace">=C2=A0 =C2=A0: m1(f1(p1,p2,p3)) // init=
ialize data members</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0, m2(f2(p1,p2,p3))</font></div><div><font face=3D"monospace, m=
onospace">=C2=A0 =C2=A0, m3(f3(p1,p2,p3))</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 =C2=A0{ g1(p1,p2,p3,m1,m2,m3); }=C2=A0 // execut=
e compound statement</font></div><div><font face=3D"monospace, monospace">}=
;</font></div><div><br></div><div>It comes up often that a constructor desi=
gner wishes to execute some code and/or create some intermediate objects th=
at consume the parameters of the constructor, and are consumed by the initi=
alization of the data members.</div><div><br></div><div>We therefore propos=
e extending the constructor definition to provide a way to do that.</div><d=
iv><br></div><div><b>Design</b></div><div><br></div><div>We demonstrate our=
proposed syntax:</div><div><br></div><div><div><font face=3D"monospace, mo=
nospace">struct S {</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0// data members</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 =C2=A0M1 m1; M2 m2; M3 m3;</font></div><div><font face=3D"mon=
ospace, monospace"><br></font></div><div><font face=3D"monospace, monospace=
">=C2=A0 =C2=A0// constructor</font></div><div><font face=3D"monospace, mon=
ospace">=C2=A0 =C2=A0S(P1 p1, P2 p2, P3 p3)=C2=A0 // take parameters</font>=
</div></div></div></blockquote><div><br></div><div>You need syntax up here =
saying you are in this mode</div><div>otherwise...</div><div><br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><div><f=
ont face=3D"monospace, monospace">=C2=A0 =C2=A0{</font></div><div><font fac=
e=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0g1(p1,p2,p3); // execute sta=
tements</font></div><div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 =C2=A0L1 l1 =3D h1(p1,p2,p3); // declare local variables</font></div=
><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L2 l2 =3D h2(=
p1,p2,p3);</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=
=A0 =C2=A0L3 l3 =3D h3(p1,p2,p3);</font></div><font face=3D"monospace, mono=
space"><br></font></div></div></div></blockquote><div><br></div><div>how do=
es the compiler know this (pun intended) is an error:</div><div> <br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div><di=
v><font face=3D"monospace, monospace"></font></div><div><font face=3D"monos=
pace, monospace">=C2=A0 =C2=A0 =C2=A0this; // ERROR: `this` not in scope ye=
t</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0=
m1; // ERROR: `this` not in scope yet</font></div><div><font face=3D"monosp=
ace, monospace"></font></div></div></div></blockquote><div><br></div><div>d=
oes it need to *look ahead* through the whole function to find this: (pun i=
ntended)<br></div></div></div></blockquote><div><br></div><div>There is als=
o the issue of how the <i>user</i> knows that this has taken place. Having =
a statement fundamentally change the very nature of the <i>preceding</i> co=
de in the same block is very unusual for C++.</div></div></blockquote><div>=
<br></div><div>The only difference is whether `this` is in scope yet.=C2=A0=
It makes otherwise not ill-formed code ill-formed.=C2=A0 That's not mu=
ch of a change.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex"><div dir=3D"ltr"><div> I really don't like the idea that a=
statement at the bottom of a function can radically change the meaning of =
code at the very top. Sure, any breaks will be noisy, but C++ is usually re=
ad top-to-bottom.</div></div></blockquote><div><br></div><div>Meaning of no=
t ill-formed code isn't changed.</div><div>=C2=A0</div><blockquote clas=
s=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid r=
gb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>If there is going t=
o be some syntax for this, then it really ought to make a clear, block-leve=
l distinction between the code before the member initializers and the code =
afterwards.<br></div><div><br></div><div>Also, we already have an adequate =
solution for this: delegating constructors. The delegated constructor can t=
ake the declared temporaries as arguments, which it will use as appropriate=
..</div><div><br></div><div><div style=3D"background-color:rgb(250,250,250);=
border-color:rgb(187,187,187);border-style:solid;border-width:1px" class=3D=
"gmail-m_7589505452121899028prettyprint"><code class=3D"gmail-m_75895054521=
21899028prettyprint"><div class=3D"gmail-m_7589505452121899028subprettyprin=
t"><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_7589505452121899028s=
tyled-by-prettify">struct</span><span style=3D"color:rgb(0,0,0)" class=3D"g=
mail-m_7589505452121899028styled-by-prettify"> S </span><span style=3D"colo=
r:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">{=
</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758950545212189902=
8styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(136,=
0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">// data membe=
rs</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899=
028styled-by-prettify"><br>=C2=A0 =C2=A0 M1 m1</span><span style=3D"color:r=
gb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">;</s=
pan><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028st=
yled-by-prettify"> M2 m2</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_7589505452121899028styled-by-prettify">;</span><span style=3D"c=
olor:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"> M=
3 m3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452=
121899028styled-by-prettify">;</span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_7589505452121899028styled-by-prettify"><br><br>=C2=A0 =C2=A0 </=
span><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_758950545212189902=
8styled-by-prettify">// constructor</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 S=
</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_75895054521218=
99028styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"=
gmail-m_7589505452121899028styled-by-prettify">P1 p1</span><span style=3D"c=
olor:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify=
">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758950545212189=
9028styled-by-prettify"> P2 p2</span><span style=3D"color:rgb(102,102,0)" c=
lass=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><span style=
=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettif=
y"> P3 p3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_75895=
05452121899028styled-by-prettify">):</span><span style=3D"color:rgb(0,0,0)"=
class=3D"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 S</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m=
_7589505452121899028styled-by-prettify">(</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">p1</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled=
-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758=
9505452121899028styled-by-prettify"> p2</span><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by=
-prettify"> p3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_=
7589505452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"> h1</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled=
-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758=
9505452121899028styled-by-prettify">p1</span><span style=3D"color:rgb(102,1=
02,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-=
prettify"> p2</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7=
589505452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0,=
0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"> p3</span><span=
style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-=
by-prettify">),</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758=
9505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 h2</spa=
n><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028=
styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail=
-m_7589505452121899028styled-by-prettify">p1</span><span style=3D"color:rgb=
(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</spa=
n><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styl=
ed-by-prettify"> p2</span><span style=3D"color:rgb(102,102,0)" class=3D"gma=
il-m_7589505452121899028styled-by-prettify">,</span><span style=3D"color:rg=
b(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"> p3</span=
><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028s=
tyled-by-prettify">),</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail=
-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 h=
3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121=
899028styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_7589505452121899028styled-by-prettify">p1</span><span style=3D"col=
or:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">=
,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75895054521218990=
28styled-by-prettify"> p2</span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><span style=3D"c=
olor:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"> p=
3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121=
899028styled-by-prettify">))</span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 </span=
><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028s=
tyled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span sty=
le=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-p=
rettify">}</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75895054=
52121899028styled-by-prettify"><br>=C2=A0 =C2=A0<br></span><span style=3D"c=
olor:rgb(0,0,136)" class=3D"gmail-m_7589505452121899028styled-by-prettify">=
private</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505=
452121899028styled-by-prettify">:</span><span style=3D"color:rgb(0,0,0)" cl=
ass=3D"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 S</=
span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899=
028styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gm=
ail-m_7589505452121899028styled-by-prettify">P1 p1</span><span style=3D"col=
or:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">=
,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75895054521218990=
28styled-by-prettify"> P2 p2</span><span style=3D"color:rgb(102,102,0)" cla=
ss=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">=
P3 p3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_75895054=
52121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-m_7589505452121899028styled-by-prettify"> L1 l1</span><span sty=
le=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-p=
rettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75895054=
52121899028styled-by-prettify"> L2 l2</span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><span=
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-p=
rettify"> L3 l3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m=
_7589505452121899028styled-by-prettify">)</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,102,0)" class=3D"g=
mail-m_7589505452121899028styled-by-prettify">:</span><span style=3D"color:=
rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"> m1</sp=
an><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_758950545212189902=
8styled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmai=
l-m_7589505452121899028styled-by-prettify">f1</span><span style=3D"color:rg=
b(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">(</sp=
an><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028sty=
led-by-prettify">p1</span><span style=3D"color:rgb(102,102,0)" class=3D"gma=
il-m_7589505452121899028styled-by-prettify">,</span><span style=3D"color:rg=
b(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">p2</span>=
<span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028st=
yled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_7589505452121899028styled-by-prettify">p3</span><span style=3D"color:rgb(1=
02,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled=
-by-prettify">l1</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
m_7589505452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0=
,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">l2</span><sp=
an style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028style=
d-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75=
89505452121899028styled-by-prettify">l3</span><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">))</span><s=
pan style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-b=
y-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb=
(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</spa=
n><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styl=
ed-by-prettify"> m2</span><span style=3D"color:rgb(102,102,0)" class=3D"gma=
il-m_7589505452121899028styled-by-prettify">(</span><span style=3D"color:rg=
b(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">f2</span>=
<span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028st=
yled-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_7589505452121899028styled-by-prettify">p1</span><span style=3D"color:rgb(1=
02,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled=
-by-prettify">p2</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
m_7589505452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0=
,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">p3</span><sp=
an style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028style=
d-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75=
89505452121899028styled-by-prettify">l1</span><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by=
-prettify">l2</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7=
589505452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0,=
0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">l3</span><span =
style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-b=
y-prettify">))</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589=
505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><=
span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028sty=
led-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_=
7589505452121899028styled-by-prettify"> m3</span><span style=3D"color:rgb(1=
02,102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">(</span>=
<span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled=
-by-prettify">f3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-=
m_7589505452121899028styled-by-prettify">(</span><span style=3D"color:rgb(0=
,0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">p1</span><sp=
an style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028style=
d-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75=
89505452121899028styled-by-prettify">p2</span><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by=
-prettify">p3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7=
589505452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0,=
0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">l1</span><span =
style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-b=
y-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_75895=
05452121899028styled-by-prettify">l2</span><span style=3D"color:rgb(102,102=
,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><span =
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-pr=
ettify">l3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589=
505452121899028styled-by-prettify">))</span><span style=3D"color:rgb(0,0,0)=
" class=3D"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0=
</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121=
899028styled-by-prettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D=
"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0g1</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m=
_7589505452121899028styled-by-prettify">(</span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">p1</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled=
-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758=
9505452121899028styled-by-prettify">p2</span><span style=3D"color:rgb(102,1=
02,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-=
prettify">p3</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_75=
89505452121899028styled-by-prettify">);</span><span style=3D"color:rgb(0,0,=
0)" class=3D"gmail-m_7589505452121899028styled-by-prettify"><br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0g2</span><spa=
n style=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled=
-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758=
9505452121899028styled-by-prettify">p1</span><span style=3D"color:rgb(102,1=
02,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-=
prettify">p2</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_75=
89505452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0=
)" class=3D"gmail-m_7589505452121899028styled-by-prettify">p3</span><span s=
tyle=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by=
-prettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758950=
5452121899028styled-by-prettify">l1</span><span style=3D"color:rgb(102,102,=
0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><span s=
tyle=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-pre=
ttify">l2</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_75895=
05452121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_7589505452121899028styled-by-prettify">l3</span><span styl=
e=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-pr=
ettify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758950545=
2121899028styled-by-prettify">m1</span><span style=3D"color:rgb(102,102,0)"=
class=3D"gmail-m_7589505452121899028styled-by-prettify">,</span><span styl=
e=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by-pretti=
fy">m2</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_75895054=
52121899028styled-by-prettify">,</span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-m_7589505452121899028styled-by-prettify">m3</span><span style=
=3D"color:rgb(102,102,0)" class=3D"gmail-m_7589505452121899028styled-by-pre=
ttify">);</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758950545=
2121899028styled-by-prettify"> </span><span style=3D"color:rgb(136,0,0)" cl=
ass=3D"gmail-m_7589505452121899028styled-by-prettify">// execute statements=
</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_758950545212189902=
8styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-m_7589505452121899028styled-by-prettify">}</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_7589505452121899028styled-by=
-prettify"><br></span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m=
_7589505452121899028styled-by-prettify">};</span></div></code></div><br>Not=
e that here, `g1` is called after the object's members are initialized.=
That <i>ought</i> to be fine;</div></div></blockquote><div><br></div><div>=
No it isn't fine.=C2=A0 That's one of the motivations.=C2=A0 To hav=
e side effects that occur before initialization of the object.=C2=A0 Yes th=
ere are common and valid uses of that.=C2=A0 No, it doesn't have to be =
side effects on global state.</div><div>=C2=A0</div><blockquote class=3D"gm=
ail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,=
204,204);padding-left:1ex"><div dir=3D"ltr"><div>`g1` is a global function =
whose return value is discarded. The only way it wouldn't be fine is if=
`g1` and the initializer of some of the other members/locals are using ext=
ernal global state. In which case, I would say... don't do that.<br></d=
iv><div><br></div><div>Yes, delegating constructors are a bit cumbersome of=
a solution. But they provide a clear, syntactic separation between the cod=
e that executes before the initialization and the code that executes after.=
Also, given how rarely this problem comes up, I think the cumbersome natur=
e of this solution is comparable to the commonality of the problem. That is=
, it doesn't come up that often, so having to use a less-than-ideal syn=
tax for it when it does is OK.<br></div><div>=C2=A0<br></div></div></blockq=
uote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bo=
rder-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><di=
v></div><div>I agree with Tony: the proposed cure is worse than the disease=
..</div></div></blockquote><div><br></div><div>I think the problem I'm t=
rying to solve does come up often, and I think people use factory functions=
at the moment to deal with it.=C2=A0 Here is an example I posted elsewhere=
related to this.=C2=A0 Notice the symmetry between my original proposal ex=
ample and the following:</div><div><br></div><div><span class=3D"gmail-im" =
style=3D"color:rgb(80,0,80)"><div><font face=3D"monospace, monospace">struc=
t S {</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0// =
data members</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0M1 m1; M2 m2; M3 m3;</font></div><div><font face=3D"monospace, monosp=
ace"><br></font></div></span><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0// factory function</font></div><div><font face=3D"monospace, mon=
ospace">=C2=A0 =C2=A0static S make_s(P1 p1, P2 p2, P3 p3)=C2=A0 // take par=
ameters</font></div><span class=3D"gmail-im" style=3D"color:rgb(80,0,80)"><=
div><font face=3D"monospace, monospace">=C2=A0 =C2=A0{</font></div><div><fo=
nt face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0g1(p1,p2,p3); // execu=
te statements</font></div><div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 =C2=A0L1 l1 =3D h1(p1,p2,p3); // declare local variables</font><=
/div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0L2 l2 =3D=
h2(p1,p2,p3);</font></div><div><font face=3D"monospace, monospace">=C2=A0 =
=C2=A0 =C2=A0L3 l3 =3D h3(p1,p2,p3);</font></div><font face=3D"monospace, m=
onospace"><br class=3D"gmail-m_-2318174067120687420gmail-m_-350381114354549=
4539gmail-Apple-interchange-newline"></font></div></span><div><font face=3D=
"monospace, monospace">=C2=A0 =C2=A0 =C2=A0s; // ERROR: `s` not in scope ye=
t</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0=
s.m1; // ERROR: `s` not in scope yet</font></div><div><font face=3D"monospa=
ce, monospace">=C2=A0 =C2=A0 =C2=A0</font></div><div><font face=3D"monospac=
e, monospace">=C2=A0 =C2=A0 =C2=A0S s(f1(p1,p2,p3,l1,l2,l3)=C2=A0 // initia=
lize data members</font></div><div><font face=3D"monospace, monospace">=C2=
=A0 =C2=A0 =C2=A0 ,f2(p1,p2,p3,l1,l2,l3)=C2=A0 // and introduce `this` into=
</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0 =
,f3(p1,p2,p3,l1,l2,l3)); // scope and initializes object</font></div><div><=
font face=3D"monospace, monospace"><br></font></div><div><font face=3D"mono=
space, monospace">=C2=A0 =C2=A0 =C2=A0s; // OK: `s` in scope</font></div><d=
iv><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0s.m1; // OK: `s`=
in scope</font></div><div><font face=3D"monospace, monospace"><br></font><=
/div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 =C2=A0g2(p1,p2,=
p3,l1,l2,l3,s.m1,s.m2,s.m3); // execute statements</font></div><div><font f=
ace=3D"monospace, monospace"><br></font></div><div><font face=3D"monospace,=
monospace">=C2=A0 =C2=A0 =C2=A0return s;</font></div><div><font face=3D"mo=
nospace, monospace">=C2=A0 =C2=A0}</font></div><div><font face=3D"monospace=
, monospace">private:</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0S(M1 m1, M2 m2, M3 m3) : m1(std::move(m1)), m2(std::move(m2)),=
m3(std::move(m3)) {}</font></div><div><font face=3D"monospace, monospace">=
=C2=A0 =C2=A0</font></div><div><font face=3D"monospace, monospace">};</font=
></div></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex"><div dir=3D"ltr"><div></div><div>If you want to move forward with this=
, your motivation and design section needs to explicitly outline:</div><div=
><br></div><div>1: Why it is that delegating constructors are not an accept=
able solution.</div><div><br></div><div>2: Real-world examples where this s=
yntax would significantly improve code. The example you provide here is ver=
y artificial.<br></div></div></blockquote><div><br></div><div>Agreed, thank=
s.=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px=
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D=
"ltr"><div></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" 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>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4c22e321-4b77-49e8-9de7-69f3f58b7365%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4c22e321-4b77-=
49e8-9de7-69f3f58b7365%40isocpp.org</a>.<br>
</blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KH%2BEQiLnQ8gWh4D1VCkWhdHmhvRL=
QY22_puyzeMJZnF4wg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAB%2B4KH%2BE=
QiLnQ8gWh4D1VCkWhdHmhvRLQY22_puyzeMJZnF4wg%40mail.gmail.com</a>.<br />
--000000000000fdd8c00581a08627--
.