220 40221 <d37ec4f7-57d1-4802-8549-e49fb5f620fc@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: random.romik@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Primary constructors for C++ ?
Date: Tue, 25 Sep 2018 10:52:02 -0700 (PDT)
Lines: 130
Approved: news@gmane.org
Message-ID: <d37ec4f7-57d1-4802-8549-e49fb5f620fc@isocpp.org>
References: <05c2d528-9837-4968-b19e-42875434962c@isocpp.org>
 <CAC+0CCPyW-_TdLfrO62q9B2dPFRATXpg8omkphfgDOUFUj9yAg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2485_1149589954.1537897922499"
X-Trace: blaine.gmane.org 1537897799 25898 195.159.176.226 (25 Sep 2018 17:49:59 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 25 Sep 2018 17:49:59 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCCZP3OF64HBBQ7LVHOQKGQE3NZ4JPY@isocpp.org Tue Sep 25 19:49:55 2018
Return-path: <std-proposals+bncBCCZP3OF64HBBQ7LVHOQKGQE3NZ4JPY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb1-f197.google.com ([209.85.219.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCCZP3OF64HBBQ7LVHOQKGQE3NZ4JPY@isocpp.org>)
	id 1g4rT8-0006dL-VL
	for gclcip-std-proposals@m.gmane.org; Tue, 25 Sep 2018 19:49:55 +0200
Original-Received: by mail-yb1-f197.google.com with SMTP id 203-v6sf10674976ybf.19
        for <gclcip-std-proposals@m.gmane.org>; Tue, 25 Sep 2018 10:52:05 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=qYyP8yjgj0IGdmiqR/3+8FQ0d6yYNSyD4E+HE+3JNpU=;
        b=Nl19O+mTt5IcvUnHJC9f6Tt0M+H4QwbkWkRNuReVjIjuHQtP2lfQz1ZwWOH8XgrdFL
         EVXKL7JIjghqDR02QS7ZSf5xG88Z7K4/C3auOMYLFlk+AsBM33GvzKLN4R568Yq2it3b
         5WykoLOcMKEfADzpc8C61kIBI8dhqh5vVrsH0vqYXW/szfEKxMj7hdIWu4SHGewYcX0D
         aotogZUzfkVRHS/t4S05X6hThTUU3c5oZ6rvVHg/22vDFrW26NfwtWmiENwyiyTX0OYQ
         vL5d4rqDfBJkhnF6lIANJJAh2t0TEaeVGQTLYnmrZ3OZX1tszc+OQQyb5gVBW7lKdcNh
         k3Eg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=qYyP8yjgj0IGdmiqR/3+8FQ0d6yYNSyD4E+HE+3JNpU=;
        b=LcK9nJiWJdipoU0i0mU0RYVtwevDPSss3uj69xVv+GAT3ny72+MWWi1jBx/iMjWEjI
         t3xzd8DgZuM/NvPRsiV6az221SjKG7WVqPAUn74D0rprikq46pcdOACRn197IWQ6gzns
         7hwQDIkZurJKwOGW8LU0SKWDtcO5z9833y5dVPpYSEOUERyWM8xnTIuZnpdKWmk2oc7G
         JomhsDDakzHx7st1NX0gHll8Gajz/zhEejFK6eRa84WMjd2+KOsiCUmJW9v91lUBMM+o
         e6UmB8ak6HdOkGou2OSteaTp7okOlqNs0klu+Hr+CIqFIkULYc1/aNhjtxxfJs7lQop0
         CIzA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=qYyP8yjgj0IGdmiqR/3+8FQ0d6yYNSyD4E+HE+3JNpU=;
        b=E5Z6KTwVRn9k10oZUlGm7eLaQVEv9hT92r4C2ilQV2fUXn54oY8AieiDnM63lykt0n
         mPJp/gz2saUVn5UJN9Q6NYUmrJvArBFTv4+0ms4pWBdJSmqN5XHC/qF1r5WQMbxqE15e
         ddJU7yz2TJZoOoSCZzjAqpsIKNo9rWu4qaoTFyQfrApEra2ZiY9L9f+wAMVUNewh66n3
         kxdR2PaMCB6iO189moPBdiyuxN759rtY0y3rTdZN9OrSzJcF4juyXPCxbako4GhXcHbP
         2YECbNS/+zCYxJGXiLrpbEH5E5wGb3/MdvlF3z+4FQwWvtm/jeWY/l9TN+HeGYWBioQG
         WRig==
X-Gm-Message-State: ABuFfogJDoKqY+vR74UDnKprEY6JmpuvPNn+I2T3uvokTQtp2CIfiHDZ
	SVeaRtvPEn7v7/2GzjDF2mtWnQ==
X-Google-Smtp-Source: ACcGV63Z8hr3yyxn4jeNkgjNWQePFytwHw1tgX8llPWtxJFfNyGFUWwPq4YFScEFOkQZGcFb39hGvg==
X-Received: by 2002:a25:3b8c:: with SMTP id i134-v6mr116388yba.33.1537897925011;
        Tue, 25 Sep 2018 10:52:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:b9c6:: with SMTP id y6-v6ls2666876ybj.4.gmail; Tue, 25
 Sep 2018 10:52:03 -0700 (PDT)
X-Received: by 2002:a25:2483:: with SMTP id k125-v6mr27355ybk.5.1537897923437;
        Tue, 25 Sep 2018 10:52:03 -0700 (PDT)
In-Reply-To: <CAC+0CCPyW-_TdLfrO62q9B2dPFRATXpg8omkphfgDOUFUj9yAg@mail.gmail.com>
X-Original-Sender: random.romik@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:40221
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40221>

------=_Part_2485_1149589954.1537897922499
Content-Type: multipart/alternative; 
	boundary="----=_Part_2486_409632890.1537897922499"

------=_Part_2486_409632890.1537897922499
Content-Type: text/plain; charset="UTF-8"



On Tuesday, September 25, 2018 at 10:37:22 AM UTC-7, Jake Arkinstall wrote:
>
> On Tue, 25 Sep 2018, 18:21 ,<rip...@gmail.com <javascript:>> wrote:
>
>> Currently we have to use old constructor member initializer list syntax, 
>> if we need to pass parameters in run-time. This is less readable: member 
>> initialization is separated from declaration.
>>
>
> This is a subjective claim. I find the initializer list approach more 
> readable, from a structural point of view.
>
> The reason that we can use template arguments in member constructors is 
> that the template argument is in scope and because template arguments are 
> constexpr. That we can do this is completely logical, and that we can't do 
> this with variables is also completely logical.
>
> The way I think about proposals is generally "how many confused posts is 
> this going to generate on programming forums?". I think that, although your 
> solution does go some way to solve a stylistic issue, it introduces some 
> conceptual issues surrounding scope.
>
>
 Thanks for feedback, good point. I agree that syntax perception is 
subjective.
 

> For example, is "n" accessible elsewhere in the class - e.g. can it be 
> referred to within a function? If not, why not? It's in scope after all, 
> and not allowing it would be counter-intuitive to many people. If so, 
> though, what is its behaviour when the value changes elsewhere? If it's a 
> const reference, and the source variable is freed, what happens? How many 
> people are going to add instances of this object to a container in a loop 
> and wonder why they're getting memory access problems?
>

n should only be accessible in initializers, because in-class member 
initializers are parts of object construction. This feels very intuitive to 
me.

On the other side old syntax is sometimes not intuitive and error-prope : 
consider for example -Wreorder related bugs.

 

-- 
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/d37ec4f7-57d1-4802-8549-e49fb5f620fc%40isocpp.org.

------=_Part_2486_409632890.1537897922499
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Tuesday, September 25, 2018 at 10:37:22 AM UTC-=
7, Jake Arkinstall 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"auto"><div class=3D"gmail_quote" dir=3D"auto"><div dir=3D"ltr">On Tu=
e, 25 Sep 2018, 18:21 ,&lt;<a href=3D"javascript:" target=3D"_blank" gdf-ob=
fuscated-mailto=3D"zEusqWc-CwAJ" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascri=
pt:&#39;;return true;">rip...@gmail.com</a>&gt; wrote:<br></div><blockquote=
 class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc soli=
d;padding-left:1ex"><div dir=3D"ltr"><span><span style=3D"background-color:=
transparent;vertical-align:baseline"><span><span style=3D"background-color:=
transparent;vertical-align:baseline"><p dir=3D"ltr" style=3D"color:rgb(0,0,=
0);font-size:small;white-space:pre-wrap;font-family:arial,sans-serif;line-h=
eight:1.38">Currently we have to use old constructor member initializer lis=
t syntax, if we need to pass parameters in run-time. This is less readable:=
 member initialization is separated from declaration.</p></span></span></sp=
an></span></div></blockquote></div><div dir=3D"auto"><br></div><div dir=3D"=
auto">This is a subjective claim. I find the initializer list approach more=
 readable, from a structural point of view.</div><div dir=3D"auto"><br></di=
v><div dir=3D"auto">The reason that we can use template arguments in member=
 constructors is that the template argument is in scope and because templat=
e arguments are constexpr. That we can do this is completely logical, and t=
hat we can&#39;t do this with variables is also completely logical.</div><d=
iv dir=3D"auto"><br></div><div dir=3D"auto"><span style=3D"font-family:sans=
-serif">The way I think about proposals is generally &quot;how many confuse=
d posts is this going to generate on programming forums?&quot;. I think tha=
t, although your solution does go some way to solve a stylistic issue, it i=
ntroduces some conceptual issues surrounding scope.</span><br></div><div di=
r=3D"auto"><br></div></div></blockquote><div><br></div><div>=C2=A0Thanks fo=
r feedback, good point. I agree that syntax perception is subjective.<br></=
div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"auto"><div dir=3D"auto"></div><div dir=3D"auto">For example, is &quot;n=
&quot; accessible elsewhere in the class - e.g. can it be referred to withi=
n a function? If not, why not? It&#39;s in scope after all, and not allowin=
g it would be counter-intuitive to many people. If so, though, what is its =
behaviour when the value changes elsewhere? If it&#39;s a const reference, =
and the source variable is freed, what happens? How many people are going t=
o add instances of this object to a container in a loop and wonder why they=
&#39;re getting memory access problems?</div></div></blockquote><div><br></=
div><div>n should only be accessible in initializers, because in-class memb=
er initializers are parts of object construction. This feels very intuitive=
 to me.</div><div><br></div><div>On the other side old syntax is sometimes =
not intuitive and error-prope : consider for example -Wreorder related bugs=
..</div><div><br></div><div>=C2=A0</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <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/d37ec4f7-57d1-4802-8549-e49fb5f620fc%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/d37ec4f7-57d1-4802-8549-e49fb5f620fc=
%40isocpp.org</a>.<br />

------=_Part_2486_409632890.1537897922499--

------=_Part_2485_1149589954.1537897922499--

.
