220 37320 <CAANG=kWjgCt-+pKOwWk6BgwNZ9ZECd9twWwq_FC1f3WPEiNw=A@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Pointer overload for ||
Date: Tue, 13 Mar 2018 11:26:23 +0000
Lines: 182
Approved: news@gmane.org
Message-ID: <CAANG=kWjgCt-+pKOwWk6BgwNZ9ZECd9twWwq_FC1f3WPEiNw=A@mail.gmail.com>
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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="f403045c5a2a7fd11405674988bb"
X-Trace: blaine.gmane.org 1520940284 16528 195.159.176.226 (13 Mar 2018 11:24:44 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 13 Mar 2018 11:24:44 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDRYVJ6TVYBRB5PKT3KQKGQE3TNMFVA@isocpp.org Tue Mar 13 12:24:40 2018
Return-path: <std-proposals+bncBDRYVJ6TVYBRB5PKT3KQKGQE3TNMFVA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pl0-f71.google.com ([209.85.160.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDRYVJ6TVYBRB5PKT3KQKGQE3TNMFVA@isocpp.org>)
	id 1evi2p-000492-Kz
	for gclcip-std-proposals@m.gmane.org; Tue, 13 Mar 2018 12:24:40 +0100
Original-Received: by mail-pl0-f71.google.com with SMTP id f3-v6sf1507164plf.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 13 Mar 2018 04:26:47 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1520940406; cv=pass;
        d=google.com; s=arc-20160816;
        b=KRXzQlxaYOVQYMiWS/OjH1abA+IY6f0iM5vUKAqyvniPXzWA9CwE+A6nSyi7WOsq9Q
         aTYkcgSufbKa1OKmqx7xifF/jVN4rHL3vA8zwCReysFNJTUkC4yAUx28LIm82an3NSkb
         OTSNJSVRLADUlo4Yh7EhvmEIs3eabW4wcM3Dg8QBu1QgEV2wPKd/evFW0UCv4j9j3Rua
         dQp9GLV25bc6D3NrCcOYp9gwMdsrAcNlLX1TOFuyW+/CC+cWNnvbvQdrcJG9jZgpv+eL
         7h5fzqvOa8VjNc5rZ28VdVkdg/qVSeD/ixfBxO48652s2w+VkGVXHrgrN+dy1kxAbexA
         qzmA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=9AnPluum9emnS2pkPK+6WBXOIKMuMp9QQ4T5u86wsh8=;
        b=wSlIy9T0EA7jIFKidAhgUTWV812/3V7Pp046K1xUKJS9otBhb2ZEuERV2DBvJRi71o
         xnGFlM20uGNw6dLqg0aCmgLyK951X5+afu4CQgJKPeeuEnTZsdurO/psreDQGyEKfYIJ
         emh5wmn+ncvoplsWdcxAj148l5j7XvEVUEZfoT9JcyxluTGAi8g3MFN3jD4BZnMPVQan
         x2KPdZa36CQFEO4ofEjg6rJdhskLH0VMAWK3WaDE1ysxHaN8q7VrLeqPxlYTsOdWVogN
         2Xo8tNAvq0asoaLOAI4Y+yN2Rv2QBPGkMMRgVLeBzPyT7zIEL67oo/i25yhZhhzt68rA
         QlPw==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=knohT2F9;
       spf=pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=gasper.azman@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=9AnPluum9emnS2pkPK+6WBXOIKMuMp9QQ4T5u86wsh8=;
        b=mM/IVXljOwnDGtWlBuE5v/beIzqdqsyIigMXnTKpfRTRLQnzwt+InM0IvmgCPH7Eby
         aadQRpRDS5bh9Oxov/2hYkVKnMvjBeCdPMkoGvP2QjSiBfjiVgP2oELGZz5mis0WUM1j
         JBRbvefeQwKbxtrIMfo1YVzCAjWMMdRTVPFR3PcAs98fCxpM2jdK3kfU10ilBObn+ZYO
         6zB20DUSIDDHFAvj+zArK9NeYIK5Cd3HOlPWE19IOWWAixpxl0H4EPzLUh7CNjoU6mjN
         hlKNQbZvdvnFstzF1mqlalevaI3izKfADcwI9fP4wIzpjEv2EGaQQHW3Eop7Q1GpA0b5
         85Yw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=9AnPluum9emnS2pkPK+6WBXOIKMuMp9QQ4T5u86wsh8=;
        b=jgtTjtGHKaqTlqCF8Tn4mpAQ+qvWMyTEW7GaJNY4piaOE4hNsIPWQfCqgq/U/0yctD
         ALVK6ipJZDyPiiYe4ylVKVZF0zDWUqwKVv8Xcrz+IAczBb+yyzrIkhG7na0AbIYzLW9a
         lNgirtBlA4Y4jLKruUwX9podKSoPuPYuRvw4IMXVb+xqifThaJZDzygOtd6+HLbXtTkR
         MUszmgo6Me4BGlFbSihgRrY3uReax8vtU/TVVtYivVdMzeIHziMUFh8/hRzheZtjZ+rW
         I7TXyT7ER161Jm/r1A9qoHN+WYLiGWz7CpUJ94WBcNkZpKJt57K3FVzvsJ0GYkTsD9mr
         /X8Q==
X-Gm-Message-State: AElRT7H9GNPHMt32ArKY0WvPi8ad5ziM6lV2YJGmGLRTm29UPyoB0+xW
	XDIgoKNr4nlZ+ZbcCNzPjMZbDw==
X-Google-Smtp-Source: AG47ELsENbcjxdt9iqr1TGP5Y1iQlcGp0SkkHMJh6rxtcJyNxa7st3RfwJdW6DxgtLYkDq1mTbllMQ==
X-Received: by 10.101.88.3 with SMTP id g3mr47032pgr.48.1520940406356;
        Tue, 13 Mar 2018 04:26:46 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.99.106.135 with SMTP id f129ls3342927pgc.1.gmail; Tue, 13 Mar
 2018 04:26:44 -0700 (PDT)
X-Received: by 10.98.108.2 with SMTP id h2mr251374pfc.43.1520940404631;
        Tue, 13 Mar 2018 04:26:44 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1520940404; cv=none;
        d=google.com; s=arc-20160816;
        b=AyLwaM2QG8XqbOVjxIQaBEFMcNVhlaqVoS7KLFQHmLNMDbiawpnZK0fBsdXFmBHSNh
         GXN9avZsHYoye+wmc9K2eoybk9Gywe2cqVWVssp2QapyYcV2tKO5XfOO9O2hDNyDbjlm
         q9NA0vVRfbULXbWMjUMwfwxvruOUln+0VYQEIhtiw7qyCRvVs7f/18FkDb1seJXWSDKu
         V+i2Ep7wd87CsuiXCkbXv2PdzzMrSvRkFpceDmt29iR8svsmM00dEXd5VvWXhmUADkoJ
         sGZxub5Avqt5sAUIkFSeYviopZF5KeylogUTKamoHVivYdL4DP0G1JKPrX7cBSo6o0EE
         vC2w==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=cA/LwjtQcM1fkAxoaBcr5tFrExhxWDWRVo9+RIIRGNA=;
        b=IRBG8GV1Ve0cqGram58Nk4jJdrLMg5Upt426GQjcgUxUQ9AAY1x73n55/tqk1sIU0Y
         ge25/ivSZrJ+Ikl6jFFEL7egU6/qvkc5M7meYBKcBjOFTdaGGbQNQmiBXgKGRhkOoCL3
         xQ9AU0UyZQJdHSwqqJFW13BxE3v5X7dED2O9Rac8Qg6MJ+DbS5lfeGFPVuHOqpQM8j6e
         8TXx3D66++nDayulczmjIzIH4GFg4+NUBoXhMkFh8Jt1J+YKZYMWYvgm42kubGffo2ey
         Kzwzfu79/Z2bziDpPWDr5KuFiK7aecIVII45z9z5kGezzZlskMF3C6dzFJzwMrUlVxR1
         sjWA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=knohT2F9;
       spf=pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=gasper.azman@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id j185sor25940pgc.286.2018.03.13.04.26.44
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Tue, 13 Mar 2018 04:26:44 -0700 (PDT)
Received-SPF: pass (google.com: domain of gasper.azman@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 10.99.122.80 with SMTP id j16mr207021pgn.5.1520940403903; Tue,
 13 Mar 2018 04:26:43 -0700 (PDT)
Original-Received: by 10.236.133.141 with HTTP; Tue, 13 Mar 2018 04:26:23 -0700 (PDT)
In-Reply-To: <CANiq72kNstxnyLTCOBfNorEiyudTijCAUHwH4DsoT14WqcNs4w@mail.gmail.com>
X-Original-Sender: gasper.azman@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=knohT2F9;       spf=pass
 (google.com: domain of gasper.azman@gmail.com designates 209.85.220.65 as
 permitted sender) smtp.mailfrom=gasper.azman@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=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:37320
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37320>

--f403045c5a2a7fd11405674988bb
Content-Type: text/plain; charset="UTF-8"

But my point was we *already have* an operator with the exact semantics of
the macro above - it's just a gnu extension. We could just propose that!

https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html

x = x?:new int;

It's unambiguous, it's obvious it's a conditional, it'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's also not
a weird new form of || or |.

It also fails to compile if "x" and the expression if x is falsy don't have
a common type, which is *also* important.

So, I'd encourage the author of this proposal to instead propose the gnu
extension as an actual feature, instead of trying to fit a "don't evaluate
this" model as a special case for just certain types - making user-defined
types less like built-in types is an explicit no-no these days, and this
proposal is just trying to special-case pointers.

G


On Mon, Mar 12, 2018 at 11:41 AM, Miguel Ojeda <
miguel.ojeda.sandonis@gmail.com> wrote:

> On Mon, Mar 12, 2018 at 11:42 AM, Richard Hodges <hodges.r@gmail.com>
> wrote:
> >
> > Consider:
> >
> > p |= new_thing();
> >
> > In the above code, do we mean that we wish to replace p with a new thing
> if
> > empty, or does it mean that we wish to merge a new thing into the object
> > referenced by p?
>
> For me ||= would be the replace. But since we don't have ||=, I just
> picked |=, which indeed looks fishy.
>
> Now, what would be a nice experiment would be ||, &&, ||= and &&= with
> short-circuit semantics, which could be implemented if we had the
> "expression E" stuff:
>
>     template <typename T, expression E>
>     operator||=(T & t, E)
>     {
>         if (t)
>             return;
>         t = E;
>     }
>
> Then:
>
>     x ||= new int;
>
> would have the expected results.
>
> Cheers,
> Miguel
>
> --
> 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/CANiq72kNstxnyLTCOBfNorEiyudTi
> jCAUHwH4DsoT14WqcNs4w%40mail.gmail.com.
>

-- 
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/CAANG%3DkWjgCt-%2BpKOwWk6BgwNZ9ZECd9twWwq_FC1f3WPEiNw%3DA%40mail.gmail.com.

--f403045c5a2a7fd11405674988bb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">But my point was we *already have* an operator with the ex=
act 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/online=
docs/gcc/Conditionals.html" target=3D"_blank">https://gcc.gnu.org/<wbr>onli=
nedocs/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 i=
t&#39;s a conditional, it&#39;s a one-liner, and more importantly, it can b=
e 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><div>It also fails to compile if &quot;x&quot; an=
d the expression if x is falsy don&#39;t have a common type, which is *also=
* important.</div><div><br></div><div>So, I&#39;d encourage the author of t=
his proposal to instead propose the gnu extension as an actual feature, ins=
tead of trying to fit a &quot;don&#39;t evaluate this&quot; model as a spec=
ial case for just certain types - making user-defined types less like built=
-in types is an explicit no-no these days, and this proposal is just trying=
 to special-case pointers.</div><div><br></div><div>G</div><div><br></div><=
/div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Mon, Mar =
12, 2018 at 11:41 AM, Miguel Ojeda <span dir=3D"ltr">&lt;<a href=3D"mailto:=
miguel.ojeda.sandonis@gmail.com" target=3D"_blank">miguel.ojeda.sandonis@gm=
ail.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 class=
=3D"">On Mon, Mar 12, 2018 at 11:42 AM, Richard Hodges &lt;<a href=3D"mailt=
o:hodges.r@gmail.com">hodges.r@gmail.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 class=3D""><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 class=3D""><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"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-propo=
sals+unsubscribe@<wbr>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>
</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"noreferrer" target=3D"_blank=
">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/<w=
br>CANiq72kNstxnyLTCOBfNorEiyudTi<wbr>jCAUHwH4DsoT14WqcNs4w%40mail.<wbr>gma=
il.com</a>.<br>
</blockquote></div><br></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/CAANG%3DkWjgCt-%2BpKOwWk6BgwNZ9ZECd9t=
wWwq_FC1f3WPEiNw%3DA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoote=
r">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkWj=
gCt-%2BpKOwWk6BgwNZ9ZECd9twWwq_FC1f3WPEiNw%3DA%40mail.gmail.com</a>.<br />

--f403045c5a2a7fd11405674988bb--

.
