220 20792 <mu1md4$pgf$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: Thu, 24 Sep 2015 16:28:20 -0400
Lines: 63
Approved: news@gmane.org
Message-ID: <mu1md4$pgf$1@ger.gmane.org>
References: <4c3e2ee7-2159-4e93-a439-7d5c94c38c9c@isocpp.org> <CANPtknyyW8iV=ANeHpHvmZxS_mpxHPWcgEmCa4wLf+RugN2xDw@mail.gmail.com> <mu11oa$vmq$1@ger.gmane.org> <ef9b670a-512e-4911-a39e-40a814cf68ba@isocpp.org>
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 1443126537 26574 80.91.229.3 (24 Sep 2015 20:28:57 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 24 Sep 2015 20:28:57 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBB7NZSGYAKGQERN6EPAY@isocpp.org Thu Sep 24 22:28:48 2015
Return-path: <std-proposals+bncBC37LBFWUIFBB7NZSGYAKGQERN6EPAY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f70.google.com ([209.85.215.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC37LBFWUIFBB7NZSGYAKGQERN6EPAY@isocpp.org>)
	id 1ZfD8J-0008CH-6K
	for gclcip-std-proposals@m.gmane.org; Thu, 24 Sep 2015 22:28:47 +0200
Original-Received: by lacao8 with SMTP id ao8sf34749227lac.3
        for <gclcip-std-proposals@m.gmane.org>; Thu, 24 Sep 2015 13:28:46 -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=a+kNTTlFbNoyBvAyhlICJOiZPs6vW+b4NSUkFRCYCo4=;
        b=CqtGWPEterF+5bi435bbJIUihLr1yLmaYmBfJjjSQp6TD9BPD9V9wHK9sf6auMK0qJ
         CXwdkrnutXJx1WDi3qE2HRmtd/MWOk2kVt3n9mc3u2TYILSjy8QTpcRxlcUmYngPQSXY
         ewCOGUq7K1NhUa9iLzMKJf07F3IROd/bhCQPbgq0wURrMcDOpBRb+1gfIm9Bi6WBHG9L
         rPSTk+yXBCeY5zqDTktTK+q3mWZfBy+ixeneyhLqImZB3fZoD8wHz92MnIwPaP94t99+
         ph6yy/GUaxe+4vqFlvSn9LnCL+zyYUtuyclErtxFHQoQAjNkc3FuiU4LgsVezebsD2PL
         
X-Gm-Message-State: ALoCoQl/9s/B33Nu7RFRf9kbimvoeFOFxe0Jhs7r1taOlqvwyZBtGMlrNHRLmppvLVP/tZkG/CG9
X-Received: by 10.112.55.69 with SMTP id q5mr256076lbp.24.1443126526186;
        Thu, 24 Sep 2015 13:28:46 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.8.130 with SMTP id r2ls112829laa.87.gmail; Thu, 24 Sep
 2015 13:28:45 -0700 (PDT)
X-Received: by 10.152.5.170 with SMTP id t10mr462679lat.112.1443126525078;
        Thu, 24 Sep 2015 13:28:45 -0700 (PDT)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id p3si14910lae.174.2015.09.24.13.28.45
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Thu, 24 Sep 2015 13:28:45 -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 1ZfD8D-00085C-Lu
	for std-proposals@isocpp.org; Thu, 24 Sep 2015 22:28:41 +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>; Thu, 24 Sep 2015 22:28:41 +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>; Thu, 24 Sep 2015 22:28:41 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 54
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: <ef9b670a-512e-4911-a39e-40a814cf68ba@isocpp.org>
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:20792
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20792>

On 2015-09-24 15:51, Nicol Bolas wrote:
> On Thursday, September 24, 2015 at 10:36:06 AM UTC-4, Matthew Woehlke wrote:
>> written += ?(stream)->write(buffer);
> 
> That brings up a question. Namely... what does that actually do?

As previously explained:

  auto&& __temp = stream;
  if (__temp) written += ?(__temp)->write(buffer);

Yes, the fact that you may have to backtrack on the statement when you
see '?()' is atrocious. I didn't say I'd actually *vote* for the feature
:-).

> What I mean is this: `?(stream)->write(buffer)` is an expression. What type 
> does it resolve to?

Same as 'stream->write(buffer)'. The effect of '?()' applies to the
entire statement.

> So if the condition is false, what does the overall expression resolve to?
> [...] does the condition being false completely wipe out the entire statement. 

Yes.

> That is, even the += is part of the condition. If so, that requires 
> look-ahead. Potentially *lots* of look-ahead.

And yes. As I said, I realize it's ugly. While I think it would be a
useful feature to have, I'd have a hard time actually supporting such a
proposal.

> ?: makes it clear exactly what's going on:
> 
> written += stream ? stream->write(buffer) : 0;

....and, at least for POD types, compilers can hopefully optimize this to
the same code, anyway. The main places where '?(expr)' would be useful
are where 'expr' is complex. Such cases are not likely to be common,
however, and the benefits not likely worth the problems.

>> (I'll note that part of the motivation here probably comes from wanting 
>> to dodge draconian coding styles that mandate multiline braces around 
>> ANY conditional body. Which, I'll be honest, I've done myself... 
>> employed ugly hacks to dodge such, I mean; I personally loathe requiring 
>> braces in single-statement conditional bodies.) 
> 
> That's a pretty poor motivation for a language feature.

Oh, agreed :-). I didn't mean to imply otherwise.

-- 
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/.

.
