220 31893 <7a03017c-ad72-466f-b2a3-c07f9186f387@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: raffaele.rossi@mavensecurities.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: This variable should not be named: an identifier
 (not) to remember
Date: Thu, 30 Mar 2017 01:08:48 -0700 (PDT)
Lines: 189
Approved: news@gmane.org
Message-ID: <7a03017c-ad72-466f-b2a3-c07f9186f387@isocpp.org>
References: <985b9b2a-c734-45eb-95f4-db4dc0d309a1@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_2303_1455096496.1490861328795"
X-Trace: blaine.gmane.org 1490861341 28665 195.159.176.226 (30 Mar 2017 08:09:01 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 30 Mar 2017 08:09:01 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC4237OVUEPRBEP26LDAKGQEZAJPMPI@isocpp.org Thu Mar 30 10:08:51 2017
Return-path: <std-proposals+bncBC4237OVUEPRBEP26LDAKGQEZAJPMPI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f69.google.com ([209.85.214.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC4237OVUEPRBEP26LDAKGQEZAJPMPI@isocpp.org>)
	id 1ctV8O-0005SP-MI
	for gclcip-std-proposals@m.gmane.org; Thu, 30 Mar 2017 10:08:44 +0200
Original-Received: by mail-it0-f69.google.com with SMTP id 19sf2456075itj.1
        for <gclcip-std-proposals@m.gmane.org>; Thu, 30 Mar 2017 01:08:50 -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
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=nhqGFCfmValLbGC80dGJmk5ZVLhDwR+S/bOHr7scXwM=;
        b=aw3PTPziutoRm3TRVw0r7k0ucM0z5reETVCPc+w+8ddfys4PtCCbvygb3Hjv1efeOt
         EgIc6UugMr8CYknzHHDXmTGq1Pd9gXuGA2ultfnktsARFtkKv1GR7fgQ6bCz0vwQlbY4
         Fq+Nh3xvOgYcza8GSBsHNSWrNtCAVrHbfxBv4HatzFUOH5ddPTc474rLellP86Y4vS4o
         EvrID/8ga9Fu9ZHySTMUeUS7fMdpPH4O+xVDwGjJy1gqEDMSmwuAOpJr443xa3s1DqTV
         ydUpBKcRQt23YVy8rVTy/2ro+he705BkRCpwX2nFd1SU5SNxlgOu9JIA2I1OQgv2KIUb
         ydmg==
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=nhqGFCfmValLbGC80dGJmk5ZVLhDwR+S/bOHr7scXwM=;
        b=qxW99ShPI+iwf+MbneLNldjy4zlwRd6dUAccunCm19EgGyRBkk9KeO/TPz5md/laQ3
         mz1b7n7oQaSQq6rjNgzftJ1jYyqDpfIk95VbKuWDAFB2w+5eNyarqeqD4Rrap3e2YjjN
         heVkA6/eIhyKT/e/F8QKBxmof1zt/8niUxiDr+9K3K+zAPVDLPrI584/39yLv7D2QOYo
         P3IM8sJuhMM0PS/hkux/InJUds3nPUmLkFQrVDRxXVFxySHlZpITn8wxnbI19o6SWdaH
         xagquBHJh09TRWVNMFVFBxBFJzTlTCZICXjgBBzApnzNtKFTgiw+3ynmmXITHxneFHEH
         xuZA==
X-Gm-Message-State: AFeK/H3Nlttf2S/94wNdzW6fqp5AMf9eKubJ631D/aJUerCytO0yg2lqft3ujLhTNTSsnA==
X-Received: by 10.107.13.20 with SMTP id 20mr1692300ion.1.1490861330298;
        Thu, 30 Mar 2017 01:08:50 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.24.83 with SMTP id t19ls2315823ott.28.gmail; Thu, 30 Mar
 2017 01:08:49 -0700 (PDT)
X-Received: by 10.157.13.75 with SMTP id 69mr567374oti.3.1490861329439;
        Thu, 30 Mar 2017 01:08:49 -0700 (PDT)
In-Reply-To: <985b9b2a-c734-45eb-95f4-db4dc0d309a1@isocpp.org>
X-Original-Sender: raffaele.rossi@mavensecurities.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:31893
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31893>

------=_Part_2303_1455096496.1490861328795
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Wouldn't it be much better to have a concept of *Context*? I am taking=20
inspiration from python (I know they use it for RAII, but that is a=20
different discussion).

The code might look like:

  void foo() {
    // do stuff
    with (unique_lock{mutex}) {
      // critical code
    }
    // other stuff
  }

Then, for prettiness and to avoid unnecessary indentations, when the=20
*Context* extends till the end of the parent scope, it can just be a=20
declaration:

  void foo() {
    with unique_lock{mutex};
    // critical code
  }

You can also nest *Contexts*:

  void foo() {
    with unique_lock{mutex1};
    with unique_lock{mutex2};
    // etc
  }

Also, by having a proper concept of *Context*, compilers and static=20
analysis tools would have more information available.

I don't know about the decomposition side of things, but perhaps using, say=
=20
@  instead? But I have to admit I still haven't understood the difference=
=20
with std::ignore (perhaps I have homework to do):

    auto [x, @, z] =3D expr;

Is anything of this any useful at all?

On Monday, 27 March 2017 21:27:11 UTC+1, Alberto Barbati wrote:

> Hello,
>
> this is a draft for a proposal to add a special meaning to the identifier=
=20
> __ (double underscore) so that it can be used (even repeatedly in the sam=
e=20
> lexical scope) for all variables whose name is not important and that is =
no=20
> longer needed after declaration. The draft includes a few examples.
>
> Is there any interest in this?
>
> Thanks in advance,
>
> Alberto
>
>
--=20


This e-mail together with any attachments (the "Message") is confidential=
=20
and may contain privileged information. If you are not the intended=20
recipient or if you have received this e-mail in error, please notify the=
=20
sender immediately and permanently delete this Message from your system.=20
 Do not copy, disclose or distribute the information contained in this=20
Message.

Maven Investment Partners Ltd (No. 07511928), Maven Derivatives Ltd (No.=20
07511840) , MVN Asset Management Limited (No. 09659116), Maven Europe Ltd=
=20
(No. 08966593), Maven Derivatives Asia Limited (No.10361312) & Maven=20
Securities Holding Ltd (No. 07505438) are registered as companies in=20
England and Wales and their registered address is Level 3, 6 Bevis Marks,=
=20
London EC3A 7BA, United Kingdom. The companies=E2=80=99 VAT No. is 13553901=
6. Maven=20
Asia (Hong Kong) Ltd (No. 2444041) is registered in Hong Kong and its=20
registered address is 20/F, 198 Wellington St, Hong Kong.  Only Maven=20
Derivatives Ltd and MVN Asset Management Limited are authorised and=20
regulated by the Financial Conduct Authority (Maven Derivatives Ltd FRN:=20
607267, MVN Asset Management Limited FRN: 714429)

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/7a03017c-ad72-466f-b2a3-c07f9186f387%40isocpp.or=
g.

------=_Part_2303_1455096496.1490861328795
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Wouldn&#39;t it be much better to have a concept of <=
b>Context</b>? I am taking inspiration from python (I know they use it for =
RAII, but that is a different discussion).</div><div><br></div><div>The cod=
e might look like:</div><div><br></div><div><font face=3D"courier new, mono=
space">=C2=A0 void foo() {</font></div><div><font face=3D"courier new, mono=
space">=C2=A0 =C2=A0 // do stuff</font></div><div><font face=3D"courier new=
, monospace">=C2=A0 =C2=A0 with (unique_lock{mutex}) {</font></div><div><fo=
nt face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 // critical code</f=
ont></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 }</font>=
</div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 // other stu=
ff</font></div><div><font face=3D"courier new, monospace">=C2=A0 }</font></=
div><div><br></div><div>Then, for prettiness and to avoid unnecessary inden=
tations, when the <b>Context</b> extends till the end of the parent scope, =
it can just be a declaration:</div><div><br></div><div><font face=3D"courie=
r new, monospace">=C2=A0 void foo() {</font></div><div><font face=3D"courie=
r new, monospace">=C2=A0 =C2=A0 with unique_lock{mutex};</font></div><div><=
font face=3D"courier new, monospace">=C2=A0 =C2=A0 // critical code<br></fo=
nt></div><div><font face=3D"courier new, monospace">=C2=A0 }</font></div><d=
iv><div><br></div><div>You can also nest <b>Contexts</b>:</div><div><br></d=
iv><div><font face=3D"courier new, monospace">=C2=A0 void foo() {</font></d=
iv><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 with unique_loc=
k{mutex1};</font></div><div><div><font face=3D"courier new, monospace">=C2=
=A0 =C2=A0 with unique_lock{mutex2};</font></div><div><font face=3D"courier=
 new, monospace">=C2=A0 =C2=A0 // etc</font></div><div><font face=3D"courie=
r new, monospace">=C2=A0 }</font></div><div><br></div><div>Also, by having =
a proper concept of <b>Context</b>, compilers and static analysis tools wou=
ld have more information available.</div><div><br></div><div>I don&#39;t kn=
ow about the decomposition side of things, but perhaps using, say <font fac=
e=3D"courier new, monospace">@</font> =C2=A0instead? But I have to admit I =
still haven&#39;t understood the difference with <font face=3D"courier new,=
 monospace">std::ignore</font> (perhaps I have homework to do):</div><div><=
br></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 auto [x, =
@, z] =3D expr;<br></font></div><div><br></div><div>Is anything of this any=
 useful at all?</div><div><br></div><div>On Monday, 27 March 2017 21:27:11 =
UTC+1, Alberto Barbati  wrote:<br></div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;"><div dir=3D"ltr">Hello,<br><br>this is a draft for a proposal to =
add a special meaning to the identifier __ (double underscore) so that it c=
an be used (even repeatedly in the same lexical scope) for all variables wh=
ose name is not important and that is no longer needed after declaration. T=
he draft includes a few examples.<br><br>Is there any interest in this?<br>=
<br>Thanks in advance,<br><br>Alberto<br><br></div></blockquote></div></div=
></div>
<br>
<p><font color=3D"#222222" face=3D"Arial, sans-serif" size=3D"2">This e-mai=
l together with any attachments (the &quot;Message&quot;) is confidential a=
nd may contain privileged information. If you are not the intended recipien=
t or if you have received this e-mail in error, please notify the sender im=
mediately and permanently delete this Message from your system. =C2=A0Do no=
t copy, disclose or distribute the information contained in this Message.</=
font></p><p><span style=3D"color:rgb(34,34,34);font-family:Arial,sans-serif=
"><font size=3D"2">Maven Investment Partners Ltd (No. 07511928), Maven Deri=
vatives Ltd (No. 07511840) , MVN Asset Management Limited (No. 09659116), M=
aven Europe Ltd (No. 08966593), Maven Derivatives Asia Limited (No.10361312=
) &amp; Maven Securities Holding Ltd (No. 07505438) are registered as compa=
nies in England and Wales and their registered address is Level 3, 6 Bevis =
Marks, London EC3A 7BA, United Kingdom. The companies=E2=80=99 VAT No. is 1=
35539016. Maven Asia (Hong Kong) Ltd (No. 2444041) is registered in Hong Ko=
ng and its registered address is 20/F, 198 Wellington St, Hong Kong. =C2=A0=
Only Maven Derivatives Ltd and MVN Asset Management Limited are authorised =
and regulated by the Financial Conduct Authority (Maven Derivatives Ltd FRN=
: 607267, MVN Asset Management Limited FRN: 714429)</font></span></p>

<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/7a03017c-ad72-466f-b2a3-c07f9186f387%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7a03017c-ad72-466f-b2a3-c07f9186f387=
%40isocpp.org</a>.<br />

------=_Part_2303_1455096496.1490861328795--

.
