220 31894 <00f80877-4564-406b-9dc5-d2d961b8dce3@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Raffaele Rossi <rossi.raffaele@gmail.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:12:46 -0700 (PDT)
Lines: 113
Approved: news@gmane.org
Message-ID: <00f80877-4564-406b-9dc5-d2d961b8dce3@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/mixed; 
	boundary="----=_Part_3045_308760219.1490861566356"
X-Trace: blaine.gmane.org 1490861584 24465 195.159.176.226 (30 Mar 2017 08:13:04 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 30 Mar 2017 08:13:04 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC6IBYFLW4MRB7736LDAKGQEMEDOFKQ@isocpp.org Thu Mar 30 10:12:59 2017
Return-path: <std-proposals+bncBC6IBYFLW4MRB7736LDAKGQEMEDOFKQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f69.google.com ([209.85.218.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC6IBYFLW4MRB7736LDAKGQEMEDOFKQ@isocpp.org>)
	id 1ctVCE-0004Gh-31
	for gclcip-std-proposals@m.gmane.org; Thu, 30 Mar 2017 10:12:42 +0200
Original-Received: by mail-oi0-f69.google.com with SMTP id r203sf18257907oib.15
        for <gclcip-std-proposals@m.gmane.org>; Thu, 30 Mar 2017 01:12:48 -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=SrhgL6ErhD2VJJjnF4ALmSjok7mqYoJNu28PMrD6Dvk=;
        b=RoIJB+MvViPele+Gzu+BzU4HRGmNjxO6RH+YPNhGbXg6dHtKepwo4AhI0njF2/aW7w
         f09Lly1axCUZ9b7CLjYZHEh23MhLSHd407hjDSycHfhHWZZps/itA9sV1FlBEI/Dwk7A
         esF917UmnJSSAcZ2XGHxjNjQq8PKDcKUgwMHHXVksAfNAW30ENg0lKIop809kQaG7gxu
         DRNaSv7G89xz3hoFelpL7Es5tfnpKB6DoeVSMc9Aa7p7dq4jrKDMnkaK/JZtrIqoSFhg
         IcL2c8AWDl1Qekoj3GrDJORqzrLJeUBBugsGLZzOfdgfC8nNDyA6CEedAvBmXEiE3A+0
         pWig==
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
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SrhgL6ErhD2VJJjnF4ALmSjok7mqYoJNu28PMrD6Dvk=;
        b=Vu3Pmh79fvnXt49Zq3pImy3izRkS2w3nBNlxdMZzRIgP3X/KWSUoZkyet67dsuYAZ7
         23VmJeoMLZgS5WBWu75ZEMZyFz/P3IztNWV/1OMsbX7KMFJkU7ouiM9adZ1gyTtdm12u
         0hIT79sd9begbU/Ay9W0AcmtB17CHD5Kx1PMY5sxml+SUvOLrK+wjgEd7OYKzezaUh8z
         4xj1SVqfhGNIcXzh174mIWLCDT9N6i8wCuDWsJ+yhXb+6JyIJd7upDqjT8KI3iLV0J2a
         TcKe1N+ddXICw3l6kGX/nK5St6qO7hsi6lg8W2y8xbys+4YlL53AAGGt8Kq/SadhuK65
         6MRg==
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=SrhgL6ErhD2VJJjnF4ALmSjok7mqYoJNu28PMrD6Dvk=;
        b=OMPB6asX5AwJv/X1SlukrG2rAihyVMHEEeBu/PH8ckL/YTCf4LTVM3k1L5at4DRNQN
         AJlx9x9i3DgY8CP1b+N2LcbEKZ43wAqOp+zYMTgrw/6d1JhZ3SQqXpQ2/80d8eWnP0sm
         WT8OQcyYAxR0QK8e/VCkWNJ2ziKL+3yZFxwcxhwpV0sTxeKeum32IrlqTAkD/7XoMn7a
         sGlijyLi9ZAriXEKIFyPqDnMVu6uZkuOb7UfpCs92SSb3QnKOiPOSj6sxHam4Zu/jaZ1
         NuCx0zQY5pf0867DGVvv0ss08G6/bqzO8ZPmOayRCxqsvj+GJpoqVwuv667jE480p1ud
         OHng==
X-Gm-Message-State: AFeK/H28rxUsY6hoeoGxFAE9Zg6ICs4ESL5EMKGpWZ/8eEQz5nhUwKTJLXXL8DcAyrRR3Q==
X-Received: by 10.157.27.253 with SMTP id v58mr772896otv.7.1490861567838;
        Thu, 30 Mar 2017 01:12:47 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.20.70 with SMTP id h64ls2289652oth.33.gmail; Thu, 30 Mar
 2017 01:12:47 -0700 (PDT)
X-Received: by 10.157.67.140 with SMTP id t12mr569576ote.7.1490861567000;
        Thu, 30 Mar 2017 01:12:47 -0700 (PDT)
In-Reply-To: <985b9b2a-c734-45eb-95f4-db4dc0d309a1@isocpp.org>
X-Original-Sender: rossi.raffaele@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:31894
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/31894>

------=_Part_3045_308760219.1490861566356
Content-Type: multipart/alternative; 
	boundary="----=_Part_3046_1573441332.1490861566356"

------=_Part_3046_1573441332.1490861566356
Content-Type: text/plain; charset=UTF-8

Wouldn't it be much better to have a concept of Context? I am taking 
inspiration from python (I know they use it for RAII, but that is a 
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 
Context extends till the end of the parent scope, it can just be a 
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 analysis 
tools would have more information available.

I don't know about the decomposition side of things, but perhaps using, say 
@  instead? But I have to admit I still haven't understood the difference 
with std::ignore (perhaps I have homework to do):

    auto [x, @, z] = expr;

Is anything of this any useful at all?

-- 
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/00f80877-4564-406b-9dc5-d2d961b8dce3%40isocpp.org.

------=_Part_3046_1573441332.1490861566356
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 C=
ontext? I am taking inspiration from python (I know they use it for RAII, b=
ut that is a different discussion).<br></div><div><br></div><div>The code m=
ight look like:</div><div><font face=3D"courier new, monospace"><br></font>=
</div><div><font face=3D"courier new, monospace">=C2=A0 void foo() {</font>=
</div><div><font face=3D"courier new, monospace">=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><font face=3D"courier new, monospace=
">=C2=A0 =C2=A0 =C2=A0 // critical code</font></div><div><font face=3D"cour=
ier new, monospace">=C2=A0 =C2=A0 }</font></div><div><font face=3D"courier =
new, monospace">=C2=A0 =C2=A0 // other stuff</font></div><div><font face=3D=
"courier new, monospace">=C2=A0 }</font></div><div><br></div><div>Then, for=
 prettiness and to avoid unnecessary indentations, when the Context extends=
 till the end of the parent scope, it can just be a declaration:</div><div>=
<br></div><div><font face=3D"courier new, monospace">=C2=A0 void foo() {</f=
ont></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 with uni=
que_lock{mutex};</font></div><div><font face=3D"courier new, monospace">=C2=
=A0 =C2=A0 // critical code</font></div><div><font face=3D"courier new, mon=
ospace">=C2=A0 }</font></div><div><br></div><div>You can also nest Contexts=
:</div><div><br></div><div><font face=3D"courier new, monospace">=C2=A0 voi=
d foo() {</font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=
=A0 with unique_lock{mutex1};</font></div><div><font face=3D"courier new, m=
onospace">=C2=A0 =C2=A0 with unique_lock{mutex2};</font></div><div><font fa=
ce=3D"courier new, monospace">=C2=A0 =C2=A0 // etc</font></div><div><font f=
ace=3D"courier new, monospace">=C2=A0 }</font></div><div><br></div><div>Als=
o, by having a proper concept of Context, compilers and static analysis too=
ls would have more information available.</div><div><br></div><div>I don&#3=
9;t know about the decomposition side of things, but perhaps using, say @ =
=C2=A0instead? But I have to admit I still haven&#39;t understood the diffe=
rence with <font face=3D"courier new, monospace">std::ignore</font> (perhap=
s I have homework to do):</div><div><br></div><div><font face=3D"courier ne=
w, monospace">=C2=A0 =C2=A0 auto [x, @, z] =3D expr;</font></div><div><br><=
/div><div>Is anything of this any useful at all?</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&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/00f80877-4564-406b-9dc5-d2d961b8dce3%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/00f80877-4564-406b-9dc5-d2d961b8dce3=
%40isocpp.org</a>.<br />

------=_Part_3046_1573441332.1490861566356--

------=_Part_3045_308760219.1490861566356--

.
