220 19239 <d8e0f792-23ba-4555-9910-00bd87d6e1ca@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vlad from Moscow <vlad.moscow@mail.ru>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Overloading std::begin and std::end for std::pair
Date: Fri, 24 Jul 2015 06:10:03 -0700 (PDT)
Lines: 380
Approved: news@gmane.org
Message-ID: <d8e0f792-23ba-4555-9910-00bd87d6e1ca@isocpp.org>
References: <012fd35d-96fd-4775-835e-2105176c4f97@isocpp.org>
 <e61080cb-ca1f-4426-a6be-4618ffe88cfe@isocpp.org>
 <792fab39-5af7-4d95-b9ba-a5cc4aed8544@isocpp.org>
 <8100167.A1Y3soRlXn@tjmaciei-mobl4>
 <15e678b3-9b6b-4966-a7a5-1d37495fda5e@isocpp.org>
 <CAMSC8GNY-CQ+=nD59acZ6-qWbmNK5Fh2JjOHOq6ekxeeG3Lmdg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_686_1349645481.1437743403415"
X-Trace: ger.gmane.org 1437743414 21277 80.91.229.3 (24 Jul 2015 13:10:14 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 24 Jul 2015 13:10:14 +0000 (UTC)
Cc: sasha2048@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXLLRHD7IDRBLHSZCWQKGQERU5DDHQ@isocpp.org Fri Jul 24 15:10:13 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBLHSZCWQKGQERU5DDHQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f197.google.com ([209.85.220.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBLHSZCWQKGQERU5DDHQ@isocpp.org>)
	id 1ZIcjm-0005Re-46
	for gclcip-std-proposals@m.gmane.org; Fri, 24 Jul 2015 15:10:06 +0200
Original-Received: by qkez4 with SMTP id z4sf33637518qke.2
        for <gclcip-std-proposals@m.gmane.org>; Fri, 24 Jul 2015 06:10:05 -0700 (PDT)
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:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=7UULmMkUXEtYn3pU6xRqp9VEm7H8RNQX13T1eUdujvE=;
        b=jJq8ofi8E0D8BJBmgkU/zcFLkPu6SQqMlDl7aAtih/nBD6gJeug6QHvtDN6NsZVzWe
         klRWgtod36df6ugnjhCLAqY+9yHSMho5kxFw1M9dzpJN+9KJAN4Huea6bBCVP0e7huxV
         uWWczlfpNAChzZpejYwuxB2mMZH1E5BI6OkUYRdVN4j83N85C3SG0fHK8ZjooViJiWRm
         qNsKqAhkmXuLXr72e2XFPxuZwqEyUyr1WITUy2OqyJ3uOogX8JEV2I0H8YVoH6l1ZZgY
         H3aM2SpNP4h1ITVhAD1EHftHC/tL+VRREAao24MyvpxcXizS58lxMl1ZQ4d2RBQobo3z
         BBrg==
X-Gm-Message-State: ALoCoQnaimZABzWbHW1bA1qgc1XoXkxKmQmhsFVZ7iQMOMSVIjkgEk9im83uJbdAl6yUmoGN15eq
X-Received: by 10.129.98.69 with SMTP id w66mr14059131ywb.13.1437743405436;
        Fri, 24 Jul 2015 06:10:05 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.101.150 with SMTP id u22ls1568504qge.85.gmail; Fri, 24 Jul
 2015 06:10:04 -0700 (PDT)
X-Received: by 10.140.82.85 with SMTP id g79mr169659qgd.35.1437743404235;
        Fri, 24 Jul 2015 06:10:04 -0700 (PDT)
In-Reply-To: <CAMSC8GNY-CQ+=nD59acZ6-qWbmNK5Fh2JjOHOq6ekxeeG3Lmdg@mail.gmail.com>
X-Original-Sender: vlad.moscow@mail.ru
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:19239
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19239>

------=_Part_686_1349645481.1437743403415
Content-Type: multipart/alternative; 
	boundary="----=_Part_687_1594186586.1437743403416"

------=_Part_687_1594186586.1437743403416
Content-Type: text/plain; charset=UTF-8



On Friday, July 24, 2015 at 3:50:58 PM UTC+3, Sasha Unknown wrote:
>
> To T. C. and Sean Middleditch: Thank you for you patience. While I 
> don't like the this proposal of Vlad from Moscow for many reasons, I 
> appreciate patience and level of detail in your responses. At some 
> point in future these patience and detail-level may save some good but 
> ugly-looking proposal. 
>
> To Vlad from Moscow: 
> 1. Just to satisfy my interest: Aren't you coming to C++ from some 
> dynamically-typed language? 
> 2. If n2995 and/or D4128 would be accepted, they will satisfy all your 
> requests: 
>     for ( auto x : std::make_range( a + 3, a + 7 ) ) ...; 
>     for ( auto p : m.equal_range( 'A' ) ) ...; 
>
>
It seems you do not understand. There is no any need to build a 
superconstruction or to deform algorithms that to do this in clear and 
natural way.

The C++ Standard already has all needed to do the task.  And if you have a 
pair of iterators that make up a range then why do you need to build a 
range from already existent valid range?! Simply write

    for ( auto x : p ) ...; 

There is such principle KISS in programming that means Keep It Simple 
Stupid.

The programmer should not pay for what he totally need not.

What you are suggesting looks the following way. I have a notebook. You 
come to my home take away my notebook and say: "Pay me and i will give you 
a notebook". And after I paid you return me my notebook.

Excelent idea!




On Fri, Jul 24, 2015 at 10:36 AM, Vlad from Moscow <vlad....@mail.ru 
> <javascript:>> wrote: 
> > 
> > 
> > On Friday, July 24, 2015 at 1:58:22 AM UTC+3, Thiago Macieira wrote: 
> >> 
> >> On Thursday 23 July 2015 12:31:59 Vlad from Moscow wrote: 
> >> > Could you explain why do I need some ranges when this program looks 
> >> > clear 
> >> > and nice without any ranges? 
> >> 
> >> Because you made it so that std::pair<T, T> is always a range, but that 
> >> isn't 
> >> the case. In fact, I'd argue that most people who think of "iterating" 
> >> over a 
> >> pair expect it to behave as an array of two elements: the first and the 
> >> second. 
> >> 
> > 
> > There is a serious logical mistake. If for example two pointers can make 
> up 
> > a range this does not mean that any two pointers is a range or that any 
> > range is two pointers. Even two iterators of the same container or two 
> > pointers of the same array might not make a range. 
> > 
> > std::pair is simply a media that can store iterators. It is used in 
> > algorithm std::mismatch where iterators does not make up a range or in 
> the 
> > algorithm or class methods  equal_range where pointers make up a range. 
> > 
> > It is a responsibility of the programmer to use appropriate iterators 
> that 
> > are stored in the media. 
> > 
> > So you and Sean Middleditch attempts to substitute the meaning of 
>  std::pair 
> > for the role like just ranges are false and confuse programmers. 
> > It is responsibility of the programmer to correctly use std::pair in 
> > different situations. 
> > 
> > With the same success you can use any valid C++ construction 
> incorrectly. 
> > For example you can return a reference to a local variable of a 
> function. 
> > Does it mean that something wrong with references and the programmers 
> shall 
> > not declare function return types as references? 
> > 
> > According to your false logic it follows that the programmers indeed 
> shall 
> > not declare function return types as references 
> > 
> > The ptoblem is why should the programmer pay for the means that he 
> totally 
> > need not? 
> > 
> > I showed already an example with std::multimap where the code looks 
> clear 
> > and nice. But you are saying: "Stop! Programs must not be so clear and 
> nice. 
> > You have to declare a class hierarchy and use these additional classes 
> to do 
> > a simple and entirely correct thing." 
> > 
> > Why do the programmer have to use a suoerstructure when he already has a 
> > range that he stored on such a media like std::pair? 
> > 
> > And moreover now Sean Middleditch is even going to deform standard 
> > algorithms with the only purpose that all programmers used his useless 
> > superstructures where all can be done simply and clear without them. 
> > 
> > 
> >> I'd expect: 
> >> 
> >> template<typename T> const T* begin(const pair<T, T> &p) 
> >> { return &p.first; } 
> >> 
> >> template<typename T> const T *end(const pair<T, T> &p) 
> >> { return &p.second + 1; } 
> >> 
> >> Which allows me to run: 
> >> 
> >> int main() 
> >> { 
> >>         for (auto i : std::make_pair(1, 2)) 
> >>                 cout << i << ' '; 
> >>         cout << endl; 
> >> } 
> >> 
> >> output: 1 2 
> >> -- 
> >> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org 
> >>    Software Architect - Intel Open Source Technology Center 
> >>       PGP/GPG: 0x6EF45358; fingerprint: 
> >>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358 
> >> 
> > -- 
> > 
> > --- 
> > 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-proposal...@isocpp.org <javascript:>. 
> > To post to this group, send email to std-pr...@isocpp.org <javascript:>. 
>
> > Visit this group at 
> > http://groups.google.com/a/isocpp.org/group/std-proposals/. 
>

-- 

--- 
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_687_1594186586.1437743403416
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Friday, July 24, 2015 at 3:50:58 PM UTC+3, Sash=
a Unknown wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px =
0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border=
-left-width: 1px; border-left-style: solid;">To T. C. and Sean Middleditch:=
 Thank you for you patience. While I
<br>don&#39;t like the this proposal of Vlad from Moscow for many reasons, =
I
<br>appreciate patience and level of detail in your responses. At some
<br>point in future these patience and detail-level may save some good but
<br>ugly-looking proposal.
<br>
<br>To Vlad from Moscow:
<br>1. Just to satisfy my interest: Aren&#39;t you coming to C++ from some
<br>dynamically-typed language?
<br>2. If n2995 and/or D4128 would be accepted, they will satisfy all your =
requests:
<br>=C2=A0 =C2=A0 for ( auto x : std::make_range( a + 3, a + 7 ) ) ...;
<br>=C2=A0 =C2=A0 for ( auto p : m.equal_range( &#39;A&#39; ) ) ...;
<br>
<br></blockquote><div><br></div><div>It seems you do not understand. There =
is no any need to=C2=A0build a superconstruction or to deform algorithms th=
at to do this in clear and natural way.</div><div><br></div><div>The C++ St=
andard already has all=C2=A0needed to do the task.=C2=A0 And if you have a =
pair of iterators that make up a range then why do you need to build a rang=
e from already existent valid range?! Simply write</div><div><br></div><div=
>=C2=A0=C2=A0=C2=A0 for ( auto=C2=A0x :=C2=A0p ) ...; </div><div><br></div>=
<div>There is such principle KISS in programming that means Keep It Simple =
Stupid.</div><div><br></div><div>The=C2=A0programmer should not pay for wha=
t he totally need not.</div><div><br></div><div>What you are suggesting loo=
ks the following way. I have a notebook. You come to my home take away my n=
otebook and say: &quot;Pay me and i will give you a notebook&quot;. And aft=
er I paid you=C2=A0return me my notebook.</div><div><br></div><div>Excelent=
 idea!</div><div><br></div><div><br></div><div><br></div><div><br></div><bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-=
left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; b=
order-left-style: solid;">On Fri, Jul 24, 2015 at 10:36 AM, Vlad from Mosco=
w &lt;<a onmousedown=3D"this.href=3D&#39;javascript:&#39;;return true;" onc=
lick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=3D"javascript:=
" target=3D"_blank" rel=3D"nofollow">vlad....@mail.ru</a>&gt; wrote:
<br>&gt;
<br>&gt;
<br>&gt; On Friday, July 24, 2015 at 1:58:22 AM UTC+3, Thiago Macieira wrot=
e:
<br>&gt;&gt;
<br>&gt;&gt; On Thursday 23 July 2015 12:31:59 Vlad from Moscow wrote:
<br>&gt;&gt; &gt; Could you explain why do I need some ranges when this pro=
gram looks
<br>&gt;&gt; &gt; clear
<br>&gt;&gt; &gt; and nice without any ranges?
<br>&gt;&gt;
<br>&gt;&gt; Because you made it so that std::pair&lt;T, T&gt; is always a =
range, but that
<br>&gt;&gt; isn&#39;t
<br>&gt;&gt; the case. In fact, I&#39;d argue that most people who think of=
 &quot;iterating&quot;
<br>&gt;&gt; over a
<br>&gt;&gt; pair expect it to behave as an array of two elements: the firs=
t and the
<br>&gt;&gt; second.
<br>&gt;&gt;
<br>&gt;
<br>&gt; There is a serious logical mistake. If for example two pointers ca=
n make up
<br>&gt; a range this does not mean that any two pointers is a range or tha=
t any
<br>&gt; range is two pointers. Even two iterators of the same container or=
 two
<br>&gt; pointers of the same array might not make a range.
<br>&gt;
<br>&gt; std::pair is simply a media that can store iterators. It is used i=
n
<br>&gt; algorithm std::mismatch where iterators does not make up a range o=
r in the
<br>&gt; algorithm or class methods =C2=A0equal_range where pointers make u=
p a range.
<br>&gt;
<br>&gt; It is a responsibility of the programmer to use appropriate iterat=
ors that
<br>&gt; are stored in the media.
<br>&gt;
<br>&gt; So you and Sean Middleditch attempts to substitute the meaning of =
=C2=A0std::pair
<br>&gt; for the role like just ranges are false and confuse programmers.
<br>&gt; It is responsibility of the programmer to correctly use std::pair =
in
<br>&gt; different situations.
<br>&gt;
<br>&gt; With the same success you can use any valid C++ construction incor=
rectly.
<br>&gt; For example you can return a reference to a local variable of a fu=
nction.
<br>&gt; Does it mean that something wrong with references and the programm=
ers shall
<br>&gt; not declare function return types as references?
<br>&gt;
<br>&gt; According to your false logic it follows that the programmers inde=
ed shall
<br>&gt; not declare function return types as references
<br>&gt;
<br>&gt; The ptoblem is why should the programmer pay for the means that he=
 totally
<br>&gt; need not?
<br>&gt;
<br>&gt; I showed already an example with std::multimap where the code look=
s clear
<br>&gt; and nice. But you are saying: &quot;Stop! Programs must not be so =
clear and nice.
<br>&gt; You have to declare a class hierarchy and use these additional cla=
sses to do
<br>&gt; a simple and entirely correct thing.&quot;
<br>&gt;
<br>&gt; Why do the programmer have to use a suoerstructure when he already=
 has a
<br>&gt; range that he stored on such a media like std::pair?
<br>&gt;
<br>&gt; And moreover now Sean Middleditch is even going to deform standard
<br>&gt; algorithms with the only purpose that all programmers used his use=
less
<br>&gt; superstructures where all can be done simply and clear without the=
m.
<br>&gt;
<br>&gt;
<br>&gt;&gt; I&#39;d expect:
<br>&gt;&gt;
<br>&gt;&gt; template&lt;typename T&gt; const T* begin(const pair&lt;T, T&g=
t; &amp;p)
<br>&gt;&gt; { return &amp;p.first; }
<br>&gt;&gt;
<br>&gt;&gt; template&lt;typename T&gt; const T *end(const pair&lt;T, T&gt;=
 &amp;p)
<br>&gt;&gt; { return &amp;p.second + 1; }
<br>&gt;&gt;
<br>&gt;&gt; Which allows me to run:
<br>&gt;&gt;
<br>&gt;&gt; int main()
<br>&gt;&gt; {
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (auto i : std::make_pair(1, 2)=
)
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cout &=
lt;&lt; i &lt;&lt; &#39; &#39;;
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 cout &lt;&lt; endl;
<br>&gt;&gt; }
<br>&gt;&gt;
<br>&gt;&gt; output: 1 2
<br>&gt;&gt; --
<br>&gt;&gt; Thiago Macieira - thiago (AT) <a onmousedown=3D"this.href=3D&#=
39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz=
\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=
=3D"this.href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.in=
fo\46sa\75D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;ret=
urn true;" href=3D"http://macieira.info" target=3D"_blank" rel=3D"nofollow"=
>macieira.info</a> - thiago (AT) <a onmousedown=3D"this.href=3D&#39;http://=
www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AF=
QjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D=
&#39;http://www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\075=
1\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" href=3D"htt=
p://kde.org" target=3D"_blank" rel=3D"nofollow">kde.org</a>
<br>&gt;&gt; =C2=A0 =C2=A0Software Architect - Intel Open Source Technology=
 Center
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 PGP/GPG: 0x6EF45358; fingerprint:
<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0 E067 918B B660 DBD1 105C =C2=A0966C 33F5 =
F005 6EF4 5358
<br>&gt;&gt;
<br>&gt; --
<br>&gt;
<br>&gt; ---
<br>&gt; You received this message because you are subscribed to the Google=
 Groups
<br>&gt; &quot;ISO C++ Standard - Future Proposals&quot; group.
<br>&gt; To unsubscribe from this group and stop receiving emails from it, =
send an
<br>&gt; email to <a onmousedown=3D"this.href=3D&#39;javascript:&#39;;retur=
n true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;" href=3D=
"javascript:" target=3D"_blank" rel=3D"nofollow">std-proposal...@isocpp.org=
</a>.
<br>&gt; To post to this group, send email to <a onmousedown=3D"this.href=
=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascri=
pt:&#39;;return true;" href=3D"javascript:" target=3D"_blank" rel=3D"nofoll=
ow">std-pr...@isocpp.org</a>.
<br>&gt; Visit this group at
<br>&gt; <a onmousedown=3D"this.href=3D&#39;http://groups.google.com/a/isoc=
pp.org/group/std-proposals/&#39;;return true;" onclick=3D"this.href=3D&#39;=
http://groups.google.com/a/isocpp.org/group/std-proposals/&#39;;return true=
;" href=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/" targ=
et=3D"_blank" rel=3D"nofollow">http://groups.google.com/a/isocpp.org/group/=
std-proposals/</a>.
<br></blockquote></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_687_1594186586.1437743403416--
------=_Part_686_1349645481.1437743403415--

.
