220 37292 <05da71c2-80cf-63dd-b2c6-8cd342db5140@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Jefferson Carpenter <jeffersoncarpenter2@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Pointer overload for ||
Date: Sun, 11 Mar 2018 04:40:05 -0500
Lines: 47
Approved: news@gmane.org
Message-ID: <05da71c2-80cf-63dd-b2c6-8cd342db5140@gmail.com>
References: <1fea07df-46a6-4df2-865a-849be8f8d129@isocpp.org>
 <CAANG=kVsGNaXGZLtbNm=9cJxjLXwu0cgL=p_kYa1TCRSKfNCvg@mail.gmail.com>
 <CAANG=kUmThSamFisncxMCaqFd6Ze7GWH-q+TjMn4YfFTn2T8+w@mail.gmail.com>
 <CALmDwq3powZ_ytSPztv=Zz-TryE1jcDwDsDhtoABggvcFeJK+g@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1520761094 31159 195.159.176.226 (11 Mar 2018 09:38:14 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 11 Mar 2018 09:38:14 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:52.0) Gecko/20100101
 Thunderbird/52.6.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDMNDCNA64OBB6XSSPKQKGQE6I3YBLY@isocpp.org Sun Mar 11 10:38:10 2018
Return-path: <std-proposals+bncBDMNDCNA64OBB6XSSPKQKGQE6I3YBLY@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+bncBDMNDCNA64OBB6XSSPKQKGQE6I3YBLY@isocpp.org>)
	id 1euxQg-0007xE-Gn
	for gclcip-std-proposals@m.gmane.org; Sun, 11 Mar 2018 10:38:10 +0100
Original-Received: by mail-it0-f69.google.com with SMTP id w194-v6sf6561711itc.1
        for <gclcip-std-proposals@m.gmane.org>; Sun, 11 Mar 2018 01:40:17 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1520761211; cv=pass;
        d=google.com; s=arc-20160816;
        b=oqvyo2S3+MpHqt2CX2/WK6Wc//fL1Ok+7BnTgyiZeqpC82iWKma/ZjAadahnyXwWRL
         srAaS3rCv0P35HLGx1641xOkPRCXm/YnT6+60ohkNIRu4C3vEkuxTZuspPXcFdhuziEW
         kvotjwPPC5g5yOiJ1uaFTXVC8fbe2n6QaNbtqdwvepdRfnfTonHknmowyIbo/r8N14j/
         kX1L2rbPeJY1haoNG6tiTj55uaDqooPr3yYXaRT/uTGhuR7MEM9UB/JNneESAPtnsylm
         yyebfWxOiKXCMmIR/DZe5ignMtsAtlnXqKwTYyDM67GMi/7pxIsKCK0yHV+zq7nd3A8t
         Ov5Q==
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:content-language
         :in-reply-to:mime-version:user-agent:date:message-id:from:references
         :to:subject:arc-authentication-results:arc-message-signature
         :dkim-signature:arc-authentication-results;
        bh=yTehU8QVogyUb17uACw6EwGsia85ZKQqpaelQobpBpg=;
        b=Bd8cmICxQsFZ+6RuQ4uHWM8wIENXW7WWsg+u+J/X3ILLEA3nL7PGKP/Lz8dBnNRtLf
         VJBJN3Fj8Ph5bN1NoMdLYs5VuGXGq6PrdahB4yw/ivawvFUYDiZrbFWsTqkG6MskeKIj
         d1dwc2N6K/nv02Eb3M25ary/tiI1YWn4hfogPcu4+NYN+lR0ArpRDDF5O0J+/ES19mCo
         HYg7Haxx+qlwar64wOuE7QbJu8RYDpy5qSXKiyH88srE/Nm5AG7kNFEiKNO82GrCjQga
         8+O1K2jB9x8jB2O636wd9V5Ec/isk1nKFAHknAPslqOfyZWw8irZs/F2ytOHEtYF12pE
         1oxQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=btsZ68oD;
       spf=pass (google.com: domain of jeffersoncarpenter2@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jeffersoncarpenter2@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=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-language: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=yTehU8QVogyUb17uACw6EwGsia85ZKQqpaelQobpBpg=;
        b=jztIEliNNC4BybUsR3EJtB4Od6rXMDM4366nyt3Lehe0i7vqeyyQCtYiGw03N355DA
         p2HYRX9eWQxUm3xSPObFNyKPVvHaICSEoBi8e57MNhV6DTSlbzAR6z6Za7q3CRkGeItu
         o0GDeG/ZaBK++toiBBTrF7bMaqirrv0m8ifFg6vCc1u/FDsXJdbEGmVMDvx7KqPPG4p9
         /VpwWw6Y1VXBMADxkBbo9thE+ewb9bIZLmPq42TOYogT0oegDQuCUJaYbKjPMOGkzLeO
         jgnEyQnLjd5/hHp4azaqWbsC1JtJN96ZbKWh9WaU5/72AGSVnhOEbe3rgrdfvD9H1VpN
         /gzg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :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=yTehU8QVogyUb17uACw6EwGsia85ZKQqpaelQobpBpg=;
        b=l+65CRWHEdhNMagVnMl65fexjJ6s7QDsM6vtDDPoILg78JcKLDZeEYw6KRBv4s09pt
         jT2HoMXHgbVnPFWTHOkWkQ9lTBIFhtIjoIY47/HlxXRofcT4ogMbyoERimvzl22LuUtF
         CFR+79Nw9ON4ID23GvWqsQjZwCgpM2HHQ5Lp5XtJN4L8kKcRXWTBMwa/EWXbyNsJY6HA
         ZS7xcH7OI3F631uFb3wnrRUT/h/U95ppPHg6VkjmnzHmmhUqb5rszC4/0v4oqdG3Lf90
         1+NaYVrVwK07Z0l8xt/O0n5rSgRxO+0X7BXC/etIec29kX8GDEIORu0EPIEZKk7bOLv5
         / 
X-Gm-Message-State: AElRT7ECKYFLXyKYEReo3cbOvmIBaLAvKHUEDdkG68J1dgs+8TDfk9GH
	IfFJKXGT/mcARjJyAmOEuMr+JA==
X-Google-Smtp-Source: AG47ELvTXPZrQFHXq+qFONnZpOKZYrujf95RG64jHZ6AykSOZzOBM0k3fct0kc5aNVYa8OzU2Jxc5A==
X-Received: by 10.36.41.200 with SMTP id p191mr2442226itp.22.1520761211697;
        Sun, 11 Mar 2018 01:40:11 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.81.11 with SMTP id f11ls254630iob.13.gmail; Sun, 11 Mar
 2018 01:40:10 -0800 (PST)
X-Received: by 10.107.63.68 with SMTP id m65mr5151795ioa.195.1520761210483;
        Sun, 11 Mar 2018 01:40:10 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1520761210; cv=none;
        d=google.com; s=arc-20160816;
        b=w3pEoNrZME5D5qL+uPDTIZBvs4DBQfWa0pu2wEG3MthbalcB3YdRDAVFLkq9j31nF4
         la8ue7JjOxivRat4SbG/ZkvsR8oVxG2k2PQZaHFdJ2G5Hv2uFiI+Vmb+Qlu0qOqFF7dN
         wtnwLle6cNQBtIsdFQd9054cz8fHQpKtgt4Edes7QD7mi0333C7LpUu0AL0p2m8FtFY7
         UzQOxwOQLsWZ/4LEmgjYICF4blVb6bVL4FYkTxzt3o9aWc7QG8yWJ9QMdpXxNK3S4lKo
         CiCN9snYs78EfaH60rAGO3XR7d/W7WQo+pTjGkcx2DvrjVevFBqnTwmFzTBd1qyrlK6I
         K/Lw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :dkim-signature:arc-authentication-results;
        bh=DWb+EkxkvFVK/gRHJrJH6EFZYk5cZA3I8b5PnwXdwmg=;
        b=sUyWjkbXqwCwEvrM/7XQf/eG5J0TITyqrEjLiepHdFwy6Ze42jBmQfJNUEdDlgg4Kh
         pbb+W9KXhwjUZsNQ1J3lIJFjAyc3X8kRPHvmZsbTzn1aNdJ0o6QB3XUxDpNJXcztGPWi
         /fVxKdt6cwXBo/RvVaZ3KoIkifmiBlt8JlFBZDklmgTx+pqDxiBl7ExwxZDz4Ur1dplV
         wzczr4pqAjDpSB0rgxyNWdozjoJOHtyYxPpuNeVm+CZHdzo13352IOlKJMlMTAsk0+lr
         D6wFvvvHGw9NoXDVTCVjZQoh8CujoQFYxydKuyqR+cLbLFTw2DkFH6vg9NqH4wxl4MWW
         mfQA==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=btsZ68oD;
       spf=pass (google.com: domain of jeffersoncarpenter2@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=jeffersoncarpenter2@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id 22sor1325391itj.105.2018.03.11.01.40.10
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sun, 11 Mar 2018 01:40:10 -0800 (PST)
Received-SPF: pass (google.com: domain of jeffersoncarpenter2@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.36.51.138 with SMTP id k132mr4326809itk.48.1520761209914;
        Sun, 11 Mar 2018 01:40:09 -0800 (PST)
Original-Received: from ?IPv6:2601:441:8680:4631:ecd0:a4aa:6a04:1146? ([2601:441:8680:4631:ecd0:a4aa:6a04:1146])
        by smtp.gmail.com with ESMTPSA id n132sm1236015itn.28.2018.03.11.01.40.08
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 11 Mar 2018 01:40:09 -0800 (PST)
In-Reply-To: <CALmDwq3powZ_ytSPztv=Zz-TryE1jcDwDsDhtoABggvcFeJK+g@mail.gmail.com>
Content-Language: en-US
X-Original-Sender: jeffersonCarpenter2@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=btsZ68oD;       spf=pass
 (google.com: domain of jeffersoncarpenter2@gmail.com designates 209.85.220.41
 as permitted sender) smtp.mailfrom=jeffersoncarpenter2@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:37292
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37292>

On 3/11/2018 4:16 AM, Nicolas Lesser wrote:
 > I don't see the point. How is your if not succinct?
 >
 > if (!ptr)
 >      ptr = new int;

Yeah, I guess the if statement is good enough.  I agree, there's no need 
to add the python- or ruby-like form of the if statement.

BTW the only reason I was hesitant to use the ternary operator, "ptr = 
ptr ? ptr : new int", is just because you would need to write ptr three 
times, yuck.

However, the ternary operator does have the simple advantage over the if 
statement that you can use it at the expression level.

 > Also that inverted logic has a high chance of confusing anyone who comes
 > across it, and it some cases, it is not even clear which or operator you
 > choose.
 >
 > var = var || allocate();
 >
 > If allocate doesn't return a pointer, but a boolean (or due to a refactor
 > it changes) then the expression above would no longer do the right thing:
 > assign 1 to var if either expression is true, which is not expected.

I don't know precisely what you mean by "inverted" logic, but I don't 
agree that it would necessarily confuse anyone who comes across it - it 
would just be unfamiliar syntax, which they would look up.  It's true 
that the expression would compile regardless of whether allocate() 
returns a bool or a pointer, which could cause a surprising bug due to 
implicit pointer-to-bool conversion, but I don't feel like that's very 
likely, or that it would be very likely that a refactor would cause a 
problem there either.  Specifically if your allocate() is changed from 
returning a pointer to returning a bool during a refactor, its signature 
would change in other ways that would cause a compile error there, i.e. 
taking a reference to the pointer to allocate as an argument instead of 
returning it.

Jefferson Carpenter

-- 
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/05da71c2-80cf-63dd-b2c6-8cd342db5140%40gmail.com.

.
