220 37373 <8751b79c-2f93-4916-bd0e-51b8e3eb910f@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: "T. C." <rs2740@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Pointer overload for ||
Date: Fri, 16 Mar 2018 15:12:40 -0700 (PDT)
Lines: 237
Approved: news@gmane.org
Message-ID: <8751b79c-2f93-4916-bd0e-51b8e3eb910f@isocpp.org>
References: <1fea07df-46a6-4df2-865a-849be8f8d129@isocpp.org>
 <CANiq72kL7HQf2oS5THm8bxzurhzoc7uhNQq3S9+zvBce2yMZZQ@mail.gmail.com>
 <c7cd5d95-0031-4e50-b7a1-9adcff695bd2@isocpp.org> <CALvx3hYz84MdBu_WsixPmWf8N=9FY4BiqOv+Lon21nF2m_f0Ow@mail.gmail.com>
 <CALvx3hbrrb6tJJYEG7S9q1YrRWSXXi+OCW9n1siXRfFjjxTDYA@mail.gmail.com> <CANiq72kNstxnyLTCOBfNorEiyudTijCAUHwH4DsoT14WqcNs4w@mail.gmail.com>
 <CAANG=kWjgCt-+pKOwWk6BgwNZ9ZECd9twWwq_FC1f3WPEiNw=A@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_2769_1776788060.1521238360549"
X-Trace: blaine.gmane.org 1521238240 6178 195.159.176.226 (16 Mar 2018 22:10:40 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 16 Mar 2018 22:10:40 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCQ43G7NQIIRBWMCWHKQKGQEKAR3PUQ@isocpp.org Fri Mar 16 23:10:36 2018
Return-path: <std-proposals+bncBCQ43G7NQIIRBWMCWHKQKGQEKAR3PUQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCQ43G7NQIIRBWMCWHKQKGQEKAR3PUQ@isocpp.org>)
	id 1ewxYZ-0001VB-F6
	for gclcip-std-proposals@m.gmane.org; Fri, 16 Mar 2018 23:10:35 +0100
Original-Received: by mail-vk0-f70.google.com with SMTP id w68sf7169241vkd.16
        for <gclcip-std-proposals@m.gmane.org>; Fri, 16 Mar 2018 15:12:43 -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=6L9cXsepTztVkveBYdJtFTGkCW2GPEXMcYdGObsXYCc=;
        b=vJbB4gvqyuMAPdWWR3zzYBcPjQ+vMcQ4vPk1e/VNAU/aPfXpSAgJ9TPlbXxSjDO5lQ
         L2xXXFUoOiW0M9DT6xm/5/9rHqar08eIuYqRULYWDrisVxLAm/1XkYl2IuYf+ParxUdr
         a2DvU/Y0SgPkfPQFF0BsDqob9fOPicODzlHPz4sru9ucbuF5jxwVo8JQPECk7wLlfcd+
         sviMpV5xX+oX1eKy8J0yi1UnKGXzTBrOk+xe8o8nFO2tOCdk4199rzv/eD4QWlC3uXAF
         kO1iLgdK7qKsRMufm75SXKQVfHmIdQpG8c4lmkooK4b9Jq+gH2d9Fx/D09aTP9R7SBZ8
         IWkA==
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=6L9cXsepTztVkveBYdJtFTGkCW2GPEXMcYdGObsXYCc=;
        b=DjSUB481fLEs5mFaGh4e2bfMnCXku+looqOjp7D2UTR5P44K66PD25x8ebJelLS4ik
         D51w8TGXv3jGSJ+UMJEaPFDWTTMClLKLgxVD1wRu163UAJXfLgHw8PwZwEv6DsDWzkY6
         538YSmp8Q9MQKj5Qs2/zrf3DPFkQ+ywBc/5/FPpvlMC3C75Pec5M2Mqhco1JKndqWoDu
         arwLEfYCsUD4PybE9zgwlAsEhBzhB95TWusWjXvXD0a0d2VLlceu3g6w+xtRbIgbCZtT
         FzKL5z/nGrDvSVh8aomCub3Pt47j4C9cciR0OnRnIRCf18apWjGsqQ/WYkZokBSFtb9Z
         WRRw==
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=6L9cXsepTztVkveBYdJtFTGkCW2GPEXMcYdGObsXYCc=;
        b=UPUA+rZI7t28opiEkdXWfy1dpAOEMRPEGbcSSfCo3j7tZfK+htj3fCFhjmxFSIdL0g
         0pkvutn3qpankrjSP+/v7Y/KQIFjIA4xhrfIJtp9xOLEE1cv5AB0kZpVSPbXFn8mHpE+
         m/MMq4SLTNq5AwK5qKB8CaWtktSPXTR3tatrg36oAwmHnsLa2jDtiflnCDodr3M0W8W/
         cng26uD8bhES0n6LM2JanBXpwwLx1BwI8483/xXAoBXevUmKTdqAuZI4v9Uv9gYtIf1P
         Wb5w5qChcbU56QqBRIS6APJLLygPkdGdqe/2h1E39LUxr2XVMD4yD/FjIIE8RFWeXnu0
         CkhA==
X-Gm-Message-State: AElRT7E60cnKsWaj49rHPAzt0KxNEUusgdhCTykT5gz0DA49432GGAlr
	q1q6rTJSa026ViHGwvSxUGiCEg==
X-Google-Smtp-Source: AG47ELt3AIYe27mxk216iXj/gKpm1YJ+FdIbmvoJ+Z8xsXf5F0sd1gINvAwvqZcl6xvY2dO1W3op3w==
X-Received: by 10.176.80.248 with SMTP id d53mr1556448uaa.43.1521238362576;
        Fri, 16 Mar 2018 15:12:42 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.120.135 with SMTP id t129ls4384655vkc.15.gmail; Fri, 16 Mar
 2018 15:12:41 -0700 (PDT)
X-Received: by 10.31.151.87 with SMTP id z84mr398356vkd.5.1521238361066;
        Fri, 16 Mar 2018 15:12:41 -0700 (PDT)
In-Reply-To: <CAANG=kWjgCt-+pKOwWk6BgwNZ9ZECd9twWwq_FC1f3WPEiNw=A@mail.gmail.com>
X-Original-Sender: rs2740@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:37373
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37373>

------=_Part_2769_1776788060.1521238360549
Content-Type: multipart/alternative; 
	boundary="----=_Part_2770_1313924794.1521238360550"

------=_Part_2770_1313924794.1521238360550
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

This was proposed in N4120 and rejected by EWG.

On Tuesday, March 13, 2018 at 7:26:46 AM UTC-4, Ga=C5=A1per A=C5=BEman wrot=
e:
>
> But my point was we *already have* an operator with the exact semantics o=
f=20
> the macro above - it's just a gnu extension. We could just propose that!
>
> https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html
>
> x =3D x?:new int;
>
> It's unambiguous, it's obvious it's a conditional, it's a one-liner, and=
=20
> more importantly, it can be used for way more than just pointers. Oh, and=
=20
> we have implementations and knowledge of how it behaves, and it's also no=
t=20
> a weird new form of || or |.
>
> It also fails to compile if "x" and the expression if x is falsy don't=20
> have a common type, which is *also* important.
>
> So, I'd encourage the author of this proposal to instead propose the gnu=
=20
> extension as an actual feature, instead of trying to fit a "don't evaluat=
e=20
> this" model as a special case for just certain types - making user-define=
d=20
> types less like built-in types is an explicit no-no these days, and this=
=20
> proposal is just trying to special-case pointers.
>
> G
>
>
> On Mon, Mar 12, 2018 at 11:41 AM, Miguel Ojeda <miguel.oje...@gmail.com=
=20
> <javascript:>> wrote:
>
>> On Mon, Mar 12, 2018 at 11:42 AM, Richard Hodges <hodg...@gmail.com=20
>> <javascript:>> wrote:
>> >
>> > Consider:
>> >
>> > p |=3D new_thing();
>> >
>> > In the above code, do we mean that we wish to replace p with a new=20
>> thing if
>> > empty, or does it mean that we wish to merge a new thing into the obje=
ct
>> > referenced by p?
>>
>> For me ||=3D would be the replace. But since we don't have ||=3D, I just
>> picked |=3D, which indeed looks fishy.
>>
>> Now, what would be a nice experiment would be ||, &&, ||=3D and &&=3D wi=
th
>> short-circuit semantics, which could be implemented if we had the
>> "expression E" stuff:
>>
>>     template <typename T, expression E>
>>     operator||=3D(T & t, E)
>>     {
>>         if (t)
>>             return;
>>         t =3D E;
>>     }
>>
>> Then:
>>
>>     x ||=3D new int;
>>
>> would have the expected results.
>>
>> Cheers,
>> Miguel
>>
>> --
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANiq72kNst=
xnyLTCOBfNorEiyudTijCAUHwH4DsoT14WqcNs4w%40mail.gmail.com
>> .
>>
>
>

--=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/8751b79c-2f93-4916-bd0e-51b8e3eb910f%40isocpp.or=
g.

------=_Part_2770_1313924794.1521238360550
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This was proposed in=C2=A0N4120 and rejected by EWG.<br><b=
r>On Tuesday, March 13, 2018 at 7:26:46 AM UTC-4, Ga=C5=A1per A=C5=BEman wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">But my po=
int was we *already have* an operator with the exact semantics of the macro=
 above - it&#39;s just a gnu extension. We could just propose that!<div><br=
></div><div><a href=3D"https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html=
" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;https:=
//www.google.com/url?q\x3dhttps%3A%2F%2Fgcc.gnu.org%2Fonlinedocs%2Fgcc%2FCo=
nditionals.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH23eFTLoIJ2YmyrzhOW=
FGs_Ak7kg&#39;;return true;" onclick=3D"this.href=3D&#39;https://www.google=
..com/url?q\x3dhttps%3A%2F%2Fgcc.gnu.org%2Fonlinedocs%2Fgcc%2FConditionals.h=
tml\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH23eFTLoIJ2YmyrzhOWFGs_Ak7kg&#3=
9;;return true;">https://gcc.gnu.org/<wbr>onlinedocs/gcc/Conditionals.<wbr>=
html</a><br></div><div><br></div><div>x =3D x?:new int;</div><div><br></div=
><div>It&#39;s unambiguous, it&#39;s obvious it&#39;s a conditional, it&#39=
;s a one-liner, and more importantly, it can be used for way more than just=
 pointers. Oh, and we have implementations and knowledge of how it behaves,=
 and it&#39;s also not a weird new form of || or |.</div><div><br></div><di=
v>It also fails to compile if &quot;x&quot; and the expression if x is fals=
y don&#39;t have a common type, which is *also* important.</div><div><br></=
div><div>So, I&#39;d encourage the author of this proposal to instead propo=
se the gnu extension as an actual feature, instead of trying to fit a &quot=
;don&#39;t evaluate this&quot; model as a special case for just certain typ=
es - making user-defined types less like built-in types is an explicit no-n=
o these days, and this proposal is just trying to special-case pointers.</d=
iv><div><br></div><div>G</div><div><br></div></div><div><br><div class=3D"g=
mail_quote">On Mon, Mar 12, 2018 at 11:41 AM, Miguel Ojeda <span dir=3D"ltr=
">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Q8=
e4LcgbAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#3=
9;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;"=
>miguel.oje...@gmail.<wbr>com</a>&gt;</span> wrote:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding=
-left:1ex"><span>On Mon, Mar 12, 2018 at 11:42 AM, Richard Hodges &lt;<a hr=
ef=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"Q8e4LcgbAQAJ"=
 rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#39;;return t=
rue;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;">hodg...@gm=
ail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Consider:<br>
&gt;<br>
&gt; p |=3D new_thing();<br>
&gt;<br>
&gt; In the above code, do we mean that we wish to replace p with a new thi=
ng if<br>
&gt; empty, or does it mean that we wish to merge a new thing into the obje=
ct<br>
&gt; referenced by p?<br>
<br>
</span>For me ||=3D would be the replace. But since we don&#39;t have ||=3D=
, I just<br>
picked |=3D, which indeed looks fishy.<br>
<br>
Now, what would be a nice experiment would be ||, &amp;&amp;, ||=3D and &am=
p;&amp;=3D with<br>
short-circuit semantics, which could be implemented if we had the<br>
&quot;expression E&quot; stuff:<br>
<span><br>
=C2=A0 =C2=A0 template &lt;typename T, expression E&gt;<br>
</span>=C2=A0 =C2=A0 operator||=3D(T &amp; t, E)<br>
=C2=A0 =C2=A0 {<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (t)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 t =3D E;<br>
=C2=A0 =C2=A0 }<br>
<br>
Then:<br>
<br>
=C2=A0 =C2=A0 x ||=3D new int;<br>
<br>
would have the expected results.<br>
<span><br>
Cheers,<br>
Miguel<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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
Q8e4LcgbAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"Q8e4LcgbAQAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39=
;javascript:&#39;;return true;">std-pr...@isocpp.org</a>.<br>
</span>To view this discussion on the web visit <a href=3D"https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/CANiq72kNstxnyLTCOBfNorEiyudTi=
jCAUHwH4DsoT14WqcNs4w%40mail.gmail.com" rel=3D"nofollow" target=3D"_blank" =
onmousedown=3D"this.href=3D&#39;https://groups.google.com/a/isocpp.org/d/ms=
gid/std-proposals/CANiq72kNstxnyLTCOBfNorEiyudTijCAUHwH4DsoT14WqcNs4w%40mai=
l.gmail.com&#39;;return true;" onclick=3D"this.href=3D&#39;https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/CANiq72kNstxnyLTCOBfNorEiyudTi=
jCAUHwH4DsoT14WqcNs4w%40mail.gmail.com&#39;;return true;">https://groups.go=
ogle.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/<wbr>CANiq72kNstxnyLT=
COBfNorEiyudTi<wbr>jCAUHwH4DsoT14WqcNs4w%40mail.<wbr>gmail.com</a>.<br>
</blockquote></div><br></div>
</blockquote></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/8751b79c-2f93-4916-bd0e-51b8e3eb910f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/8751b79c-2f93-4916-bd0e-51b8e3eb910f=
%40isocpp.org</a>.<br />

------=_Part_2770_1313924794.1521238360550--

------=_Part_2769_1776788060.1521238360549--

.
