220 31939 <62e66de4-7c7a-4e1c-8343-b173b49cb594@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: hun.nemethpeter@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Improved variable declaration syntax
Date: Mon, 3 Apr 2017 07:45:12 -0700 (PDT)
Lines: 164
Approved: news@gmane.org
Message-ID: <62e66de4-7c7a-4e1c-8343-b173b49cb594@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1231_1084392551.1491230712839"
X-Trace: blaine.gmane.org 1491230730 1858 195.159.176.226 (3 Apr 2017 14:45:30 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 3 Apr 2017 14:45:30 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBD3YT6VHQYIBB6N7RHDQKGQECFQOYBI@isocpp.org Mon Apr 03 16:45:26 2017
Return-path: <std-proposals+bncBD3YT6VHQYIBB6N7RHDQKGQECFQOYBI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f199.google.com ([209.85.213.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBD3YT6VHQYIBB6N7RHDQKGQECFQOYBI@isocpp.org>)
	id 1cv3EC-000703-A3
	for gclcip-std-proposals@m.gmane.org; Mon, 03 Apr 2017 16:45:08 +0200
Original-Received: by mail-yb0-f199.google.com with SMTP id c126sf12294581ybf.6
        for <gclcip-std-proposals@m.gmane.org>; Mon, 03 Apr 2017 07:45:14 -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: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=nfR5CLTXsbkkUh5pSxPX0pvgTeI8t+vyaLQsovX5ZNs=;
        b=GiYtlq1xSpE4wrsIJeopK08TgcVSRudiO79z8j0CjeF3CoA2hafqYD5Zy3FgZOIt2E
         BcpMMcy1FcLIZAubLUmLhjnD633CnRGoZzN2isSwB33Xmach+qN9nqc0NKsF6ar4WJEO
         mQSs1KleaQOU0WyqzRkqEoD/ucpxsT0+uUtnD/yKZzcSVvv35Y1CPy79/1LJ1XIMl9sF
         8vD20ouRmI9jW00rQEn7OKuMPBaGIY7DWyIC4O6dZmhNovJOQA6mR1AbsDHpaC33fvI6
         xlQwWtJcPEspeX13EiUS/5iDO7Ybk89PRm2dCjTDpZL4T+Bo59YpdvNqeg0xBDfd3IVN
         JZNQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id: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=nfR5CLTXsbkkUh5pSxPX0pvgTeI8t+vyaLQsovX5ZNs=;
        b=WTZsk884JoEyNW7Y1T8vhFGXxGDRflEvRehdvPlh72iPozVNMlN6AMVlzC37zTfXL3
         udDXBCw2j68USaup+VvG3dj3Rbpmph6Dx5lmOI3CeYv7MGQy1VNeSYUIQzEYFmUbjimI
         eYO1PSxxqCMxWxbF4WoBu25ZMSdKhhQp+0Miws6ut0UmXqTIoSs8dBZVfLBkOBRitj1Y
         x7Y0GEBMg6hqNVPPEvDDCTHyWpvexagWmSC1qCtM+MMptDvEt/8h25AYZgC7Kpma+iYC
         DK7y5JP2XK2DQK6xjaa2w1lpv1VKlo70fdotTKRDiYJBv4O/tOlCmzvwDZbxte/lJX5X
         3cFw==
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: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=nfR5CLTXsbkkUh5pSxPX0pvgTeI8t+vyaLQsovX5ZNs=;
        b=MZg99oO/dvCOY8L/nvrZjUvoCEDOtj6zVqjxR82dYCD8SRs/iygaZYdJOVfm6T58ap
         B/hQY5pxHOyvvnGPbkqcf1hJKrYdTnLS+0GAINSESYySKoQb804qWDzMJmHIgdMKk3zU
         cmE3fY2Tj3BTVJfT5HnmlrqRrNUZlRpPY8cl9nyzcI6BAfBzik1XWkECjXddXABqMH2j
         n7YtzzXxMGKaP9UukkooUWJh8wZBSZilW30qiZh5l+X88dtNMb24kEkpEkVc8B7+x5cS
         iqDfoTz/qotEiZyqyq/BxhT6m3BqO/gE7Tbo53eoRhyML88jymfQpn5RflXjzfQbvyvS
         Wo+w==
X-Gm-Message-State: AFeK/H3zpGQy8aqe/Yd0pS1hDRy2rxZGmm+JibNwZjHWf9BBtQ7rspgTKTm+sNP5nt1Xwg==
X-Received: by 10.13.212.195 with SMTP id w186mr7846461ywd.105.1491230714110;
        Mon, 03 Apr 2017 07:45:14 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.27.155 with SMTP id z27ls1330919otd.14.gmail; Mon, 03 Apr
 2017 07:45:13 -0700 (PDT)
X-Received: by 10.157.25.203 with SMTP id k69mr713806otk.17.1491230713280;
        Mon, 03 Apr 2017 07:45:13 -0700 (PDT)
X-Original-Sender: hun.nemethpeter@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <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:31939
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31939>

------=_Part_1231_1084392551.1491230712839
Content-Type: multipart/alternative; 
	boundary="----=_Part_1232_1182156914.1491230712839"

------=_Part_1232_1182156914.1491230712839
Content-Type: text/plain; charset=UTF-8

Hi,


I took part in so many syntax debates over the years on preferred variable 
declaration syntax.

One of the neuralgic point of variable declaration syntax is the pointer 
and reference alignment style.

The root problem is the following:

int* a, b;

This declares a pointer and an int which is confusing. So a common coding 
style to avoid this error is aligning pointer to variables:

int *a, b;

Which is also confusing sometimes as some type parts are separated from the 
"main" type.

What I suggest is a new variable declaration syntax:

// <type>:= <identifier1>, <identifier2>, ...;
// so I can write

int*:= a, b;

// or

int*:= a = nullptr, b = &a;

// the following won't compile:
int*:= *a, b;

To avoid the type syntax confusion I also propose to deprecate old style 
variable declaration syntax as we can write tools to mechanically transform 
the code bases to this new syntax.


I get this syntax from a previous thread: 

A more consistent variable declaration syntax by Andy Prowl 
https://groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/variable$20declaration/std-proposals/ITDME5hYiPw/l4HFz3jjik4J



Peter

-- 
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/62e66de4-7c7a-4e1c-8343-b173b49cb594%40isocpp.org.

------=_Part_1232_1182156914.1491230712839
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div><br></div><div>I took part in so ma=
ny syntax debates over the years on preferred variable declaration syntax.<=
/div><div><br></div><div>One of the neuralgic point of variable declaration=
 syntax is the pointer and reference alignment style.</div><div><br></div><=
div>The root problem is the following:<br></div><div><br></div><div><div cl=
ass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-c=
olor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap=
: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span></div></code></div><br></div><div>This declares a p=
ointer and an int which is confusing. So a common coding style to avoid thi=
s error is aligning pointer to variables:</div><div><br></div><div><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
 break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span></div></code></div><br></div><div>Which is also confusing somet=
imes as some type parts are separated from the &quot;main&quot; type.</div>=
<div><br></div><div>What I suggest is a new variable declaration syntax:</d=
iv><div><br></div><div><div class=3D"prettyprint" style=3D"background-color=
: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid=
; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><d=
iv class=3D"subprettyprint"><span style=3D"color: #800;" class=3D"styled-by=
-prettify">// &lt;type&gt;:=3D &lt;identifier1&gt;, &lt;identifier2&gt;, ..=
..;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// so I can wr=
ite</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">*:=3D</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br><br></span><span style=3D"color: #800;" class=3D"s=
tyled-by-prettify">// or</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">*:=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 a </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">nullptr</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> b </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r></span><span style=3D"color: #800;" class=3D"styled-by-prettify">// the f=
ollowing won&#39;t compile:</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">int</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">*:=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">a</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">;</span></div></code></div><br></div><div>To =
avoid the type syntax confusion I also propose to deprecate old style varia=
ble declaration syntax as we can write tools to mechanically transform the =
code bases to this new syntax.</div><div><br></div><div><br></div><div>I ge=
t this syntax from a previous thread:=C2=A0<br></div><div><br></div>A more =
consistent variable declaration syntax by Andy Prowl <div><a href=3D"https:=
//groups.google.com/a/isocpp.org/forum/#!searchin/std-proposals/variable$20=
declaration/std-proposals/ITDME5hYiPw/l4HFz3jjik4J">https://groups.google.c=
om/a/isocpp.org/forum/#!searchin/std-proposals/variable$20declaration/std-p=
roposals/ITDME5hYiPw/l4HFz3jjik4J</a><br></div><div><br></div><div><br></di=
v><div><br></div><div>Peter</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/62e66de4-7c7a-4e1c-8343-b173b49cb594%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/62e66de4-7c7a-4e1c-8343-b173b49cb594=
%40isocpp.org</a>.<br />

------=_Part_1232_1182156914.1491230712839--

------=_Part_1231_1084392551.1491230712839--

.
