220 15319 <136dcbcc-7fff-4e30-9852-5554cc743a42@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Andy Prowl <andy.prowl@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Isn't it time we had the bool
 std::[container]::contains() family of methods?
Date: Fri, 26 Dec 2014 07:19:48 -0800 (PST)
Lines: 114
Approved: news@gmane.org
Message-ID: <136dcbcc-7fff-4e30-9852-5554cc743a42@isocpp.org>
References: <0959f2f8-acdd-4786-b6f3-0f05c62dcee6@isocpp.org>
 <2df86492-548f-42c8-86d6-fe1c8ba3a5a9@isocpp.org>
 <2f390ec3-b259-4150-9771-cd0d02860348@isocpp.org>
 <3743ebda-3367-4fc3-922a-f38d98e57889@isocpp.org>
 <1bccb2dd-4aa4-4f07-8958-b1d6bf092630@isocpp.org>
 <CAA7U3HMcBab8xEJU7w_r3d4cQa8d-DYwVw4BxnsHM_UjyfjAmg@mail.gmail.com>
 <46cc4da5-98d1-471f-ab31-714ac5502853@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_4284_597702032.1419607188992"
X-Trace: ger.gmane.org 1419607198 30416 80.91.229.3 (26 Dec 2014 15:19:58 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 26 Dec 2014 15:19:58 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCG63E4DYQKRBFPZ6WSAKGQE4OGZLAI@isocpp.org Fri Dec 26 16:19:51 2014
Return-path: <std-proposals+bncBCG63E4DYQKRBFPZ6WSAKGQE4OGZLAI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f70.google.com ([209.85.220.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCG63E4DYQKRBFPZ6WSAKGQE4OGZLAI@isocpp.org>)
	id 1Y4WgB-00007d-9T
	for gclcip-std-proposals@m.gmane.org; Fri, 26 Dec 2014 16:19:51 +0100
Original-Received: by mail-pa0-f70.google.com with SMTP id eu11sf80604914pac.9
        for <gclcip-std-proposals@m.gmane.org>; Fri, 26 Dec 2014 07:19:50 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=GjtXA92npPv/lFhomPuQQVzVdG9j5yBpbNOIKbY8o1c=;
        b=N4hQFn715VLhrLMiAOXbkVRocSrklnssFMc1YqhHXxyK32DRHkYTmKQl4k3gdHz+z3
         uZTbMyqLeyS3rK3ocNd9lv3mh9JIdiFDGNZVcPK/We/Sgi9Ts+TFkupgtoIpAAETsist
         6UyYwjzMmrLCNyC3yhfgKxFrOSWP2FhK2qT1t1R/Afuv7v2/Zb62Jo7F9i80s6iEr8o+
         idnDwTclJxGpux0EMa2VY7wtcfcYQeleyFLtPc7as1weJVs13nuG2oC4EGKcCWSXkjvm
         xBwmC/PGCgmL3dxWJIKDJlqwcoJ8sWeztT42U13PSaysZ424Vzrp45QsRMXygSHuKtTt
         E2kQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=GjtXA92npPv/lFhomPuQQVzVdG9j5yBpbNOIKbY8o1c=;
        b=a8ICxPOHdSeCdVcPsWv3ZSUn3COlz+DKZSsat2Hb2+5XwuUsGmSrpjnlekU614lc2m
         PfftVdKJv0N2pbbYYwRiO4EEeArRDxkdroseICOIkRII24SMe6PJBC4m7tlgwWHXUO1k
         FiNcvKqz8euks1kv8JtmoPgVaEXzJT/t1Ypu55oXxAehwJJFZy0ylaH9Ffr29R3989AI
         L5wAFAC2fgxi87vFIIWLvQjPjqkqbV2/Mp1k5QKxeGztUSOUcMxPwgQZeO/5XCp81XpE
         x9SOGXBXmtemPH07cgBZ54282r9HFKcQO3DsOdWBxQscqvBNKgj9ICZQgDOTJHvbLacc
         Yr8A==
X-Gm-Message-State: ALoCoQmuBZeBSJ95xhp2z49s43rB63EXq/fLAOzly6Fjv1k3njZSq01vMvM018PLBbCotzMtNp6E
X-Received: by 10.66.181.136 with SMTP id dw8mr32910194pac.27.1419607190186;
        Fri, 26 Dec 2014 07:19:50 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.29.7 with SMTP id a7ls4463086qga.87.gmail; Fri, 26 Dec
 2014 07:19:49 -0800 (PST)
X-Received: by 10.140.94.150 with SMTP id g22mr749239qge.0.1419607189287;
        Fri, 26 Dec 2014 07:19:49 -0800 (PST)
In-Reply-To: <46cc4da5-98d1-471f-ab31-714ac5502853@isocpp.org>
X-Original-Sender: andy.prowl@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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:15319
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/15319>

------=_Part_4284_597702032.1419607188992
Content-Type: multipart/alternative; 
	boundary="----=_Part_4285_1797034805.1419607188992"

------=_Part_4285_1797034805.1419607188992
Content-Type: text/plain; charset=UTF-8

On Friday, December 26, 2014 2:31:42 PM UTC+1, Leo Heinsaar wrote:
>
> On Friday, December 26, 2014 4:50:15 PM UTC+4, Olaf van der Spek wrote:
>>
>> On Fri, Dec 26, 2014 at 10:30 AM, Leo Heinsaar <leohe...@gmail.com> 
>> wrote: 
>>
>> How is it less typing? Auto-complete? 
>>
>
> Since we'll be able to simply write
>
> *phone_book.contains(number)*
>
> instead of:
>
> *phone_book.find(number) != phone_book.end()*
>
> Not to mention how much more clearly the simplified version, as they like 
> to call it, expresses intent.
>

I think Olaf meant to ask what is the advantage of the v.contains(x) syntax 
over the contains(v, x) syntax in terms of typing. In fact, there is not 
much of an advantage apart from auto-completion (as Olaf suggests). 

IMO we shouldn't focus much on minimizing the amount of *typing*: it is not 
*that* important for code to be easy to write as it is to be easy to read. 
We read and reason about code much more frequently than we write it, and 
constantly aiming for the least number of keystrokes is not a good practice 
and it does not help reasoning about the result of our typing (see the 
several discussions on intent-revealing names, small extracted functions, 
etc.).

This said, there are situations where the dot notation would make code easy 
to read (not sure this is one of them though), e.g. when composing 
algorithms that work on ranges. This is why I think it is worth considering 
UFCS proposals. As a side-effect, this would bring us more flexibility (and 
possibly more consistency) in choosing the best syntax for function calls.

Kind regards,

Andy

-- 

--- 
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/.

------=_Part_4285_1797034805.1419607188992
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, December 26, 2014 2:31:42 PM UTC+1, Leo Heinsaa=
r wrote:<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">On Fr=
iday, December 26, 2014 4:50:15 PM UTC+4, Olaf van der Spek wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1p=
x #ccc solid;padding-left:1ex">On Fri, Dec 26, 2014 at 10:30 AM, Leo Heinsa=
ar &lt;<a>leohe...@gmail.com</a>&gt; wrote:
<br><br>How is it less typing? Auto-complete?
<br></blockquote><div><br></div><div>Since we'll be able to simply write</d=
iv><blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px"><div><b>=
phone_book.contains(number)</b></div></blockquote><div><span style=3D"font-=
size:13px">instead of:</span></div><blockquote style=3D"margin:0 0 0 40px;b=
order:none;padding:0px"><div><span style=3D"font-size:13px"><b>phone_book.f=
ind(number) !=3D phone_book.end()</b></span></div></blockquote><div>Not to =
mention how much more clearly the simplified version, as they like to call =
it, expresses intent.</div></div></blockquote><div><br>I think Olaf meant t=
o ask what is the advantage of the v.contains(x) syntax over the contains(v=
, x) syntax in terms of typing. In fact, there is not much of an advantage =
apart from auto-completion (as Olaf suggests). <br><br>IMO we shouldn't foc=
us much on minimizing the amount of <i>typing</i>: it is not <i>that</i> im=
portant for code to be easy to write as it is to be easy to read. We read a=
nd reason about code much more frequently than we write it, and constantly =
aiming for the least number of keystrokes is not a good practice and it doe=
s not help reasoning about the result of our typing (see the several discus=
sions on intent-revealing names, small extracted functions, etc.).<br><br>T=
his said, there are situations where the dot notation would make code easy =
to read (not sure this is one of them though), e.g. when composing algorith=
ms that work on ranges. This is why I think it is worth considering UFCS pr=
oposals. As a side-effect, this would bring us more flexibility (and possib=
ly more consistency) in choosing the best syntax for function calls.<br><br=
>Kind regards,<br><br>Andy</div></div>

<p></p>

-- <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+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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_4285_1797034805.1419607188992--
------=_Part_4284_597702032.1419607188992--

.
