220 22022 <6b98496b-ea50-4155-8560-4fd0d445a5c5@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vlad from Moscow <vlad.moscow@mail.ru>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: New compound assignment operators.:)
Date: Tue, 27 Oct 2015 13:27:23 -0700 (PDT)
Lines: 140
Approved: news@gmane.org
Message-ID: <6b98496b-ea50-4155-8560-4fd0d445a5c5@isocpp.org>
References: <e0f0d04d-491f-43ba-90a8-858cdf308768@isocpp.org>
 <n0ols9$bom$1@ger.gmane.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6950_928031894.1445977643740"
X-Trace: ger.gmane.org 1445977647 31152 80.91.229.3 (27 Oct 2015 20:27:27 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 27 Oct 2015 20:27:27 +0000 (UTC)
Cc: mwoehlke.floss@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXLLRHD7IDRBLF4X6YQKGQECRZF67A@isocpp.org Tue Oct 27 21:27:27 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBLF4X6YQKGQECRZF67A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f198.google.com ([209.85.160.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBLF4X6YQKGQECRZF67A@isocpp.org>)
	id 1ZrAq6-0002Dl-93
	for gclcip-std-proposals@m.gmane.org; Tue, 27 Oct 2015 21:27:26 +0100
Original-Received: by ykdy125 with SMTP id y125sf380484392ykd.3
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Oct 2015 13:27:25 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type: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=+ifshlqWFIGDSw3TlRJgu0JxAGDxuXTiqYLnYj6cCbA=;
        b=mHzpEsqRdhgyMsI3aAU6tr0z+8L7cB7EunDHOQuvxzew2ac9HcNRn6bFyk0sSVfaCK
         ml9FbJbK3HuuJ3G/jMKK6Z74/BqHnw9spTilE2tuZ2wM6Yyhp0f4h3bj6eSHDYA9t20P
         rXYm1D2deHP0cksIGP1vDNCCtktwLIu5KBLznpFsSfvJvBPzlZgGFCC7iu29lS0nlblx
         YSJYfR+dtJ28TCz+rSuwcDZGp82PH+BFsoCVqnQS/oC0GPNIMi6g9GblJNypnuWhoq12
         l10BpdUsnygKG05rHhHKN3LKvaW93rw9eMzeO8wBTlENZYV59G1brWrVQ5sqi1NHddtH
         sAww==
X-Gm-Message-State: ALoCoQmFxi2K6KInHbVoOPDC7NPsRgUV/KBS9UVuntW6AOu2rL5RgWlkZ09mju4THDo7P00vW20B
X-Received: by 10.140.176.140 with SMTP id w134mr8355167qhw.6.1445977645468;
        Tue, 27 Oct 2015 13:27:25 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.78.202 with SMTP id d10ls1330727igx.41.canary; Tue, 27 Oct
 2015 13:27:24 -0700 (PDT)
X-Received: by 10.50.20.7 with SMTP id j7mr13571ige.1.1445977644428;
        Tue, 27 Oct 2015 13:27:24 -0700 (PDT)
In-Reply-To: <n0ols9$bom$1@ger.gmane.org>
X-Original-Sender: vlad.moscow@mail.ru
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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://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>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:22022
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/22022>

------=_Part_6950_928031894.1445977643740
Content-Type: multipart/alternative; 
	boundary="----=_Part_6951_1719810581.1445977643740"

------=_Part_6951_1719810581.1445977643740
Content-Type: text/plain; charset=UTF-8



On Tuesday, October 27, 2015 at 11:13:12 PM UTC+3, Matthew Woehlke wrote:
>
> On 2015-10-27 16:00, Vlad from Moscow wrote: 
> > So the idea is to introduce compound operators like :) 
> > 
> > =+, =-,=*,  =/, =% 
>
> At least the first two can't happen: 
>
>   // Currently valid code 
>   x =+ 2; 
>   y =- 4; 
>   // x == 2, y == -4 
>
> Even adding ()'s won't help. 
>
> I'm not necessarily saying that the idea itself is bad, but the proposed 
> syntax is not feasible. 
>
> -- 
> Matthew 
>
>
It is enough often  when I am writing a predicate for an algorithm I need 
to return the result of a comparison or other logical operator. But before 
to return the result I need to do some action with one of arguments or a 
captured cariable that takes part in the logical expression. So I have to 
introduce a boolean variable that to keep the result then do the action and 
only after that return the result.

The idea came to my head when I was answering the following question at SO 
http://stackoverflow.com/questions/33375769/a-zero-indexed-array-given-an-equilibrium-index-of-this-array/33376721#33376721

Instead of writing three statements in the if statement

    for ( size_t i = 0; i < sizeof( a ) / sizeof( *a ); i++ )
    {
        right_sum -= a[i];
        if ( left_sum == right_sum ) std::cout << i << ' ';
        left_sum += a[i];
    }
 
I could write only one statement :)

    for ( size_t i = 0; i < sizeof( a ) / sizeof( *a ); i++ )
    {
        if ( ( left_sum =+ a[i] ) == ( right_sum -= a[i] ) ) std::cout << i 
<< ' ';
    }

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_6951_1719810581.1445977643740
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Tuesday, October 27, 2015 at 11:13:12 PM UTC+3,=
 Matthew Woehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204);=
 border-left-width: 1px; border-left-style: solid;">On 2015-10-27 16:00, Vl=
ad from Moscow wrote:
<br>&gt; So the idea is to introduce compound operators like :)
<br>&gt;=20
<br>&gt; =3D+, =3D-,=3D*, =C2=A0=3D/, =3D%=20
<br>
<br>At least the first two can&#39;t happen:
<br>
<br>=C2=A0 // Currently valid code
<br>=C2=A0 x =3D+ 2;
<br>=C2=A0 y =3D- 4;
<br>=C2=A0 // x =3D=3D 2, y =3D=3D -4
<br>
<br>Even adding ()&#39;s won&#39;t help.
<br>
<br>I&#39;m not necessarily saying that the idea itself is bad, but the pro=
posed
<br>syntax is not feasible.
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote><div><br></div><div>It is enough often=C2=A0=C2=A0when I a=
m writing a predicate for an algorithm I need to return the result of a com=
parison or other logical operator. But before to return the result I need t=
o do some action with one of arguments or a captured cariable that takes pa=
rt in the logical expression. So I have to introduce a boolean variable tha=
t to keep the result then do the action and only after that return the resu=
lt.</div><div><br></div><div>The idea came to my head when I was answering =
the following question at SO <a href=3D"http://stackoverflow.com/questions/=
33375769/a-zero-indexed-array-given-an-equilibrium-index-of-this-array/3337=
6721#33376721">http://stackoverflow.com/questions/33375769/a-zero-indexed-a=
rray-given-an-equilibrium-index-of-this-array/33376721#33376721</a></div><d=
iv><br></div><div>Instead of writing three statements in the if statement</=
div><div><br></div><div><span class=3D"kwd">=C2=A0=C2=A0=C2=A0 for ( size_t=
 i =3D 0; i &lt; sizeof( a ) / sizeof( *a ); i++ )<br>=C2=A0=C2=A0=C2=A0 {<=
br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 right_sum -=3D a[i];<br>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if ( left_sum =3D=3D right_sum )=C2=
=A0std::cout &lt;&lt; i &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 left_sum +=3D a[i];<br>=C2=A0=C2=A0=C2=A0 }<br></span></=
div><div>=C2=A0</div><div>I could write only one statement :)</div><div><br=
></div><div>=C2=A0=C2=A0=C2=A0 for ( size_t i =3D 0; i &lt; sizeof( a ) / s=
izeof( *a ); i++ )<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 if ( ( left_sum =3D+ a[i]=C2=A0)=C2=A0=3D=3D ( right_sum -=
=3D a[i] ) )=C2=A0std::cout &lt;&lt; i &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=
=A0=C2=A0 }<br></div></div>

<p></p>

-- <br />
<br />
--- <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_6951_1719810581.1445977643740--
------=_Part_6950_928031894.1445977643740--

.
