Topic: Overloading of the family of numeric


Author: Sam Kellett <samkellett@gmail.com>
Date: Sat, 3 Oct 2015 16:12:49 +0100
Raw View
--001a11c342eea66d1d052134b66f
Content-Type: text/plain; charset=UTF-8

On 3 October 2015 at 15:44, Nicol Bolas <jmckesson@gmail.com> wrote:

> On Saturday, October 3, 2015 at 10:35:47 AM UTC-4, Vlad from Moscow wrote:
>>
>> On Saturday, October 3, 2015 at 5:16:53 PM UTC+3, Nicol Bolas wrote:
>>>
>>> On Saturday, October 3, 2015 at 4:35:08 AM UTC-4, Vlad from Moscow wrote:
>>>>
>>>> It is a wrong point of view. I am not trying to do ywo operations. I am
>>>> delegating this work to stoi.
>>>>
>>>
>>> And why should stoi be concerned with *anything* but converting a
>>> string to an integer? Why should it be concerned with offsetting the
>>> initial position of that string by some value first?
>>>
>>> These funtions already are designed specially for std::string.
>>
>
> And that is 99% of what is *wrong* with those functions.
>

>
[snip]
>

> If you pass an integer to a function, I have to look up its documentation
> to find out what it's doing. That's not "more clear" to me.
>

this is even more confusing when it's a function that does something with
integers... am i passing in a default value if it fails? or a base that the
input is in? etc, etc..?

--

---
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/.

--001a11c342eea66d1d052134b66f
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 3=
 October 2015 at 15:44, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"mailto=
:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</span> =
wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=3D"=
">On Saturday, October 3, 2015 at 10:35:47 AM UTC-4, Vlad from Moscow wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Saturday, Octo=
ber 3, 2015 at 5:16:53 PM UTC+3, Nicol Bolas wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-co=
lor:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div di=
r=3D"ltr">On Saturday, October 3, 2015 at 4:35:08 AM UTC-4, Vlad from Mosco=
w 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"><div dir=3D"ltr"><div>It is a wrong point of view.=
 I am not trying to do ywo operations. I am delegating this work to stoi.</=
div></div></blockquote><div><br>And why should stoi be concerned with <i>an=
ything</i> but converting a string to an integer? Why should it be concerne=
d with offsetting the initial position of that string by some value first?<=
br><br></div></div></blockquote><div>These funtions already are designed sp=
ecially for=C2=A0std::string.</div></div></blockquote></span><div><br>And t=
hat is 99% of what is <i>wrong</i> with those functions.<br></div></blockqu=
ote><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb=
(204,204,204);padding-left:1ex" class=3D"gmail_quote"><div>=C2=A0</div></bl=
ockquote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div></div><div>=
[snip] <br></div></blockquote><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:=
1ex"><div></div><div><br>If you pass an integer to a function, I have to lo=
ok up its documentation to find out what it&#39;s doing. That&#39;s not &qu=
ot;more clear&quot; to me.<br></div></blockquote><div><br></div><div>this i=
s even more confusing when it&#39;s a function that does something with int=
egers... am i passing in a default value if it fails? or a base that the in=
put is in? etc, etc..? <br></div></div></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 />

--001a11c342eea66d1d052134b66f--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sat, 3 Oct 2015 08:29:38 -0700 (PDT)
Raw View
------=_Part_1845_1197542104.1443886178641
Content-Type: multipart/alternative;
 boundary="----=_Part_1846_1984983373.1443886178641"

------=_Part_1846_1984983373.1443886178641
Content-Type: text/plain; charset=UTF-8


On Saturday, October 3, 2015 at 6:12:52 PM UTC+3, Sam Kellett wrote:
>
> On 3 October 2015 at 15:44, Nicol Bolas <jmck...@gmail.com <javascript:>>
> wrote:
>
>> On Saturday, October 3, 2015 at 10:35:47 AM UTC-4, Vlad from Moscow wrote:
>>>
>>> On Saturday, October 3, 2015 at 5:16:53 PM UTC+3, Nicol Bolas wrote:
>>>>
>>>> On Saturday, October 3, 2015 at 4:35:08 AM UTC-4, Vlad from Moscow
>>>> wrote:
>>>>>
>>>>> It is a wrong point of view. I am not trying to do ywo operations. I
>>>>> am delegating this work to stoi.
>>>>>
>>>>
>>>> And why should stoi be concerned with *anything* but converting a
>>>> string to an integer? Why should it be concerned with offsetting the
>>>> initial position of that string by some value first?
>>>>
>>>> These funtions already are designed specially for std::string.
>>>
>>
>> And that is 99% of what is *wrong* with those functions.
>>
>
>>
> [snip]
>>
>
>> If you pass an integer to a function, I have to look up its documentation
>> to find out what it's doing. That's not "more clear" to me.
>>
>
> this is even more confusing when it's a function that does something with
> integers... am i passing in a default value if it fails? or a base that the
> input is in? etc, etc..?
>

Oh, yes of course!:) s.find_first_of( "0123456789" ) evidently supplies the
default value.

And what will you say about such functions like substr, append etc or for
example s.find( 'A', pos )? I am sure it is very difficult to
understand what pos means in the find. Is it a default value in the case if
the find  will not find 'A'? What do you think about this?:)

--

---
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_1846_1984983373.1443886178641
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br>On Saturday, October 3, 2015 at 6:12:52 PM UTC+3, Sam Kellett wrote:<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;"><div dir=3D"ltr"><div><div class=3D"gmail_quote">=
On 3 October 2015 at 15:44, Nicol Bolas <span dir=3D"ltr">&lt;<a onmousedow=
n=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.href=
=3D&#39;javascript:&#39;;return true;" href=3D"javascript:" target=3D"_blan=
k" rel=3D"nofollow" gdf-obfuscated-mailto=3D"wrCpNb86CwAJ">jmck...@gmail.co=
m</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 2=
04); border-left-width: 1px; border-left-style: solid;"><span>On Saturday, =
October 3, 2015 at 10:35:47 AM UTC-4, Vlad from Moscow wrote:<blockquote cl=
ass=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;"><div dir=3D"ltr">On Saturday, October 3, 2015 at 5:16:53 PM =
UTC+3, Nicol Bolas 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;"><div dir=3D"ltr">On S=
aturday, October 3, 2015 at 4:35:08 AM UTC-4, Vlad from Moscow wrote:<block=
quote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-lef=
t: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bord=
er-left-style: solid;"><div dir=3D"ltr"><div>It is a wrong point of view. I=
 am not trying to do ywo operations. I am delegating this work to stoi.</di=
v></div></blockquote><div><br>And why should stoi be concerned with <i>anyt=
hing</i> but converting a string to an integer? Why should it be concerned =
with offsetting the initial position of that string by some value first?<br=
><br></div></div></blockquote><div>These funtions already are designed spec=
ially for=C2=A0std::string.</div></div></blockquote></span><div><br>And tha=
t is 99% of what is <i>wrong</i> with those functions.<br></div></blockquot=
e><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; pad=
ding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1=
px; border-left-style: solid;"><div>=C2=A0</div></blockquote><blockquote cl=
ass=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;"><div></div><div>[snip] <br></div></blockquote><blockquote cl=
ass=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;"><div></div><div><br>If you pass an integer to a function, I =
have to look up its documentation to find out what it&#39;s doing. That&#39=
;s not &quot;more clear&quot; to me.<br></div></blockquote><div><br></div><=
div>this is even more confusing when it&#39;s a function that does somethin=
g with integers... am i passing in a default value if it fails? or a base t=
hat the input is in? etc, etc..? <br></div></div></div></div></blockquote><=
div><br></div><div>Oh, yes of course!:)=C2=A0s.find_first_of( &quot;0123456=
789&quot; )=C2=A0evidently supplies the default value.</div><div><br></div>=
<div>And what will you say about such=C2=A0functions like substr, append et=
c=C2=A0or=C2=A0for example s.find( &#39;A&#39;,=C2=A0pos )? I am sure it is=
 very difficult to understand=C2=A0what=C2=A0pos means in the find.=C2=A0Is=
 it=C2=A0a default value in the case if the find=C2=A0=C2=A0will not find &=
#39;A&#39;? What do you think about this?:)</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_1846_1984983373.1443886178641--
------=_Part_1845_1197542104.1443886178641--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Sat, 03 Oct 2015 14:53:56 -0400
Raw View
On Saturday 03 October 2015 11:46:02 Vlad from Moscow wrote:
> > C++ has ways of dealing with functions that need access to a sequence in
> > such a way that does not modify said sequence. We call them "ranges".
> > std::string_view is such a range.
>
> I need not a range. I need just a position.:)

Why do you need a begin pointer and an offset from that begin pointer? Why not
adjust the begin pointer by the offset amount and send only one piece of
information to the function?

--
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-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/.

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sat, 3 Oct 2015 12:02:48 -0700 (PDT)
Raw View
------=_Part_356_53324596.1443898968140
Content-Type: multipart/alternative;
 boundary="----=_Part_357_460438349.1443898968140"

------=_Part_357_460438349.1443898968140
Content-Type: text/plain; charset=UTF-8

I have no begin pointer. I have a string and a position in the string. It
is a disposable operation. I need not to introduce some other entities when
I already have all I need.

On Saturday, October 3, 2015 at 9:54:08 PM UTC+3, Thiago Macieira wrote:
>
> On Saturday 03 October 2015 11:46:02 Vlad from Moscow wrote:
> > > C++ has ways of dealing with functions that need access to a sequence
> in
> > > such a way that does not modify said sequence. We call them "ranges".
> > > std::string_view is such a range.
> >
> > I need not a range. I need just a position.:)
>
> Why do you need a begin pointer and an offset from that begin pointer? Why
> not
> adjust the begin pointer by the offset amount and send only one piece of
> information to the function?
>
> --
> 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-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_357_460438349.1443898968140
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I have no=C2=A0begin pointer. I have a string and a positi=
on in the string. It is a disposable operation. I need not to introduce som=
e other entities when I already have all I need.<br><br>On Saturday, Octobe=
r 3, 2015 at 9:54:08 PM UTC+3, Thiago Macieira wrote:<blockquote class=3D"g=
mail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-l=
eft-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: s=
olid;">On Saturday 03 October 2015 11:46:02 Vlad from Moscow wrote:
<br>&gt; &gt; C++ has ways of dealing with functions that need access to a =
sequence in=20
<br>&gt; &gt; such a way that does not modify said sequence. We call them &=
quot;ranges&quot;.=20
<br>&gt; &gt; std::string_view is such a range.
<br>&gt;=20
<br>&gt; I need not a range. I need just a position.:)=20
<br>
<br>Why do you need a begin pointer and an offset from that begin pointer? =
Why not=20
<br>adjust the begin pointer by the offset amount and send only one piece o=
f=20
<br>information to the function?
<br>
<br>--=20
<br>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\46u=
sg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.=
href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\7=
5D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return 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.googl=
e.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJd=
o5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;http=
://www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" href=3D"http://kde.o=
rg" target=3D"_blank" rel=3D"nofollow">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>=C2=A0 =C2=A0 =C2=A0 PGP/GPG: 0x6EF45358; fingerprint:
<br>=C2=A0 =C2=A0 =C2=A0 E067 918B B660 DBD1 105C =C2=A0966C 33F5 F005 6EF4=
 5358
<br>
<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_357_460438349.1443898968140--
------=_Part_356_53324596.1443898968140--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Sat, 03 Oct 2015 17:40:26 -0400
Raw View
On Saturday 03 October 2015 12:02:48 Vlad from Moscow wrote:
> I have no begin pointer. I have a string and a position in the string. It
> is a disposable operation. I need not to introduce some other entities when
> I already have all I need.

The string contains a begin pointer.

What's more understandable:

 stoi(str, 16, nullptr, 10);
or
 stoi(str.mid(16), nullptr, 10);
?

Remember code is read more often than it is written. Having the position
clearly marked is a bonus, so you wouldn't misinterpret it as the base.

(I know there's no std::string::mid() function, but that's a deficiency to be
addressed elsewhere and also a bit of a philosophical discussion)
--
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-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/.

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sun, 4 Oct 2015 02:44:03 -0700 (PDT)
Raw View
------=_Part_2255_1217056813.1443951843860
Content-Type: multipart/alternative;
 boundary="----=_Part_2256_899363919.1443951843860"

------=_Part_2256_899363919.1443951843860
Content-Type: text/plain; charset=UTF-8



On Sunday, October 4, 2015 at 12:40:30 AM UTC+3, Thiago Macieira wrote:
>
> On Saturday 03 October 2015 12:02:48 Vlad from Moscow wrote:
> > I have no begin pointer. I have a string and a position in the string.
> It
> > is a disposable operation. I need not to introduce some other entities
> when
> > I already have all I need.
>
> The string contains a begin pointer.
>
> What's more understandable:
>
>         stoi(str, 16, nullptr, 10);
> or
>         stoi(str.mid(16), nullptr, 10);
> ?
>
> Remember code is read more often than it is written. Having the position
> clearly marked is a bonus, so you wouldn't misinterpret it as the base.
>
> (I know there's no std::string::mid() function, but that's a deficiency to
> be
> addressed elsewhere and also a bit of a philosophical discussion)
> --
> 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
>
>
This statement

        stoi(str, 16, nullptr, 10);

can be rewritten for example like


        stoi(str, pos, &pos, 10);

But even the original statement is more clear than

        stoi(str.mid(16), nullptr, 10);

because nobody knows what is str.mid

Does it search the middle of the substring starting at position 16 of the
original string?

And moreover it is not necessary that used index is indeed is in the middle
of the string.

--

---
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_2256_899363919.1443951843860
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Sunday, October 4, 2015 at 12:40:30 AM UTC+3, Thiago Macieira wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; p=
adding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width:=
 1px; border-left-style: solid;">On Saturday 03 October 2015 12:02:48 Vlad =
from Moscow wrote:
<br>&gt; I have no begin pointer. I have a string and a position in the str=
ing. It=20
<br>&gt; is a disposable operation. I need not to introduce some other enti=
ties when=20
<br>&gt; I already have all I need.
<br>
<br>The string contains a begin pointer.
<br>
<br>What&#39;s more understandable:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0stoi(str, 16, nullptr, =
10);
<br>or
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0stoi(str.mid(16), nullp=
tr, 10);
<br>?
<br>
<br>Remember code is read more often than it is written. Having the positio=
n=20
<br>clearly marked is a bonus, so you wouldn&#39;t misinterpret it as the b=
ase.
<br>
<br>(I know there&#39;s no std::string::mid() function, but that&#39;s a de=
ficiency to be=20
<br>addressed elsewhere and also a bit of a philosophical discussion)
<br>--=20
<br>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\46u=
sg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.=
href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\7=
5D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return 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.googl=
e.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJd=
o5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;http=
://www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" href=3D"http://kde.o=
rg" target=3D"_blank" rel=3D"nofollow">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>=C2=A0 =C2=A0 =C2=A0 PGP/GPG: 0x6EF45358; fingerprint:
<br>=C2=A0 =C2=A0 =C2=A0 E067 918B B660 DBD1 105C =C2=A0966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote><div><br></div><div>This=C2=A0statement</div><div><br></di=
v><div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0stoi(str, 16, nullpt=
r, 10);=C2=A0<br></div><div><br></div><div>can be rewritten for example lik=
e</div><div><br></div><div>=C2=A0<div>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0stoi(str, pos, &amp;pos, 10);</div><div><br></div><div>But even=
 the original statement is more clear than</div><div>=C2=A0</div><div>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0stoi(str.mid(16), nullptr, 10)=
; </div><div><br>because nobody knows what is str.mid=C2=A0 </div><div><br>=
</div><div>Does it search the middle of the substring starting=C2=A0at posi=
tion 16 of the original string?</div><div><br></div><div>And moreover it is=
 not necessary that used index is indeed is in the middle of the string. </=
div><div><br></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_2256_899363919.1443951843860--
------=_Part_2255_1217056813.1443951843860--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sun, 4 Oct 2015 04:06:51 -0700 (PDT)
Raw View
------=_Part_149_556910045.1443956811298
Content-Type: multipart/alternative;
 boundary="----=_Part_150_1974684460.1443956811298"

------=_Part_150_1974684460.1443956811298
Content-Type: text/plain; charset=UTF-8



On Sunday, October 4, 2015 at 12:40:30 AM UTC+3, Thiago Macieira wrote:
>
> On Saturday 03 October 2015 12:02:48 Vlad from Moscow wrote:
> > I have no begin pointer. I have a string and a position in the string.
> It
> > is a disposable operation. I need not to introduce some other entities
> when
> > I already have all I need.
>
> The string contains a begin pointer.
>
> What's more understandable:
>
>         stoi(str, 16, nullptr, 10);
> or
>         stoi(str.mid(16), nullptr, 10);
> ?
>
> Remember code is read more often than it is written. Having the position
> clearly marked is a bonus, so you wouldn't misinterpret it as the base.
>
> (I know there's no std::string::mid() function, but that's a deficiency to
> be
> addressed elsewhere and also a bit of a philosophical discussion)
> --
> 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
>
>
There is a very simple and efficient method to determine what approach is
more intuitively clear.

Just give a corresponding assignment to a beginner and look how  he will
try to do it.

So if you ask a beginner to output all numbers in a string I assure you
that his approach will look something like the following

#include <iostream>
#include <string>

unsigned long get_number( const std::string &s, std::string::size_type &pos
)
{
    unsigned long value = 0;

    for ( ; s[pos] >= '0' && s[pos] <= '9'; ++pos ) value = 10 * value +
s[pos] - '0';

    return value;
}

int main()
{
    std::string s( "#1, ##2, ###3, ####4, #####5" );
    size_t n = 0;

    for ( std::string::size_type pos = 0; pos != s.size(); )
    {
        if ( s[pos] >= '0' && s[pos] <= '9' )
        {
            std::cout << get_number( s, pos ) << ' ';
            ++n;
        }
        else
        {
            ++pos;
        }
    }

    std::cout << "\nThere are " << n << " numbers in the string" <<
std::endl;
}

The word "remove" or "view" will never in his life come to his head
relative to this assignment. :)

So just substitute get_number for std::stoul specifying in it the second
parameter that defines a position in the string  and you will get very
clear code for programmers of any level of qualification.:)

--

---
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_150_1974684460.1443956811298
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Sunday, October 4, 2015 at 12:40:30 AM UTC+3, Thiago Macieira wr=
ote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; p=
adding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width:=
 1px; border-left-style: solid;">On Saturday 03 October 2015 12:02:48 Vlad =
from Moscow wrote:
<br>&gt; I have no begin pointer. I have a string and a position in the str=
ing. It=20
<br>&gt; is a disposable operation. I need not to introduce some other enti=
ties when=20
<br>&gt; I already have all I need.
<br>
<br>The string contains a begin pointer.
<br>
<br>What&#39;s more understandable:
<br>
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0stoi(str, 16, nullptr, =
10);
<br>or
<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0stoi(str.mid(16), nullp=
tr, 10);
<br>?
<br>
<br>Remember code is read more often than it is written. Having the positio=
n=20
<br>clearly marked is a bonus, so you wouldn&#39;t misinterpret it as the b=
ase.
<br>
<br>(I know there&#39;s no std::string::mid() function, but that&#39;s a de=
ficiency to be=20
<br>addressed elsewhere and also a bit of a philosophical discussion)
<br>--=20
<br>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\46u=
sg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return true;" onclick=3D"this.=
href=3D&#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\7=
5D\46sntz\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag&#39;;return 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.googl=
e.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJd=
o5_JYG1DowztwAHAKs80XSA&#39;;return true;" onclick=3D"this.href=3D&#39;http=
://www.google.com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA&#39;;return true;" href=3D"http://kde.o=
rg" target=3D"_blank" rel=3D"nofollow">kde.org</a>
<br>=C2=A0 =C2=A0Software Architect - Intel Open Source Technology Center
<br>=C2=A0 =C2=A0 =C2=A0 PGP/GPG: 0x6EF45358; fingerprint:
<br>=C2=A0 =C2=A0 =C2=A0 E067 918B B660 DBD1 105C =C2=A0966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote><div><br></div><div>There is a very simple and efficient m=
ethod to determine what approach is more intuitively clear. </div><div><br>=
</div><div>Just give a corresponding assignment to a beginner and look how=
=C2=A0 he will try to do it.</div><div><br></div><div>So if you=C2=A0ask a =
beginner to output all numbers in a string I assure you that his approach w=
ill look something like the following</div><div><br></div><div>#include &lt=
;iostream&gt;<br>#include &lt;string&gt;</div><div><br></div><div>unsigned =
long get_number( const std::string &amp;s, std::string::size_type &amp;pos =
)<br>{<br>=C2=A0=C2=A0=C2=A0 unsigned long value =3D 0;<br>=C2=A0=C2=A0=C2=
=A0 <br>=C2=A0=C2=A0=C2=A0 for ( ; s[pos] &gt;=3D &#39;0&#39; &amp;&amp; s[=
pos] &lt;=3D &#39;9&#39;; ++pos ) value =3D 10 * value + s[pos] - &#39;0&#3=
9;;<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br>=C2=
=A0=C2=A0=C2=A0 return value;<br>}<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 <br>int main()<br>{<br>=C2=A0=C2=A0=C2=A0 std::str=
ing s( &quot;#1, ##2, ###3, ####4, #####5&quot; );<br>=C2=A0=C2=A0=C2=A0 si=
ze_t n =3D 0;<br>=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 for ( std::strin=
g::size_type pos =3D 0; pos !=3D s.size(); )<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if ( s[pos] &gt;=3D &#39;0&#39; &am=
p;&amp; s[pos] &lt;=3D &#39;9&#39; )<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 std::cout &lt;&lt; get_number( s, pos ) &lt;&lt; &#39; &#39;; <br>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ++n;<br>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 else<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 {<br>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ++pos;<br>=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }<br>=C2=A0=C2=A0=C2=A0 }=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 std::cout &lt;&lt;=
 &quot;\nThere are &quot; &lt;&lt; n &lt;&lt; &quot; numbers in the string&=
quot; &lt;&lt; std::endl;<br>}=C2=A0=C2=A0=C2=A0 </div><div><br></div><div>=
The word &quot;remove&quot; or &quot;view&quot; will never in his life come=
 to his head relative to this=C2=A0assignment.=C2=A0:)</div><div><br></div>=
<div>So just substitute get_number for std::stoul=C2=A0specifying in it the=
 second parameter that defines a position in the string =C2=A0and you will =
get very clear code for programmers of any level of qualification.:)</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_150_1974684460.1443956811298--
------=_Part_149_556910045.1443956811298--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 4 Oct 2015 07:18:53 -0700 (PDT)
Raw View
------=_Part_2600_1823252075.1443968333394
Content-Type: multipart/alternative;
 boundary="----=_Part_2601_1337037298.1443968333394"

------=_Part_2601_1337037298.1443968333394
Content-Type: text/plain; charset=UTF-8

On Sunday, October 4, 2015 at 7:06:51 AM UTC-4, Vlad from Moscow wrote:
>
> There is a very simple and efficient method to determine what approach is
> more intuitively clear.
>
>
Just give a corresponding assignment to a beginner and look how  he will
> try to do it.
>

Wait, you said "intuitively clear" at first. Then you switched to talking
about "beginners".

Beginners are beginners precisely *because* they have no experience. And
experience is how you develop *intuition*, and thus how you know what is
"intuitively clear" and what is not.

I'm an experienced C++ programmer, and the code you posted is *mud* to me.
It is by no reasonable definition of the word "clear". It most certainly is
not "intuitively clear". Oh, I can figure out what it's doing by staring at
it for a while.

But it is trash code. You may argue that it's the kind of trash code that a
beginner would write, but that only proves my point: beginners don't know
what clear code looks like.

You're using the wrong standard to evaluate whether code is clear or not.


> So if you ask a beginner to output all numbers in a string I assure you
> that his approach will look something like the following
>

I contest your notion that this is what any beginner would write. Oh, this
is what *some* beginners would write, to be sure. But those beginners would
be beginners at *C programming*, not C++ programming. Even pre-C++11 C++.

Any beginner from one of Bjarne's intro classes would *never* write such
filth (they'd be using iterators). Any beginner who bothered to actually
look at the documentation of std::string would have found string search
functions and would use them. Any beginner who had been paying attention to
C++ at all would avoid such code.

There is a difference between "beginner" and "ignoramus". The programmer
you cite seems to be the latter. And those are *not* programmers we should
cater to.

We should not encourage abusive use of the API. We should not encourage
ignorance or sloth among programmers. We should not add library features
that only cater to C-in-C++-style programmers.

Your suggestion helps nobody but them.

Beginners can learn to properly use the API. Bjarne proves that every year
with his beginning programming classes. They can be trained to use
iterators, ranges, and so forth. We should make these features available,
not for advanced programmers, but for beginners too.

Because beginners are the ones who will make the most mistakes. Just look
at all that code you posted. Few beginners would get that right the first
time. Or second. They'll waste hours trying to figure out where they went
wrong.

Whereas this code is much easier to write and read, and has fewer points
for mistakes:

std::string s = ...;
auto sv = std::string_view(s);

while(true)
{
  auto ix = sv.find_first_of("0123456789");
  if(ix == std::string::npos) break;
  sv = sv.remove_prefix(ix);

  int advance;
  auto value = stoi(sv, &advance);
  sv = sv.remove_prefix(advance);

  std::cout << value << " ";
}

Shorter code. Less places to screw up. This is what beginners *ought* to be
writing. Beginners can learn to do this if you actually teach them the API.

Your way assumes that beginners only know that strings are an array of
characters with a size. My way assumes that beginners know that strings are
objects with actual functions. Your way assumes ignorance and sloth; my way
does not.

Your way leads *inevitably* to brittle code, difficult-to-modify code, and
bad *programmers*. My way encourages the use of robust code, easy-to-modify
code, and good programmers.

So why should we do things your way?

--

---
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_2601_1337037298.1443968333394
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, October 4, 2015 at 7:06:51 AM UTC-4, Vlad from =
Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div>There is a v=
ery simple and efficient method to determine what approach is more intuitiv=
ely clear.<br>=C2=A0</div></blockquote><blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-lef=
t: 1ex;"><div>Just give a corresponding assignment to a beginner and look h=
ow=C2=A0 he will try to do it.=C2=A0</div></blockquote><div><br>Wait, you s=
aid &quot;intuitively clear&quot; at first. Then you switched to talking ab=
out &quot;beginners&quot;.<br><br>Beginners are beginners precisely <i>beca=
use</i> they have no experience. And experience is how you develop <i>intui=
tion</i>, and thus how you know what is &quot;intuitively clear&quot; and w=
hat is not.<br><br>I&#39;m an experienced C++ programmer, and the code you =
posted is <i>mud</i> to me. It is by no reasonable definition of the word &=
quot;clear&quot;. It most certainly is not &quot;intuitively clear&quot;. O=
h, I can figure out what it&#39;s doing by staring at it for a while.<br><b=
r>But it is trash code. You may argue that it&#39;s the kind of trash code =
that a beginner would write, but that only proves my point: beginners don&#=
39;t know what clear code looks like.<br><br>You&#39;re using the wrong sta=
ndard to evaluate whether code is clear or not.<br>=C2=A0</div><blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;"><div></div><div>So if you=C2=A0ask a begin=
ner to output all numbers in a string I assure you that his approach will l=
ook something like the following</div></blockquote><div><br>I contest your =
notion that this is what any beginner would write. Oh, this is what <i>some=
</i> beginners would write, to be sure. But those beginners would be beginn=
ers at <i>C programming</i>, not C++ programming. Even pre-C++11 C++.<br><b=
r>Any beginner from one of Bjarne&#39;s intro classes would <i>never</i> wr=
ite such filth (they&#39;d be using iterators). Any beginner who bothered t=
o actually look at the documentation of std::string would have found string=
 search functions and would use them. Any beginner who had been paying atte=
ntion to C++ at all would avoid such code.<br><br>There is a difference bet=
ween &quot;beginner&quot; and &quot;ignoramus&quot;. The programmer you cit=
e seems to be the latter. And those are <i>not</i> programmers we should ca=
ter to.<br><br>We should not encourage abusive use of the API. We should no=
t encourage ignorance or sloth among programmers. We should not add library=
 features that only cater to C-in-C++-style programmers.<br><br>Your sugges=
tion helps nobody but them.<br><br>Beginners can learn to properly use the =
API. Bjarne proves that every year with his beginning programming classes. =
They can be trained to use iterators, ranges, and so forth. We should make =
these features available, not for advanced programmers, but for beginners t=
oo.<br><br>Because beginners are the ones who will make the most mistakes. =
Just look at all that code you posted. Few beginners would get that right t=
he first time. Or second. They&#39;ll waste hours trying to figure out wher=
e they went wrong.<br><br>Whereas this code is much easier to write and rea=
d, and has fewer points for mistakes:<br><br><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187=
); border-style: solid; border-width: 1px; word-wrap: break-word;"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">string</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> s </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">...;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> sv </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">string_view</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">s</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">whil=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">true</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br>=C2=A0 </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> ix </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> sv</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">find_=
first_of</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot;01234=
56789&quot;</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">if</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">ix </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">string</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">npos</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">break</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><code class=3D"prett=
yprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">sv </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> sv</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">remove_prefix</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify"></span></code>(ix);<br><br>=C2=A0 =
int advance;<br>=C2=A0 auto value =3D stoi(sv, &amp;advance);<br>=C2=A0 sv =
=3D sv.remove_prefix(advance);<br><br>=C2=A0 std</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> value</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify"></span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>&lt;&lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #080;" class=3D"styled-by-prettify">&quot; &qu=
ot;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">}</span></div></code><=
/div><br>Shorter code. Less places to screw up. This is what beginners <i>o=
ught</i> to be writing. Beginners can learn to do this if you actually teac=
h them the API.<br><br>Your way assumes that beginners only know that strin=
gs are an array of characters with a size. My way assumes that beginners kn=
ow that strings are objects with actual functions. Your way assumes ignoran=
ce and sloth; my way does not.<br><br>Your way leads <i>inevitably</i> to b=
rittle code, difficult-to-modify code, and bad <i>programmers</i>. My way e=
ncourages the use of robust code, easy-to-modify code, and good programmers=
..<br><br>So why should we do things your way?<br></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_2601_1337037298.1443968333394--
------=_Part_2600_1823252075.1443968333394--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sun, 4 Oct 2015 08:39:24 -0700 (PDT)
Raw View
------=_Part_2570_1296458142.1443973164807
Content-Type: multipart/alternative;
 boundary="----=_Part_2571_1699344524.1443973164807"

------=_Part_2571_1699344524.1443973164807
Content-Type: text/plain; charset=UTF-8



On Sunday, October 4, 2015 at 5:18:53 PM UTC+3, Nicol Bolas wrote:
>
> On Sunday, October 4, 2015 at 7:06:51 AM UTC-4, Vlad from Moscow wrote:
>>
>> There is a very simple and efficient method to determine what approach is
>> more intuitively clear.
>>
>>
> Just give a corresponding assignment to a beginner and look how  he will
>> try to do it.
>>
>
> Wait, you said "intuitively clear" at first. Then you switched to talking
> about "beginners".
>
> Beginners are beginners precisely *because* they have no experience. And
> experience is how you develop *intuition*, and thus how you know what is
> "intuitively clear" and what is not.
>
> I'm an experienced C++ programmer, and the code you posted is *mud* to
> me. It is by no reasonable definition of the word "clear". It most
> certainly is not "intuitively clear". Oh, I can figure out what it's doing
> by staring at it for a while.
>
> But it is trash code. You may argue that it's the kind of trash code that
> a beginner would write, but that only proves my point: beginners don't know
> what clear code looks like.
>
> You're using the wrong standard to evaluate whether code is clear or not.
>
>
>> So if you ask a beginner to output all numbers in a string I assure you
>> that his approach will look something like the following
>>
>
> I contest your notion that this is what any beginner would write. Oh, this
> is what *some* beginners would write, to be sure. But those beginners
> would be beginners at *C programming*, not C++ programming. Even
> pre-C++11 C++.
>
> Any beginner from one of Bjarne's intro classes would *never* write such
> filth (they'd be using iterators). Any beginner who bothered to actually
> look at the documentation of std::string would have found string search
> functions and would use them. Any beginner who had been paying attention to
> C++ at all would avoid such code.
>
> There is a difference between "beginner" and "ignoramus". The programmer
> you cite seems to be the latter. And those are *not* programmers we
> should cater to.
>
> We should not encourage abusive use of the API. We should not encourage
> ignorance or sloth among programmers. We should not add library features
> that only cater to C-in-C++-style programmers.
>
> Your suggestion helps nobody but them.
>
> Beginners can learn to properly use the API. Bjarne proves that every year
> with his beginning programming classes. They can be trained to use
> iterators, ranges, and so forth. We should make these features available,
> not for advanced programmers, but for beginners too.
>
> Because beginners are the ones who will make the most mistakes. Just look
> at all that code you posted. Few beginners would get that right the first
> time. Or second. They'll waste hours trying to figure out where they went
> wrong.
>
> Whereas this code is much easier to write and read, and has fewer points
> for mistakes:
>
> std::string s = ...;
> auto sv = std::string_view(s);
>
> while(true)
> {
>   auto ix = sv.find_first_of("0123456789");
>   if(ix == std::string::npos) break;
>   sv = sv.remove_prefix(ix);
>
>   int advance;
>   auto value = stoi(sv, &advance);
>   sv = sv.remove_prefix(advance);
>
>   std::cout << value << " ";
> }
>
> Shorter code. Less places to screw up. This is what beginners *ought* to
> be writing. Beginners can learn to do this if you actually teach them the
> API.
>
> Your way assumes that beginners only know that strings are an array of
> characters with a size. My way assumes that beginners know that strings are
> objects with actual functions. Your way assumes ignorance and sloth; my way
> does not.
>
> Your way leads *inevitably* to brittle code, difficult-to-modify code,
> and bad *programmers*. My way encourages the use of robust code,
> easy-to-modify code, and good programmers.
>
> So why should we do things your way?
>

Beginners select a straightforward approach. And even professional
programmers when they encouter a new task first of all try to use those
knoweledge they have that is they select a straightforward approach.

There is no any need to envent new entities if you have already all to
resolve a problem. New things are invented only in case when you can not
resolve a problem.

remove_prefix has nothing common with the problem because the task is not
to remove something in a string. A string with numbers has nor prefix nor
suffix and it shall be unchanged.

So using remove_prefix is simply an invalid idiom for this task.

The task is done simply as the code of a beginner that I showed does.

At first you have to find the position of a number and then extract the
number.  That is all.

To find a position is an immutable operation. To extract a number is also
immutable operation.

What are you going to remove?!

Moreover you even do not see that your code does not make sense because all
what you are doing is inventing new enity string_view just to write

  auto value = stoi(sv, &advance);


instead of

  auto value = stoi( s, pos, &pos );


My congratulations!:)  It is a great achievment in programming!:)




--

---
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_2571_1699344524.1443973164807
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Sunday, October 4, 2015 at 5:18:53 PM UTC+3, Nicol Bolas wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; paddin=
g-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px;=
 border-left-style: solid;"><div dir=3D"ltr">On Sunday, October 4, 2015 at =
7:06:51 AM UTC-4, Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: r=
gb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div>=
There is a very simple and efficient method to determine what approach is m=
ore intuitively clear.<br>=C2=A0</div></blockquote><blockquote class=3D"gma=
il_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;"><div>Just give a corresponding assignment to a beginner and look how=
=C2=A0 he will try to do it.=C2=A0</div></blockquote><div><br>Wait, you sai=
d &quot;intuitively clear&quot; at first. Then you switched to talking abou=
t &quot;beginners&quot;.<br><br>Beginners are beginners precisely <i>becaus=
e</i> they have no experience. And experience is how you develop <i>intuiti=
on</i>, and thus how you know what is &quot;intuitively clear&quot; and wha=
t is not.<br><br>I&#39;m an experienced C++ programmer, and the code you po=
sted is <i>mud</i> to me. It is by no reasonable definition of the word &qu=
ot;clear&quot;. It most certainly is not &quot;intuitively clear&quot;. Oh,=
 I can figure out what it&#39;s doing by staring at it for a while.<br><br>=
But it is trash code. You may argue that it&#39;s the kind of trash code th=
at a beginner would write, but that only proves my point: beginners don&#39=
;t know what clear code looks like.<br><br>You&#39;re using the wrong stand=
ard to evaluate whether code is clear or not.<br>=C2=A0</div><blockquote cl=
ass=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;"><div></div><div>So if you=C2=A0ask a beginner to output all =
numbers in a string I assure you that his approach will look something like=
 the following</div></blockquote><div><br>I contest your notion that this i=
s what any beginner would write. Oh, this is what <i>some</i> beginners wou=
ld write, to be sure. But those beginners would be beginners at <i>C progra=
mming</i>, not C++ programming. Even pre-C++11 C++.<br><br>Any beginner fro=
m one of Bjarne&#39;s intro classes would <i>never</i> write such filth (th=
ey&#39;d be using iterators). Any beginner who bothered to actually look at=
 the documentation of std::string would have found string search functions =
and would use them. Any beginner who had been paying attention to C++ at al=
l would avoid such code.<br><br>There is a difference between &quot;beginne=
r&quot; and &quot;ignoramus&quot;. The programmer you cite seems to be the =
latter. And those are <i>not</i> programmers we should cater to.<br><br>We =
should not encourage abusive use of the API. We should not encourage ignora=
nce or sloth among programmers. We should not add library features that onl=
y cater to C-in-C++-style programmers.<br><br>Your suggestion helps nobody =
but them.<br><br>Beginners can learn to properly use the API. Bjarne proves=
 that every year with his beginning programming classes. They can be traine=
d to use iterators, ranges, and so forth. We should make these features ava=
ilable, not for advanced programmers, but for beginners too.<br><br>Because=
 beginners are the ones who will make the most mistakes. Just look at all t=
hat code you posted. Few beginners would get that right the first time. Or =
second. They&#39;ll waste hours trying to figure out where they went wrong.=
<br><br>Whereas this code is much easier to write and read, and has fewer p=
oints for mistakes:<br><br><div style=3D"border: 1px solid rgb(187, 187, 18=
7); border-image: none; -ms-word-wrap: break-word; background-color: rgb(25=
0, 250, 250);"><code><div><span style=3D"color: rgb(0, 0, 0);">std</span><s=
pan style=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0=
, 0, 136);">string</span><span style=3D"color: rgb(0, 0, 0);"> s </span><sp=
an style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0=
, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">...;</span><span=
 style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(0, 0, =
136);">auto</span><span style=3D"color: rgb(0, 0, 0);"> sv </span><span sty=
le=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0=
);"> std</span><span style=3D"color: rgb(102, 102, 0);">::</span><span styl=
e=3D"color: rgb(0, 0, 0);">string_view</span><span style=3D"color: rgb(102,=
 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">s</span><span style=
=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"=
><br><br></span><span style=3D"color: rgb(0, 0, 136);">while</span><span st=
yle=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 13=
6);">true</span><span style=3D"color: rgb(102, 102, 0);">)</span><span styl=
e=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0=
);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 </span><span st=
yle=3D"color: rgb(0, 0, 136);">auto</span><span style=3D"color: rgb(0, 0, 0=
);"> ix </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><span sty=
le=3D"color: rgb(0, 0, 0);"> sv</span><span style=3D"color: rgb(102, 102, 0=
);">.</span><span style=3D"color: rgb(0, 0, 0);">find_first_of</span><span =
style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 136=
, 0);">&quot;0123456789&quot;</span><span style=3D"color: rgb(102, 102, 0);=
">)<wbr>;</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 </span><spa=
n style=3D"color: rgb(0, 0, 136);">if</span><span style=3D"color: rgb(102, =
102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">ix </span><span styl=
e=3D"color: rgb(102, 102, 0);">=3D=3D</span><span style=3D"color: rgb(0, 0,=
 0);"> std</span><span style=3D"color: rgb(102, 102, 0);">::</span><span st=
yle=3D"color: rgb(0, 0, 136);">string</span><span style=3D"color: rgb(102, =
102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">npos</span><span st=
yle=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(0, 0, 136);">break</span><span style=
=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);">=
<br>=C2=A0 </span><span style=3D"color: rgb(0, 0, 0);"><code><span style=3D=
"color: rgb(0, 0, 0);">sv </span><span style=3D"color: rgb(102, 102, 0);">=
=3D</span><span style=3D"color: rgb(0, 0, 0);"> sv</span><span style=3D"col=
or: rgb(102, 102, 0);">.</span><span style=3D"color: rgb(0, 0, 0);">remove_=
prefix</span><span style=3D"color: rgb(102, 102, 0);"></span></code>(ix);<b=
r><br>=C2=A0 int advance;<br>=C2=A0 auto value =3D stoi(sv, &amp;advance);<=
br>=C2=A0 sv =3D sv.remove_prefix(advance);<br><br>=C2=A0 std</span><span s=
tyle=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, =
0);">cout </span><span style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><s=
pan style=3D"color: rgb(0, 0, 0);"> value</span><span style=3D"color: rgb(1=
02, 102, 0);"></span><span style=3D"color: rgb(0, 0, 0);"> </span><span sty=
le=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span style=3D"color: rgb(0,=
 0, 0);"> </span><span style=3D"color: rgb(0, 136, 0);">&quot; &quot;</span=
><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb=
(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">}</span></d=
iv></code></div><br>Shorter code. Less places to screw up. This is what beg=
inners <i>ought</i> to be writing. Beginners can learn to do this if you ac=
tually teach them the API.<br><br>Your way assumes that beginners only know=
 that strings are an array of characters with a size. My way assumes that b=
eginners know that strings are objects with actual functions. Your way assu=
mes ignorance and sloth; my way does not.<br><br>Your way leads <i>inevitab=
ly</i> to brittle code, difficult-to-modify code, and bad <i>programmers</i=
>. My way encourages the use of robust code, easy-to-modify code, and good =
programmers.<br><br>So why should we do things your way?<br></div></div></b=
lockquote><div><br></div><div>Beginners select a straightforward approach. =
And even professional programmers when they=C2=A0encouter a new task first =
of all try to use those knoweledge they have that is they select a straight=
forward approach.</div><div><br></div><div>There is no any need to envent n=
ew entities if you have already all to resolve a problem. New things are in=
vented only in=C2=A0case when you can not resolve a problem. </div><div><br=
></div><div><span style=3D"color: rgb(0, 0, 0);">remove_prefix has nothing =
common with the problem because the task is not to remove something in a st=
ring. A string with numbers has nor prefix nor suffix and it shall be uncha=
nged. </span></div><div><span style=3D"color: rgb(0, 0, 0);"><br></span></d=
iv><div><span style=3D"color: rgb(0, 0, 0);">So using <span style=3D"color:=
 rgb(0, 0, 0);">remove_prefix is simply an invalid idiom for this task.</sp=
an></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=3D"co=
lor: rgb(0, 0, 0);"><br></span></span></div><div><span style=3D"color: rgb(=
0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);">The task is done simply as =
the code of a beginner that I showed does.</span></span></div><div><span st=
yle=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);"><br></spa=
n></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=3D"col=
or: rgb(0, 0, 0);">At first you have to find the position of a number and t=
hen extract the number.=C2=A0 That is all.</span></span></div><div><span st=
yle=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);"><br></spa=
n></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=3D"col=
or: rgb(0, 0, 0);">To find=C2=A0a position is an immutable operation. To ex=
tract a number is also immutable operation. </span></span></div><div><span =
style=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);"><br></s=
pan></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=3D"c=
olor: rgb(0, 0, 0);">What are you going to remove?!</span></span></div><div=
><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);">=
<br></span></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span sty=
le=3D"color: rgb(0, 0, 0);">Moreover you even do not see that your code doe=
s not=C2=A0make sense because all what you are doing is inventing new enity=
 string_view just to write</span></span></div><div><span style=3D"color: rg=
b(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);"></span></span><span style=
=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);"><br></span><=
/span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color:=
 rgb(0, 0, 0);">=C2=A0 auto value =3D stoi(sv, &amp;advance);</span></span>=
</div><p><br></p><div><font color=3D"#000000">instead of</font></div><div><=
font color=3D"#000000"><br></font></div><div><font color=3D"#000000">=C2=A0=
 auto value =3D stoi( s, pos, &amp;pos );</font></div><p><br></p><font colo=
r=3D"#000000"><div>My congratulations!:)=C2=A0 It is a great achievment in =
programming!:)</div><div><br></div></font><span style=3D"color: rgb(0, 0, 0=
);"><p><br></p><span style=3D"color: rgb(0, 0, 0);"><p><br></p><div><br></d=
iv></span></span>

<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_2571_1699344524.1443973164807--
------=_Part_2570_1296458142.1443973164807--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 4 Oct 2015 09:00:00 -0700 (PDT)
Raw View
------=_Part_2725_571021750.1443974400808
Content-Type: multipart/alternative;
 boundary="----=_Part_2726_1187602539.1443974400808"

------=_Part_2726_1187602539.1443974400808
Content-Type: text/plain; charset=UTF-8

OK, it's clear we're talking past each other at this point. You prefer
C-in-C++ style. You prefer convoluted code that ignores the API and is
"straightforward," as defined by what poorly taught beginning programmers
will tend to write.

The standards committee doesn't agree with you. They prefer ranges to
passing bare integer indices around. They prefer *safe* coding idioms.
Coding idioms that are easy to reason about and modify. Even if they
introduce "new entities" or whatever.

Go ahead and write up a formal proposal if you want. You'll have to fly to
a meeting and defend it, as I rather suspect you'll have a hard time
finding people to defend it for you. And don't be surprised if the first
comment out of the committee is, "why don't you just take a `string_view`?"
And when you try to offer your justifications for your API, don't be
surprised if they find it unconvincing.

--

---
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_2726_1187602539.1443974400808
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">OK, it&#39;s clear we&#39;re talking past each other at th=
is point. You prefer C-in-C++ style. You prefer convoluted code that ignore=
s the API and is &quot;straightforward,&quot; as defined by what poorly tau=
ght beginning programmers will tend to write.<br><br>The standards committe=
e doesn&#39;t agree with you. They prefer ranges to passing bare integer in=
dices around. They prefer <i>safe</i> coding idioms. Coding idioms that are=
 easy to reason about and modify. Even if they introduce &quot;new entities=
&quot; or whatever.<br><br>Go ahead and write up a formal proposal if you w=
ant. You&#39;ll have to fly to a meeting and defend it, as I rather suspect=
 you&#39;ll have a hard time finding people to defend it for you. And don&#=
39;t be surprised if the first comment out of the committee is, &quot;why d=
on&#39;t you just take a `string_view`?&quot; And when you try to offer you=
r justifications for your API, don&#39;t be surprised if they find it uncon=
vincing.<br></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_2726_1187602539.1443974400808--
------=_Part_2725_571021750.1443974400808--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sun, 4 Oct 2015 09:54:49 -0700 (PDT)
Raw View
------=_Part_369_145207507.1443977689852
Content-Type: multipart/alternative;
 boundary="----=_Part_370_1205896253.1443977689853"

------=_Part_370_1205896253.1443977689853
Content-Type: text/plain; charset=UTF-8



On Sunday, October 4, 2015 at 7:00:01 PM UTC+3, Nicol Bolas wrote:
>
> OK, it's clear we're talking past each other at this point. You prefer
> C-in-C++ style. You prefer convoluted code that ignores the API and is
> "straightforward," as defined by what poorly taught beginning programmers
> will tend to write.
>
> The standards committee doesn't agree with you. They prefer ranges to
> passing bare integer indices around. They prefer *safe* coding idioms.
> Coding idioms that are easy to reason about and modify. Even if they
> introduce "new entities" or whatever.
>
> Go ahead and write up a formal proposal if you want. You'll have to fly to
> a meeting and defend it, as I rather suspect you'll have a hard time
> finding people to defend it for you. And don't be surprised if the first
> comment out of the committee is, "why don't you just take a `string_view`?"
> And when you try to offer your justifications for your API, don't be
> surprised if they find it unconvincing.
>

I hope that the C++ Standards Committee is not just you.:)

All what you have written now has nothing common with the discussion.

The redundant and senseless operation remove_prefix  does not make the code
safer.:)

And your words that "They prefer ranges to passing bare integer indices
around" after seeing your code as for example

  auto ix = sv.find_first_of("0123456789");
  if(ix == std::string::npos) break;
  sv = sv.remove_prefix(ix);

  int advance;
  auto value = stoi(sv, &advance);
  sv = sv.remove_prefix(advance);

looks like a joke. :)

Could you say what is ix? Is it an integer?
And what about advance? Oh, I am sorry, it is not an integer, is it ?

In fact your code diifers from the code of a beginner that I showed  only
in one thing: the code of the beginner does not use remove_prefix that you
are uisng twice in one loop

  //...
  sv = sv.remove_prefix(ix);

  int advance;
  auto value = stoi(sv, &advance);
  sv = sv.remove_prefix(advance);
  //...

By the way what about if you need not only to extract numbers but also to
generate a vector of pairs { position, number }?

Will ix in your code correspond to the position in the original string? Or
in this case do you have to rewrite your code entirely?:)



--

---
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_370_1205896253.1443977689853
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Sunday, October 4, 2015 at 7:00:01 PM UTC+3, Nicol Bolas wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; paddin=
g-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px;=
 border-left-style: solid;"><div dir=3D"ltr">OK, it&#39;s clear we&#39;re t=
alking past each other at this point. You prefer C-in-C++ style. You prefer=
 convoluted code that ignores the API and is &quot;straightforward,&quot; a=
s defined by what poorly taught beginning programmers will tend to write.<b=
r><br>The standards committee doesn&#39;t agree with you. They prefer range=
s to passing bare integer indices around. They prefer <i>safe</i> coding id=
ioms. Coding idioms that are easy to reason about and modify. Even if they =
introduce &quot;new entities&quot; or whatever.<br><br>Go ahead and write u=
p a formal proposal if you want. You&#39;ll have to fly to a meeting and de=
fend it, as I rather suspect you&#39;ll have a hard time finding people to =
defend it for you. And don&#39;t be surprised if the first comment out of t=
he committee is, &quot;why don&#39;t you just take a `string_view`?&quot; A=
nd when you try to offer your justifications for your API, don&#39;t be sur=
prised if they find it unconvincing.<br></div></blockquote><div><br></div><=
div>I hope that the C++ Standards Committee is not just you.:)</div><div><b=
r></div><div>All what you have written now has nothing common with the disc=
ussion. </div><div><br></div><div>The redundant and senseless operation rem=
ove_prefix =C2=A0does not make the code safer.:)</div><div><br></div><div>A=
nd your words that &quot;They prefer ranges to passing bare integer indices=
 around&quot; after seeing your code as for example</div><div><br></div><di=
v><font color=3D"#000000">=C2=A0 </font><span style=3D"color: rgb(0, 0, 136=
);">auto</span><span style=3D"color: rgb(0, 0, 0);"> ix </span><span style=
=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);=
"> sv</span><span style=3D"color: rgb(102, 102, 0);">.</span><span style=3D=
"color: rgb(0, 0, 0);">find_first_of</span><span style=3D"color: rgb(102, 1=
02, 0);">(</span><span style=3D"color: rgb(0, 136, 0);">&quot;0123456789&qu=
ot;</span><span style=3D"color: rgb(102, 102, 0);">)<wbr>;</span><span styl=
e=3D"color: rgb(0, 0, 0);"><br>=C2=A0 </span><span style=3D"color: rgb(0, 0=
, 136);">if</span><span style=3D"color: rgb(102, 102, 0);">(</span><span st=
yle=3D"color: rgb(0, 0, 0);">ix </span><span style=3D"color: rgb(102, 102, =
0);">=3D=3D</span><span style=3D"color: rgb(0, 0, 0);"> std</span><span sty=
le=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 13=
6);">string</span><span style=3D"color: rgb(102, 102, 0);">::</span><span s=
tyle=3D"color: rgb(0, 0, 0);">npos</span><span style=3D"color: rgb(102, 102=
, 0);">)</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"=
color: rgb(0, 0, 136);">break</span><span style=3D"color: rgb(102, 102, 0);=
">;</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 </span><span styl=
e=3D"color: rgb(0, 0, 0);"><code><span style=3D"color: rgb(0, 0, 0);">sv </=
span><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"colo=
r: rgb(0, 0, 0);"> sv</span><span style=3D"color: rgb(102, 102, 0);">.</spa=
n><span style=3D"color: rgb(0, 0, 0);">remove_prefix</span><span style=3D"c=
olor: rgb(102, 102, 0);"></span></code>(ix);<br><br>=C2=A0 int advance;<br>=
=C2=A0 auto value =3D stoi(sv, &amp;advance);<br>=C2=A0 sv =3D sv.remove_pr=
efix(advance);</span></div><div><span style=3D"color: rgb(0, 0, 0);"><br></=
span></div><div><span style=3D"color: rgb(0, 0, 0);">looks like a joke. :)<=
/span></div><div><span style=3D"color: rgb(0, 0, 0);"><br></span></div><div=
><span style=3D"color: rgb(0, 0, 0);">Could you say what is ix? Is it an in=
teger? </span></div><div><span style=3D"color: rgb(0, 0, 0);">And what abou=
t advance? Oh, I am sorry, it is not an integer, is it ?</span></div><div><=
span style=3D"color: rgb(0, 0, 0);"><br></span></div><div><span style=3D"co=
lor: rgb(0, 0, 0);">In fact your code diifers from the code of a beginner t=
hat I showed=C2=A0 only in one thing: the code of the beginner does not use=
 remove_prefix that you are uisng twice in one loop</span></div><div><span =
style=3D"color: rgb(0, 0, 0);"><br></span></div><div><span style=3D"color: =
rgb(0, 0, 0);">=C2=A0 //...</span></div><div><span style=3D"color: rgb(0, 0=
, 0);">=C2=A0 <span style=3D"color: rgb(0, 0, 0);"><code><span style=3D"col=
or: rgb(0, 0, 0);">sv </span><span style=3D"color: rgb(102, 102, 0);">=3D</=
span><span style=3D"color: rgb(0, 0, 0);"> sv</span><span style=3D"color: r=
gb(102, 102, 0);">.</span><span style=3D"color: rgb(0, 0, 0);">remove_prefi=
x</span><span style=3D"color: rgb(102, 102, 0);"></span></code>(ix);<br><br=
>=C2=A0 int advance;<br>=C2=A0 auto value =3D stoi(sv, &amp;advance);<br>=
=C2=A0 sv =3D sv.remove_prefix(advance);</span></span></div><div><span styl=
e=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);">=C2=A0 //..=
..</span></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: rgb(0, 0, 0);"><br></span></span></div><div><span style=3D"color=
: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);">By the=C2=A0way=C2=A0=
what=C2=A0about if you need not only to extract numbers but also to generat=
e a vector of pairs { position, number }? </span></span></div><div><span st=
yle=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0);"><br></spa=
n></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=3D"col=
or: rgb(0, 0, 0);">Will ix in your code correspond to the position in the o=
riginal string? Or in this case do you have to rewrite your code entirely?:=
)</span></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: rgb(0, 0, 0);"><br></span></span></div><div><span style=3D"color=
: rgb(0, 0, 0);"><br></span></div><div><span style=3D"color: rgb(0, 0, 0);"=
><font color=3D"#222222"><br></font></span></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_370_1205896253.1443977689853--
------=_Part_369_145207507.1443977689852--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Sun, 4 Oct 2015 11:25:17 -0700 (PDT)
Raw View
------=_Part_520_1368002238.1443983117192
Content-Type: multipart/alternative;
 boundary="----=_Part_521_705578915.1443983117192"

------=_Part_521_705578915.1443983117192
Content-Type: text/plain; charset=UTF-8


On Sunday, October 4, 2015 at 7:00:01 PM UTC+3, Nicol Bolas wrote:
>
> OK, it's clear we're talking past each other at this point. You prefer
> C-in-C++ style. You prefer convoluted code that ignores the API and is
> "straightforward," as defined by what poorly taught beginning programmers
> will tend to write.
>
> The standards committee doesn't agree with you. They prefer ranges to
> passing bare integer indices around. They prefer *safe* coding idioms.
> Coding idioms that are easy to reason about and modify. Even if they
> introduce "new entities" or whatever.
>
> Go ahead and write up a formal proposal if you want. You'll have to fly to
> a meeting and defend it, as I rather suspect you'll have a hard time
> finding people to defend it for you. And don't be surprised if the first
> comment out of the committee is, "why don't you just take a `string_view`?"
> And when you try to offer your justifications for your API, don't be
> surprised if they find it unconvincing.
>

Instead of saying many words let's compare the two resulting code snippets.

This is better than any words.:)

This is your resulting code snippet

std::string s = ...;
auto sv = std::string_view(s);

while(true)
{
  auto ix = sv.find_first_of("0123456789");
  if(ix == std::string::npos) break;
  sv = sv.remove_prefix(ix);

  int advance;
  auto value = stoi(sv, &advance);
  sv = sv.remove_prefix(advance);

  std::cout << value << " ";
}

And this is my resulting code snippet

    std::string s = ...;

    for ( std::string::size_type pos = 0;
          ( pos = s.find_first_of( "0123456789", pos ) ) !=
std::string::npos; )
    {
        std::cout << std::stoul( s, pos, &pos ) << ' ';
    }


I can use the same code to generate for example a vector of pairs {
position, number } iust substituting the statement inside the body of the
loop for

v.push( { pos, std::stoul( s, pos, &pos ) } );

And what about your code?




--

---
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_521_705578915.1443983117192
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br>On Sunday, October 4, 2015 at 7:00:01 PM UTC+3, Nicol Bolas wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-le=
ft: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; bor=
der-left-style: solid;"><div dir=3D"ltr">OK, it&#39;s clear we&#39;re talki=
ng past each other at this point. You prefer C-in-C++ style. You prefer con=
voluted code that ignores the API and is &quot;straightforward,&quot; as de=
fined by what poorly taught beginning programmers will tend to write.<br><b=
r>The standards committee doesn&#39;t agree with you. They prefer ranges to=
 passing bare integer indices around. They prefer <i>safe</i> coding idioms=
.. Coding idioms that are easy to reason about and modify. Even if they intr=
oduce &quot;new entities&quot; or whatever.<br><br>Go ahead and write up a =
formal proposal if you want. You&#39;ll have to fly to a meeting and defend=
 it, as I rather suspect you&#39;ll have a hard time finding people to defe=
nd it for you. And don&#39;t be surprised if the first comment out of the c=
ommittee is, &quot;why don&#39;t you just take a `string_view`?&quot; And w=
hen you try to offer your justifications for your API, don&#39;t be surpris=
ed if they find it unconvincing.<br></div></blockquote><div><br></div><div>=
Instead=C2=A0of=C2=A0saying many words=C2=A0let&#39;s compare the two=C2=A0=
resulting code snippets. </div><div><br></div><div>This is better than any =
words.:)</div><div><br></div><div>This=C2=A0is your=C2=A0resulting code sni=
ppet</div><div><br></div><div><span style=3D"color: rgb(0, 0, 0);">std</spa=
n><span style=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: r=
gb(0, 0, 136);">string</span><span style=3D"color: rgb(0, 0, 0);"> s </span=
><span style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: r=
gb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);">...;</span><=
span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(0,=
 0, 136);">auto</span><span style=3D"color: rgb(0, 0, 0);"> sv </span><span=
 style=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, =
0, 0);"> std</span><span style=3D"color: rgb(102, 102, 0);">::</span><span =
style=3D"color: rgb(0, 0, 0);">string_view</span><span style=3D"color: rgb(=
102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">s</span><span s=
tyle=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, =
0);"><br><br></span><span style=3D"color: rgb(0, 0, 136);">while</span><spa=
n style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0=
, 136);">true</span><span style=3D"color: rgb(102, 102, 0);">)</span><span =
style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 10=
2, 0);">{</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 </span><spa=
n style=3D"color: rgb(0, 0, 136);">auto</span><span style=3D"color: rgb(0, =
0, 0);"> ix </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><span=
 style=3D"color: rgb(0, 0, 0);"> sv</span><span style=3D"color: rgb(102, 10=
2, 0);">.</span><span style=3D"color: rgb(0, 0, 0);">find_first_of</span><s=
pan style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0,=
 136, 0);">&quot;0123456789&quot;</span><span style=3D"color: rgb(102, 102,=
 0);">)<wbr>;</span><span style=3D"color: rgb(0, 0, 0);"><br>=C2=A0 </span>=
<span style=3D"color: rgb(0, 0, 136);">if</span><span style=3D"color: rgb(1=
02, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 0);">ix </span><span =
style=3D"color: rgb(102, 102, 0);">=3D=3D</span><span style=3D"color: rgb(0=
, 0, 0);"> std</span><span style=3D"color: rgb(102, 102, 0);">::</span><spa=
n style=3D"color: rgb(0, 0, 136);">string</span><span style=3D"color: rgb(1=
02, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">npos</span><spa=
n style=3D"color: rgb(102, 102, 0);">)</span><span style=3D"color: rgb(0, 0=
, 0);"> </span><span style=3D"color: rgb(0, 0, 136);">break</span><span sty=
le=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0);=
"><br>=C2=A0 </span><span style=3D"color: rgb(0, 0, 0);"><code><span style=
=3D"color: rgb(0, 0, 0);">sv </span><span style=3D"color: rgb(102, 102, 0);=
">=3D</span><span style=3D"color: rgb(0, 0, 0);"> sv</span><span style=3D"c=
olor: rgb(102, 102, 0);">.</span><span style=3D"color: rgb(0, 0, 0);">remov=
e_prefix</span><span style=3D"color: rgb(102, 102, 0);"></span></code>(ix);=
<br><br>=C2=A0 int advance;<br>=C2=A0 auto value =3D stoi(sv, &amp;advance)=
;<br>=C2=A0 sv =3D sv.remove_prefix(advance);<br><br>=C2=A0 std</span><span=
 style=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0=
, 0);">cout </span><span style=3D"color: rgb(102, 102, 0);">&lt;&lt;</span>=
<span style=3D"color: rgb(0, 0, 0);"> value</span><span style=3D"color: rgb=
(102, 102, 0);"></span><span style=3D"color: rgb(0, 0, 0);"> </span><span s=
tyle=3D"color: rgb(102, 102, 0);">&lt;&lt;</span><span style=3D"color: rgb(=
0, 0, 0);"> </span><span style=3D"color: rgb(0, 136, 0);">&quot; &quot;</sp=
an><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: r=
gb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">}</span><=
/div><div><span style=3D"color: rgb(102, 102, 0);"><br></span></div><div><s=
pan style=3D"color: rgb(102, 102, 0);">And=C2=A0this is=C2=A0my=C2=A0result=
ing code snippet</span></div><div><span style=3D"color: rgb(102, 102, 0);">=
</span><span style=3D"color: rgb(102, 102, 0);"><br></span></div><div><span=
 style=3D"color: rgb(102, 102, 0);"><span style=3D"color: rgb(102, 102, 0);=
"><span style=3D"color: rgb(102, 102, 0);">=C2=A0=C2=A0=C2=A0 </span></span=
></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: rgb(=
0, 0, 0);">std</span><span style=3D"color: rgb(102, 102, 0);">::</span><spa=
n style=3D"color: rgb(0, 0, 136);">string</span><span style=3D"color: rgb(0=
, 0, 0);"> s </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><spa=
n style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102=
, 0);">...;</span><span style=3D"color: rgb(0, 0, 0);"><br></span></span></=
div><div><br></div><div><span style=3D"color: rgb(102, 102, 0);">=C2=A0=C2=
=A0=C2=A0 for ( std::string::size_type pos =3D 0; <br>=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ( pos =3D s.find_first_of( &quot;01234567=
89&quot;, pos ) ) !=3D std::string::npos; )<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::cout &lt;&lt; std::stoul( s, p=
os, &amp;pos ) &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0=C2=A0 }</span></div><p=
><br></p><div><font color=3D"#666600">I can use the same code to generate f=
or example a vector of pairs { position, number } iust substituting the=C2=
=A0statement=C2=A0inside the body of the loop for</font></div><div><font co=
lor=3D"#666600"><br></font></div><div><font color=3D"#666600">v.push( { pos=
, std::stoul( s, pos, &amp;pos ) }=C2=A0);</font></div><div><font color=3D"=
#666600"><br></font></div><div><font color=3D"#666600">And what about your =
code?</font></div><div><font color=3D"#666600"><br></font></div><div><font =
color=3D"#666600"><br></font></div><span style=3D"color: rgb(102, 102, 0);"=
><p><br></p><div><br></div></span>

<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_521_705578915.1443983117192--
------=_Part_520_1368002238.1443983117192--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Sun, 4 Oct 2015 17:23:46 -0700 (PDT)
Raw View
------=_Part_458_853081804.1444004626440
Content-Type: multipart/alternative;
 boundary="----=_Part_459_361442928.1444004626440"

------=_Part_459_361442928.1444004626440
Content-Type: text/plain; charset=UTF-8

On Sunday, October 4, 2015 at 12:54:50 PM UTC-4, Vlad from Moscow wrote:
>
> On Sunday, October 4, 2015 at 7:00:01 PM UTC+3, Nicol Bolas wrote:
>>
>> OK, it's clear we're talking past each other at this point. You prefer
>> C-in-C++ style. You prefer convoluted code that ignores the API and is
>> "straightforward," as defined by what poorly taught beginning programmers
>> will tend to write.
>>
>> The standards committee doesn't agree with you. They prefer ranges to
>> passing bare integer indices around. They prefer *safe* coding idioms.
>> Coding idioms that are easy to reason about and modify. Even if they
>> introduce "new entities" or whatever.
>>
>> Go ahead and write up a formal proposal if you want. You'll have to fly
>> to a meeting and defend it, as I rather suspect you'll have a hard time
>> finding people to defend it for you. And don't be surprised if the first
>> comment out of the committee is, "why don't you just take a `string_view`?"
>> And when you try to offer your justifications for your API, don't be
>> surprised if they find it unconvincing.
>>
>
> I hope that the C++ Standards Committee is not just you.:)
>

The C++ standards committee does not even include me ;)

However, the fact of the matter is this. You explained what you wanted. Six
separate people, including myself, disagree with you about which is
clearer, easier for beginners, and/or more useful in general. Not one
single person has stepped forward to defend your idea.

Do you honestly expect the arguments that we have found unconvincing to be
more convincing when spoken to committee members? They will undoubtedly ask
why you don't just suggest that the function takes a `string_view`
(especially since that change is already part of an existing proposal).

Do you think that your examples will convince them? Do you believe that the
people behind the range proposal will be convinced by your C-in-C++ code
examples? Do you think that they will agree with you when you declare how
beginners will obviously want to code?

Because at the end of the day, all you have is a feature who's
functionality will be duplicated once `string_view` is added to `stoi` and
so forth. You may not like the *form* of that duplication, but it is an
irrefutable fact that you will be *able* to get the same job done with the
`string_view` form as with what you want.

That's what you'd be fighting against.

>

> In fact your code diifers from the code of a beginner that I showed  only
> in one thing: the code of the beginner does not use remove_prefix that you
> are uisng twice in one loop
>

You were trying to prove that beginners would never be able to use
string_view, right? So if it is true that my code is only slightly
different from your idea of beginner code, then you *must* accept that a
beginner would be *equally capable* of writing either one.

Doesn't that torpedo your entire argument? Either my code is so different
that a beginner would never write it, or it's perfectly comprehensible to a
beginner. It can't be both.


> By the way what about if you need not only to extract numbers but also to
> generate a vector of pairs { position, number }?
>

That right there shows the problem with your mode of thought. You declare
arbitrary requirements without bothering to ask why someone would *need*
such a requirement.

I look at that requirement and ask what they'd do with such offsets. If
they want to associate locations in the string with the number that they
correspond to, then odds are good that they're probably going to want to
process the text *between* number characters. Right? I mean, they already
have the numbers themselves. So that would be a logical reason for wanting
to know what part of the text a number comes from.

And if that's the case, then `{ position, number }` is seriously lacking
one important element: the *size* of each number, in characters. You need
that to know where a number ends, so that you can go on to process the
characters after one number and before the next.

Given that, what you really want is a `vector<pair<string_view, int>>`. And
that is easy to provide:

vec.emplace_back(sv.substr(0, advance), value);


> Will ix in your code correspond to the position in the original string? Or
> in this case do you have to rewrite your code entirely?:)
>
Offsets (stop calling them "positions"), despite what I said, are a valid
way of interacting with strings. Unlike iterators, they can't be
invalidated (so long as you didn't modify the text they represent).
Therefore, wanting to actually return the offset to each entry is not a
priori unreasonable.

It's also pretty trivial with `string_view`:

vec.emplace_back(&sv[0] - &s[0], value);

What, did you forget that `string_view`, for all of its interface, is
really just a pair of pointers ;)

On Sunday, October 4, 2015 at 2:25:17 PM UTC-4, Vlad from Moscow wrote:
>
> Instead of saying many words let's compare the two resulting code
> snippets.
>
> This is better than any words.:)
>

You're absolutely right; your code communicates far better than any words
could. And here is the result of your communication.

I cannot rationally discuss issues of code quality with someone who
genuinely feels that this:


>     std::string s = ...;
>
>     for ( std::string::size_type pos = 0;
>           ( pos = s.find_first_of( "0123456789", pos ) ) !=
> std::string::npos; )
>     {
>         std::cout << std::stoul( s, pos, &pos ) << ' ';
>     }
>

is an example of good code.

Good day, sir!

--

---
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_459_361442928.1444004626440
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sunday, October 4, 2015 at 12:54:50 PM UTC-4, Vlad from Moscow wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;">On Sunday, October 4, 2015 at 7:0=
0:01 PM UTC+3, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D=
"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,20=
4);border-left-width:1px;border-left-style:solid"><div dir=3D"ltr">OK, it&#=
39;s clear we&#39;re talking past each other at this point. You prefer C-in=
-C++ style. You prefer convoluted code that ignores the API and is &quot;st=
raightforward,&quot; as defined by what poorly taught beginning programmers=
 will tend to write.<br><br>The standards committee doesn&#39;t agree with =
you. They prefer ranges to passing bare integer indices around. They prefer=
 <i>safe</i> coding idioms. Coding idioms that are easy to reason about and=
 modify. Even if they introduce &quot;new entities&quot; or whatever.<br><b=
r>Go ahead and write up a formal proposal if you want. You&#39;ll have to f=
ly to a meeting and defend it, as I rather suspect you&#39;ll have a hard t=
ime finding people to defend it for you. And don&#39;t be surprised if the =
first comment out of the committee is, &quot;why don&#39;t you just take a =
`string_view`?&quot; And when you try to offer your justifications for your=
 API, don&#39;t be surprised if they find it unconvincing.<br></div></block=
quote><div><br></div><div>I hope that the C++ Standards Committee is not ju=
st you.:)</div></blockquote><div><br>The C++ standards committee does not e=
ven include me ;)<br><br>However, the fact of the matter is this. You expla=
ined what you wanted. Six separate people, including myself, disagree with =
you about which is clearer, easier for beginners, and/or more useful in gen=
eral. Not one single person has stepped forward to defend your idea.<br><br=
>Do you honestly expect the arguments that we have found unconvincing to be=
 more convincing when spoken to committee members? They will undoubtedly as=
k why you don&#39;t just suggest that the function takes a `string_view` (e=
specially since that change is already part of an existing proposal).<br><b=
r>Do you think that your examples will convince them? Do you believe that t=
he people behind the range proposal will be convinced by your C-in-C++ code=
 examples? Do you think that they will agree with you when you declare how =
beginners will obviously want to code?<br><br>Because at the end of the day=
, all you have is a feature who&#39;s functionality will be duplicated once=
 `string_view` is added to `stoi` and so forth. You may not like the <i>for=
m</i> of that duplication, but it is an irrefutable fact that you will be <=
i>able</i> to get the same job done with the `string_view` form as with wha=
t you want.<br><br>That&#39;s what you&#39;d be fighting against.<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div></div></blockquote><div>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div><span style=
=3D"color:rgb(0,0,0)"></span></div><div><span style=3D"color:rgb(0,0,0)">In=
 fact your code diifers from the code of a beginner that I showed=C2=A0 onl=
y in one thing: the code of the beginner does not use remove_prefix that yo=
u are uisng twice in one loop</span></div></blockquote><div><br>You were tr=
ying to prove that beginners would never be able to use string_view, right?=
 So if it is true that my code is only slightly different from your idea of=
 beginner code, then you <i>must</i> accept that a beginner would be <i>equ=
ally capable</i> of writing either one.<br><br>Doesn&#39;t that torpedo you=
r entire argument? Either my code is so different that a beginner would nev=
er write it, or it&#39;s perfectly comprehensible to a beginner. It can&#39=
;t be both.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v><span style=3D"color:rgb(0,0,0)"><span style=3D"color:rgb(0,0,0)"></span>=
</span></div><div><span style=3D"color:rgb(0,0,0)"><span style=3D"color:rgb=
(0,0,0)">By the=C2=A0way=C2=A0what=C2=A0about if you need not only to extra=
ct numbers but also to generate a vector of pairs { position, number }? </s=
pan></span></div></blockquote><div><br>That right there shows the problem w=
ith your mode of thought. You declare arbitrary requirements without bother=
ing to ask why someone would <i>need</i> such a requirement.<br><br>I look =
at that requirement and ask what they&#39;d do with such offsets. If they w=
ant to associate locations in the string with the number that they correspo=
nd to, then odds are good that they&#39;re probably going to want to proces=
s the text <i>between</i> number characters. Right? I mean, they already ha=
ve the numbers themselves. So that would be a logical reason for wanting to=
 know what part of the text a number comes from.<br><br>And if that&#39;s t=
he case, then `<span style=3D"color:rgb(0,0,0)"><span style=3D"color:rgb(0,=
0,0)">{ position, number }` is seriously lacking one important element: the=
 <i>size</i> of each number, in characters. You need that to know where a n=
umber ends, so that you can go on to process the characters after one numbe=
r and before the next.<br><br>Given that, what you really want is a `vector=
&lt;pair&lt;string_view, int&gt;&gt;`. And that is easy to provide:<br><br>=
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); b=
order-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; wo=
rd-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #000;" class=3D"styled-by-prettify">vec</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">emplace_back</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">sv</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">substr</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> advanc=
e</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> value</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v></span></span></div><div>=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-lef=
t: 1ex;"><div><span style=3D"color:rgb(0,0,0)"><span style=3D"color:rgb(0,0=
,0)">Will ix in your code correspond to the position in the original string=
? Or in this case do you have to rewrite your code entirely?:)</span></span=
></div></blockquote><div>Offsets (stop calling them &quot;positions&quot;),=
 despite what I said, are a valid way of interacting with strings. Unlike i=
terators, they can&#39;t be invalidated (so long as you didn&#39;t modify t=
he text they represent). Therefore, wanting to actually return the offset t=
o each entry is not a priori unreasonable.<br><br>It&#39;s also pretty triv=
ial with `string_view`:<br><br><div class=3D"prettyprint" style=3D"backgrou=
nd-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-styl=
e: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">vec</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">emplace_back</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>sv</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[</span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">]</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">-</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">s</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>[</span><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">],</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> value</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span></div></code></div>=
<br>What, did you forget that `string_view`, for all of its interface, is r=
eally just a pair of pointers ;)<br><br>On Sunday, October 4, 2015 at 2:25:=
17 PM UTC-4, Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div>Instead=C2=A0of=C2=A0saying many words=C2=A0let&#39;s compare th=
e two=C2=A0resulting code snippets. </div><div><br></div><div>This is bette=
r than any words.:)</div></blockquote><div><br>You&#39;re absolutely right;=
 your code communicates far better than any words could. And here is the re=
sult of your communication.<br><br>I cannot rationally discuss issues of co=
de quality with someone who genuinely feels that this:<br>=C2=A0</div><bloc=
kquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-l=
eft: 1px #ccc solid;padding-left: 1ex;"><div><span style=3D"color:rgb(102,1=
02,0)"><span style=3D"color:rgb(102,102,0)"><span style=3D"color:rgb(102,10=
2,0)">=C2=A0=C2=A0=C2=A0 </span></span></span><span style=3D"color:rgb(102,=
102,0)"><span style=3D"color:rgb(0,0,0)">std</span><span style=3D"color:rgb=
(102,102,0)">::</span><span style=3D"color:rgb(0,0,136)">string</span><span=
 style=3D"color:rgb(0,0,0)"> s </span><span style=3D"color:rgb(102,102,0)">=
=3D</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb=
(102,102,0)">...;</span><span style=3D"color:rgb(0,0,0)"><br></span></span>=
</div><div><br></div><div><span style=3D"color:rgb(102,102,0)">=C2=A0=C2=A0=
=C2=A0 for ( std::string::size_type pos =3D 0; <br>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ( pos =3D s.find_first_of( &quot;0123456789&=
quot;, pos ) ) !=3D std::string::npos; )<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::cout &lt;&lt; std::stoul( s, pos,=
 &amp;pos ) &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0=C2=A0 }</span></div></blo=
ckquote><div><br>is an example of good code.<br><br>Good day, sir!<br></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_459_361442928.1444004626440--
------=_Part_458_853081804.1444004626440--

.


Author: Vlad from Moscow <vlad.moscow@mail.ru>
Date: Mon, 5 Oct 2015 03:25:48 -0700 (PDT)
Raw View
------=_Part_6_198076823.1444040748433
Content-Type: multipart/alternative;
 boundary="----=_Part_7_359840663.1444040748433"

------=_Part_7_359840663.1444040748433
Content-Type: text/plain; charset=UTF-8



On Monday, October 5, 2015 at 3:23:46 AM UTC+3, Nicol Bolas wrote:
>
> On Sunday, October 4, 2015 at 12:54:50 PM UTC-4, Vlad from Moscow wrote:
>>
>> On Sunday, October 4, 2015 at 7:00:01 PM UTC+3, Nicol Bolas wrote:
>>>
>>> OK, it's clear we're talking past each other at this point. You prefer
>>> C-in-C++ style. You prefer convoluted code that ignores the API and is
>>> "straightforward," as defined by what poorly taught beginning programmers
>>> will tend to write.
>>>
>>> The standards committee doesn't agree with you. They prefer ranges to
>>> passing bare integer indices around. They prefer *safe* coding idioms.
>>> Coding idioms that are easy to reason about and modify. Even if they
>>> introduce "new entities" or whatever.
>>>
>>> Go ahead and write up a formal proposal if you want. You'll have to fly
>>> to a meeting and defend it, as I rather suspect you'll have a hard time
>>> finding people to defend it for you. And don't be surprised if the first
>>> comment out of the committee is, "why don't you just take a `string_view`?"
>>> And when you try to offer your justifications for your API, don't be
>>> surprised if they find it unconvincing.
>>>
>>
>> I hope that the C++ Standards Committee is not just you.:)
>>
>
> The C++ standards committee does not even include me ;)
>

Thanks, it is indeed a good news.:)

>
> However, the fact of the matter is this. You explained what you wanted.
> Six separate people, including myself, disagree with you about which is
> clearer, easier for beginners, and/or more useful in general. Not one
> single person has stepped forward to defend your idea.
>
> I am dissapointed!  Six is too few.:).


> Do you honestly expect the arguments that we have found unconvincing to be
> more convincing when spoken to committee members? They will undoubtedly ask
> why you don't just suggest that the function takes a `string_view`
> (especially since that change is already part of an existing proposal).
>
> I think that if somebody can write code will not ask such questions. It is
enough to see your code only once that never ask such questions. Take into
account that my proposal is not about remove_prefix.:) And my code removes
nothing.:)



> Do you think that your examples will convince them? Do you believe that
> the people behind the range proposal will be convinced by your C-in-C++
> code examples? Do you think that they will agree with you when you declare
> how beginners will obviously want to code?
>
> Till now I thought that it is your code that is a bad C++ in C.:) It makes
many redundant operations, uses many unnecessary integer variables.


> Because at the end of the day, all you have is a feature who's
> functionality will be duplicated once `string_view` is added to `stoi` and
> so forth. You may not like the *form* of that duplication, but it is an
> irrefutable fact that you will be *able* to get the same job done with
> the `string_view` form as with what you want.
>
> Nothing in my code duplicates string_view.

it seems you have understood nothing. Your approach is to add the fifth
wheel to a coach  And moreover your fifth wheel has a form of an incorrect
rectangle that results in using remove_prefix.:)

My approach is to use the coach with its four wheels. Only I suggest to use
a new spring.:)


That's what you'd be fighting against.
>
>>
>
>> In fact your code diifers from the code of a beginner that I showed  only
>> in one thing: the code of the beginner does not use remove_prefix that you
>> are uisng twice in one loop
>>
>
> You were trying to prove that beginners would never be able to use
> string_view, right?
>

No, I said that such an idea will never come in his head.:) If he has
an assignment to find a position in a string and extract a number at the
position he will do these two tasks:

1. Find the position;
2. Extract the number.




> So if it is true that my code is only slightly different from your idea of
> beginner code, then you *must* accept that a beginner would be *equally
> capable* of writing either one.
>
> A beginner can write any code.:) The problem is that he himself never will
invent string_view in this situation.:) In the best case he will know that
there is standard function stoi that he could use.


Doesn't that torpedo your entire argument? Either my code is so different
> that a beginner would never write it, or it's perfectly comprehensible to a
> beginner. It can't be both.
>

A bad code is being written in two cases. Either a programmer knows too
little in programming. Or a programmer knows too much constructions but
does not know how, where and why to use them.:)



> By the way what about if you need not only to extract numbers but also to
>> generate a vector of pairs { position, number }?
>>
>
> That right there shows the problem with your mode of thought. You declare
> arbitrary requirements without bothering to ask why someone would *need*
> such a requirement.
>
> Any good code is a generic code. It is usually reusable.  So there is
nothing wonderful that my code can be used with the new task without any
serious changes and your code can not be used with the new task without
 being entirely rewritten.

I look at that requirement and ask what they'd do with such offsets. If
> they want to associate locations in the string with the number that they
> correspond to, then odds are good that they're probably going to want to
> process the text *between* number characters. Right? I mean, they already
> have the numbers themselves. So that would be a logical reason for wanting
> to know what part of the text a number comes from.
>
> And if that's the case, then `{ position, number }` is seriously lacking
> one important element: the *size* of each number, in characters. You need
> that to know where a number ends, so that you can go on to process the
> characters after one number and before the next.
>
> Given that, what you really want is a `vector<pair<string_view, int>>`.
> And that is easy to provide:
>
> vec.emplace_back(sv.substr(0, advance), value);
>
>
To provide this you have to rewrite all your previous code with
remove_prefix.:)


> Will ix in your code correspond to the position in the original string? Or
>> in this case do you have to rewrite your code entirely?:)
>>
> Offsets (stop calling them "positions"), despite what I said, are a valid
> way of interacting with strings. Unlike iterators, they can't be
> invalidated (so long as you didn't modify the text they represent).
> Therefore, wanting to actually return the offset to each entry is not a
> priori unreasonable.
>
> It's also pretty trivial with `string_view`:
>
> vec.emplace_back(&sv[0] - &s[0], value);
>
> What, did you forget that `string_view`, for all of its interface, is
> really just a pair of pointers ;)
>
> On Sunday, October 4, 2015 at 2:25:17 PM UTC-4, Vlad from Moscow wrote:
>>
>> Instead of saying many words let's compare the two resulting code
>> snippets.
>>
>> This is better than any words.:)
>>
>
> You're absolutely right; your code communicates far better than any words
> could. And here is the result of your communication.
>
> I cannot rationally discuss issues of code quality with someone who
> genuinely feels that this:
>
>
>>     std::string s = ...;
>>
>>     for ( std::string::size_type pos = 0;
>>           ( pos = s.find_first_of( "0123456789", pos ) ) !=
>> std::string::npos; )
>>     {
>>         std::cout << std::stoul( s, pos, &pos ) << ' ';
>>     }
>>
>
> is an example of good code.
>
> Good day, sir!
>

--

---
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_7_359840663.1444040748433
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Monday, October 5, 2015 at 3:23:46 AM UTC+3, Nicol Bolas wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; paddin=
g-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px;=
 border-left-style: solid;">On Sunday, October 4, 2015 at 12:54:50 PM UTC-4=
, Vlad from Moscow 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;">On Sunday, October 4,=
 2015 at 7:00:01 PM UTC+3, Nicol Bolas wrote:<blockquote class=3D"gmail_quo=
te" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-colo=
r: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><=
div dir=3D"ltr">OK, it&#39;s clear we&#39;re talking past each other at thi=
s point. You prefer C-in-C++ style. You prefer convoluted code that ignores=
 the API and is &quot;straightforward,&quot; as defined by what poorly taug=
ht beginning programmers will tend to write.<br><br>The standards committee=
 doesn&#39;t agree with you. They prefer ranges to passing bare integer ind=
ices around. They prefer <i>safe</i> coding idioms. Coding idioms that are =
easy to reason about and modify. Even if they introduce &quot;new entities&=
quot; or whatever.<br><br>Go ahead and write up a formal proposal if you wa=
nt. You&#39;ll have to fly to a meeting and defend it, as I rather suspect =
you&#39;ll have a hard time finding people to defend it for you. And don&#3=
9;t be surprised if the first comment out of the committee is, &quot;why do=
n&#39;t you just take a `string_view`?&quot; And when you try to offer your=
 justifications for your API, don&#39;t be surprised if they find it unconv=
incing.<br></div></blockquote><div><br></div><div>I hope that the C++ Stand=
ards Committee is not just you.:)</div></blockquote><div><br>The C++ standa=
rds committee does not even include me ;)<br></div></blockquote><div><br></=
div><div>Thanks, it is indeed a good news.:)=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;"><div><br>However, the fact of the matter is this. You explained=
 what you wanted. Six separate people, including myself, disagree with you =
about which is clearer, easier for beginners, and/or more useful in general=
.. Not one single person has stepped forward to defend your idea.<br><br></d=
iv></blockquote><div>I am dissapointed!=C2=A0 Six=C2=A0is too few.:).</div>=
<div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px=
 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); borde=
r-left-width: 1px; border-left-style: solid;"><div>Do you honestly expect t=
he arguments that we have found unconvincing to be more convincing when spo=
ken to committee members? They will undoubtedly ask why you don&#39;t just =
suggest that the function takes a `string_view` (especially since that chan=
ge is already part of an existing proposal).<br><br></div></blockquote><div=
>I think that if somebody can write code will not ask such questions. It is=
 enough to see your code only once that never ask such questions. Take into=
 account that my proposal is not about remove_prefix.:) And my code removes=
 nothing.:)</div><div><br></div><div>=C2=A0</div><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=
;"><div>Do you think that your examples will convince them? Do you believe =
that the people behind the range proposal will be convinced by your C-in-C+=
+ code examples? Do you think that they will agree with you when you declar=
e how beginners will obviously want to code?<br><br></div></blockquote><div=
>Till now I thought that it is your code that is a bad C++ in C.:) It makes=
 many redundant operations, uses many unnecessary integer variables.</div><=
div>=C2=A0</div><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;"><div>Because at the end of the=
 day, all you have is a feature who&#39;s functionality will be duplicated =
once `string_view` is added to `stoi` and so forth. You may not like the <i=
>form</i> of that duplication, but it is an irrefutable fact that you will =
be <i>able</i> to get the same job done with the `string_view` form as with=
 what you want.<br><br></div></blockquote><div>Nothing in my code duplicate=
s string_view. </div><div><br></div><div>it seems you have understood nothi=
ng. Your approach is to add the fifth wheel=C2=A0to a coach=C2=A0 And moreo=
ver your fifth wheel has a form of=C2=A0an incorrect rectangle that results=
 in using remove_prefix.:)</div><div><br></div><div>My approach is to use t=
he coach with its four wheels. Only I suggest to use a new spring.:)</div><=
div><br></div><div><br></div><blockquote class=3D"gmail_quote" style=3D"mar=
gin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204,=
 204); border-left-width: 1px; border-left-style: solid;"><div>That&#39;s w=
hat you&#39;d be fighting against.<br></div><blockquote class=3D"gmail_quot=
e" 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;"><d=
iv></div></blockquote><div>=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=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;"><div><s=
pan style=3D"color: rgb(0, 0, 0);"></span></div><div><span style=3D"color: =
rgb(0, 0, 0);">In fact your code diifers from the code of a beginner that I=
 showed=C2=A0 only in one thing: the code of the beginner does not use remo=
ve_prefix that you are uisng twice in one loop</span></div></blockquote><di=
v><br>You were trying to prove that beginners would never be able to use st=
ring_view, right? </div></blockquote><div><br></div><div>No, I said that su=
ch an idea will never come in his head.:) If he has an=C2=A0assignment to f=
ind a position in a string and extract=C2=A0a number at the position he wil=
l do these two tasks:</div><div><br></div><div>1. Find the position;</div><=
div>2. Extract the number.</div><div><br></div><div><br></div><div>=C2=A0</=
div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; p=
adding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width:=
 1px; border-left-style: solid;"><div>So if it is true that my code is only=
 slightly different from your idea of beginner code, then you <i>must</i> a=
ccept that a beginner would be <i>equally capable</i> of writing either one=
..<br><br></div></blockquote><div>A beginner can write any code.:) The probl=
em is that he himself never will invent string_view in this situation.:) In=
 the best case he will know that there is standard function stoi that he co=
uld use.</div><div>=C2=A0</div><div><br></div><blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-col=
or: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;">=
<div>Doesn&#39;t that torpedo your entire argument? Either my code is so di=
fferent that a beginner would never write it, or it&#39;s perfectly compreh=
ensible to a beginner. It can&#39;t be both.<br></div></blockquote><div><br=
></div><div>A bad code is being written in two cases. Either a programmer k=
nows too little in programming. Or a programmer knows too much construction=
s but does not know how, where and why to use them.:)</div><div><br></div><=
div>=C2=A0</div><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;"><blockquote class=3D"gmail_quo=
te" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-colo=
r: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><=
div><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: rgb(0, 0, 0)=
;"></span></span></div><div><span style=3D"color: rgb(0, 0, 0);"><span styl=
e=3D"color: rgb(0, 0, 0);">By the=C2=A0way=C2=A0what=C2=A0about if you need=
 not only to extract numbers but also to generate a vector of pairs { posit=
ion, number }? </span></span></div></blockquote><div><br>That right there s=
hows the problem with your mode of thought. You declare arbitrary requireme=
nts without bothering to ask why someone would <i>need</i> such a requireme=
nt.<br><br></div></blockquote><div>Any good code is=C2=A0a generic code.=C2=
=A0It is usually reusable.=C2=A0=C2=A0So there is nothing wonderful that my=
 code=C2=A0can be used with the new task without any serious=C2=A0changes a=
nd your code can not be used=C2=A0with the=C2=A0new task without =C2=A0bein=
g entirely rewritten.</div><div><br></div><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;"><div=
>I look at that requirement and ask what they&#39;d do with such offsets. I=
f they want to associate locations in the string with the number that they =
correspond to, then odds are good that they&#39;re probably going to want t=
o process the text <i>between</i> number characters. Right? I mean, they al=
ready have the numbers themselves. So that would be a logical reason for wa=
nting to know what part of the text a number comes from.<br><br>And if that=
&#39;s the case, then `<span style=3D"color: rgb(0, 0, 0);"><span style=3D"=
color: rgb(0, 0, 0);">{ position, number }` is seriously lacking one import=
ant element: the <i>size</i> of each number, in characters. You need that t=
o know where a number ends, so that you can go on to process the characters=
 after one number and before the next.<br><br>Given that, what you really w=
ant is a `vector&lt;pair&lt;string_view, int&gt;&gt;`. And that is easy to =
provide:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); border-=
image: none; -ms-word-wrap: break-word; background-color: rgb(250, 250, 250=
);"><code><div><span style=3D"color: rgb(0, 0, 0);">vec</span><span style=
=3D"color: rgb(102, 102, 0);">.</span><span style=3D"color: rgb(0, 0, 0);">=
emplace_back</span><span style=3D"color: rgb(102, 102, 0);">(</span><span s=
tyle=3D"color: rgb(0, 0, 0);">sv</span><span style=3D"color: rgb(102, 102, =
0);">.</span><span style=3D"color: rgb(0, 0, 0);">substr</span><span style=
=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 102, 102=
);">0</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=3D=
"color: rgb(0, 0, 0);"> advance</span><span style=3D"color: rgb(102, 102, 0=
);">),</span><span style=3D"color: rgb(0, 0, 0);"> value</span><span style=
=3D"color: rgb(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"=
><br></span></div></code></div></span></span></div><div>=C2=A0</div></block=
quote><div>To provide this you have to rewrite all your previous code with =
remove_prefix.:)</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" st=
yle=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;"><blockq=
uote 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; borde=
r-left-style: solid;"><div><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: rgb(0, 0, 0);">Will ix in your code correspond to the position i=
n the original string? Or in this case do you have to rewrite your code ent=
irely?:)</span></span></div></blockquote><div>Offsets (stop calling them &q=
uot;positions&quot;), despite what I said, are a valid way of interacting w=
ith strings. Unlike iterators, they can&#39;t be invalidated (so long as yo=
u didn&#39;t modify the text they represent). Therefore, wanting to actuall=
y return the offset to each entry is not a priori unreasonable.<br><br>It&#=
39;s also pretty trivial with `string_view`:<br><br><div style=3D"border: 1=
px solid rgb(187, 187, 187); border-image: none; -ms-word-wrap: break-word;=
 background-color: rgb(250, 250, 250);"><code><div><span style=3D"color: rg=
b(0, 0, 0);">vec</span><span style=3D"color: rgb(102, 102, 0);">.</span><sp=
an style=3D"color: rgb(0, 0, 0);">emplace_back</span><span style=3D"color: =
rgb(102, 102, 0);">(&amp;</span><span style=3D"color: rgb(0, 0, 0);">sv</sp=
an><span style=3D"color: rgb(102, 102, 0);">[</span><span style=3D"color: r=
gb(0, 102, 102);">0</span><span style=3D"color: rgb(102, 102, 0);">]</span>=
<span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102,=
 102, 0);">-</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=
=3D"color: rgb(102, 102, 0);">&amp;</span><span style=3D"color: rgb(0, 0, 0=
);">s</span><span style=3D"color: rgb(102, 102, 0);">[</span><span style=3D=
"color: rgb(0, 102, 102);">0</span><span style=3D"color: rgb(102, 102, 0);"=
>],</span><span style=3D"color: rgb(0, 0, 0);"> value</span><span style=3D"=
color: rgb(102, 102, 0);">);</span></div></code></div><br>What, did you for=
get that `string_view`, for all of its interface, is really just a pair of =
pointers ;)<br><br>On Sunday, October 4, 2015 at 2:25:17 PM UTC-4, Vlad fro=
m Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0=
px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-=
left-width: 1px; border-left-style: solid;"><div>Instead=C2=A0of=C2=A0sayin=
g many words=C2=A0let&#39;s compare the two=C2=A0resulting code snippets. <=
/div><div><br></div><div>This is better than any words.:)</div></blockquote=
><div><br>You&#39;re absolutely right; your code communicates far better th=
an any words could. And here is the result of your communication.<br><br>I =
cannot rationally discuss issues of code quality with someone who genuinely=
 feels that this:<br>=C2=A0</div><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;"><div><span st=
yle=3D"color: rgb(102, 102, 0);"><span style=3D"color: rgb(102, 102, 0);"><=
span style=3D"color: rgb(102, 102, 0);">=C2=A0=C2=A0=C2=A0 </span></span></=
span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color: rgb(0, =
0, 0);">std</span><span style=3D"color: rgb(102, 102, 0);">::</span><span s=
tyle=3D"color: rgb(0, 0, 136);">string</span><span style=3D"color: rgb(0, 0=
, 0);"> s </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><span s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0=
);">...;</span><span style=3D"color: rgb(0, 0, 0);"><br></span></span></div=
><div><br></div><div><span style=3D"color: rgb(102, 102, 0);">=C2=A0=C2=A0=
=C2=A0 for ( std::string::size_type pos =3D 0; <br>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ( pos =3D s.find_first_of( &quot;0123456789&=
quot;, pos ) ) !=3D std::string::npos; )<br>=C2=A0=C2=A0=C2=A0 {<br>=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 std::cout &lt;&lt; std::stoul( s, pos,=
 &amp;pos ) &lt;&lt; &#39; &#39;;<br>=C2=A0=C2=A0=C2=A0 }</span></div></blo=
ckquote><div><br>is an example of good code.<br><br>Good day, sir!<br></div=
></div></blockquote>

<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_7_359840663.1444040748433--
------=_Part_6_198076823.1444040748433--

.