220 20723 <mtud36$9s3$1@ger.gmane.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Null -conditional and -coalescing operators
Date: Wed, 23 Sep 2015 10:31:02 -0400
Lines: 64
Approved: news@gmane.org
Message-ID: <mtud36$9s3$1@ger.gmane.org>
References: <4c3e2ee7-2159-4e93-a439-7d5c94c38c9c@isocpp.org> <6a0ad653-4764-483b-afb5-74d444be15d9@isocpp.org> <09547076-d049-4d87-acc3-b851e6518942@isocpp.org> <2242837.lDbo80ytWE@tjmaciei-mobl4>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1443018691 10469 80.91.229.3 (23 Sep 2015 14:31:31 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 23 Sep 2015 14:31:31 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBBOHPRKYAKGQEQ57NTVQ@isocpp.org Wed Sep 23 16:31:23 2015
Return-path: <std-proposals+bncBC37LBFWUIFBBOHPRKYAKGQEQ57NTVQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f71.google.com ([209.85.215.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC37LBFWUIFBBOHPRKYAKGQEQ57NTVQ@isocpp.org>)
	id 1Zel4r-00028j-PH
	for gclcip-std-proposals@m.gmane.org; Wed, 23 Sep 2015 16:31:21 +0200
Original-Received: by lamf6 with SMTP id f6sf24536724lam.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 23 Sep 2015 07:31:21 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:to:from:subject:date:lines:message-id:references
         :mime-version:content-type:user-agent:in-reply-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=YB0xka66GtbwtSW1PaRUe6+vtVAT4fgUXh61q4kQeS8=;
        b=aNG2K3OwPTUAvzcL9vx511EkT8n9vlYPZL5xNKYwfxZKuZVJwljQXIEgDukLmZIqqT
         8uMQD8v/c4KKKgQ6I5VgsHj5bwNvXo2+4pmG1Ge9wSRuyiYi5npmQSwN5NpERc61HKBT
         kEla1kdjD15xyokd1+Y1bmsiTbxMqiJwFtN2So6jjRTlqVFQDvZY3nF+/t+NpJhOlQjk
         TQgHg3ujGUA/6+U8JSlybxvxIontBWJU7qmoYzIpQAw7y7d8gkxh+/RcuOq2sei8kGyz
         KuqkQYv+016fXWldLHkgozveRbYXF6YzWsUhb3kZ54KD/haICfTKz6Y1SHIi233Gd17P
         
X-Gm-Message-State: ALoCoQldWaM0emF0SwIR4+MozzwhsMU0f5+zdsFYZiDhk0VkFFLV90306aeyJFBoW2ktm+FD+JxW
X-Received: by 10.195.18.100 with SMTP id gl4mr5376308wjd.4.1443018681178;
        Wed, 23 Sep 2015 07:31:21 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.20.229 with SMTP id q5ls38921lae.17.gmail; Wed, 23 Sep
 2015 07:31:18 -0700 (PDT)
X-Received: by 10.25.29.85 with SMTP id d82mr4009849lfd.25.1443018678062;
        Wed, 23 Sep 2015 07:31:18 -0700 (PDT)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id y10si3986196lay.136.2015.09.23.07.31.17
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Wed, 23 Sep 2015 07:31:17 -0700 (PDT)
Received-SPF: pass (google.com: domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as permitted sender) client-ip=80.91.229.3;
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1Zel4g-0001wb-Mm
	for std-proposals@isocpp.org; Wed, 23 Sep 2015 16:31:10 +0200
Original-Received: from tripoint.kitware.com ([66.194.253.20])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Wed, 23 Sep 2015 16:31:10 +0200
Original-Received: from mwoehlke.floss by tripoint.kitware.com with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Wed, 23 Sep 2015 16:31:10 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 55
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: tripoint.kitware.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To: <2242837.lDbo80ytWE@tjmaciei-mobl4>
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as
 permitted sender) smtp.mailfrom=gclcip-std-proposals@m.gmane.org;
       dmarc=fail (p=NONE 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: <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:20723
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20723>

On 2015-09-23 02:06, Thiago Macieira wrote:
> On Tuesday 22 September 2015 10:38:58 joewoodbury@gmail.com wrote:
>> Thus if I wrote
>>
>> int val = connection ?: 5;
>>
>> your solution wouldn't work.
> 
> Assuming that connection was a pointer here, you'd get an error about 
> assigning a pointer to an integer.
> 
> The ?: syntax with the missing second operand already has a precedent to mean 
> a repeat of the first operand. Therefore, the above reads:
> 
> int val = connection ? connection : 5;
> 
> However, I would like to see the syntax standardised. When you're dealing with 
> C code that returns error conditions, this is useful:
> 
> 	ErrorCode err = some_function();
> 	err = err ?: some_other_function();
> 	err = err ?: some_third_function();

  err || err = some_other_function();

:-)

(I've actually written code like that. Pedantically, I think it was of
the form 'success && ...', but same idea...)

> I'm not going to ask for, but it would be nice to have
> 
> 	err ?:= some_function();

....or, as in my reply, '?!(err) = some_function();'; tacking '?' / '?:'
/ '?!' on to other operator tokens makes me nervous ;-). I too think it
would be nice to have, but don't see it being sufficiently nice as to
actually be accepted as a proposal.

Actually... hmm...

  #define iff(var) \
    for (auto _guard = true; _guard;) \
      for (auto&& _var = var; _guard && bool{_var}; _guard = false) \
        _var
  #define ifn(var) \
    for (auto _guard = true; _guard;) \
      for (auto&& _var = var; _guard && !bool{_var}; _guard = false) \
        _var

  iff(object)->method();
  ifn(err) = some_function();

-- 
Matthew

-- 

--- 
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/.

.
