Topic: C++ classes for string conversion
Author: Robin Rowe <robinsrowe@gmail.com>
Date: Mon, 9 Nov 2015 08:04:57 -0800
Raw View
I have an Int class that does this:
#include "CppTypes.h"
#include <string>
int main()
{ int x=10;
Int x2(x);
std::string s=x2;// s=="10"
Int x3("20");
int x4=x3;// x4==20
const char* s2=x3;// s2=="20", s2 valid as long as x3 exists
Int x5("hello");// true==isnan(x5);
int x6=x5;//x6==0
return 0;
}
I have classes like this for all the built-in types. I prefer this
approach over using string streams when going back-and-forth between
built-in types and strings or char*.
Is there something like this in the C++ standard? Would anyone else find
this useful? Has this been discussed before?
Thanks,
Robin
--
---
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: Klemens Morgenstern <klemens.morgenstern@gmx.net>
Date: Mon, 9 Nov 2015 08:51:18 -0800 (PST)
Raw View
------=_Part_184_1597588066.1447087878702
Content-Type: multipart/alternative;
boundary="----=_Part_185_172759820.1447087878702"
------=_Part_185_172759820.1447087878702
Content-Type: text/plain; charset=UTF-8
This style is very java-like. This functionality exists as a set of
functions: http://en.cppreference.com/w/cpp/string/basic_string/stol
--
---
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_185_172759820.1447087878702
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">This style is very java-like. This functionality exists as=
a set of functions:=C2=A0http://en.cppreference.com/w/cpp/string/basic_str=
ing/stol=C2=A0</div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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_185_172759820.1447087878702--
------=_Part_184_1597588066.1447087878702--
.
Author: Vitali Lovich <vlovich@gmail.com>
Date: Mon, 9 Nov 2015 08:54:46 -0800
Raw View
--Apple-Mail=_EE518725-8E8C-4947-995F-612AE9151647
Content-Type: text/plain; charset=UTF-8
Probably more Javascript/Python than Java as isnan is not defined for integers since Java & C++ provide direct exposure to primitives whereas python hides it.
> On Nov 9, 2015, at 8:51 AM, Klemens Morgenstern <klemens.morgenstern@gmx.net> wrote:
>
> This style is ver
--
---
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/.
--Apple-Mail=_EE518725-8E8C-4947-995F-612AE9151647
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dus-ascii"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode=
: space; -webkit-line-break: after-white-space;" class=3D"">Probably more J=
avascript/Python than Java as isnan is not defined for integers since =
Java & C++ provide direct exposure to primitives whereas python hides i=
t.<div class=3D""><div class=3D""><br class=3D""><div><blockquote type=3D"c=
ite" class=3D""><div class=3D"">On Nov 9, 2015, at 8:51 AM, Klemens Morgens=
tern <<a href=3D"mailto:klemens.morgenstern@gmx.net" class=3D"">klemens.=
morgenstern@gmx.net</a>> wrote:</div><br class=3D"Apple-interchange-newl=
ine"><div class=3D""><span style=3D"font-family: Helvetica; font-size: 12px=
; font-style: normal; font-variant: normal; font-weight: normal; letter-spa=
cing: normal; orphans: auto; text-align: start; text-indent: 0px; text-tran=
sform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-=
text-stroke-width: 0px; float: none; display: inline !important;" class=3D"=
">This style is ver</span></div></blockquote></div><br class=3D""></div></d=
iv></body></html>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
--Apple-Mail=_EE518725-8E8C-4947-995F-612AE9151647--
.
Author: ghanashyam.satpathy@gmail.com
Date: Mon, 1 Feb 2016 02:23:58 -0800 (PST)
Raw View
------=_Part_4279_2047096761.1454322238638
Content-Type: multipart/alternative;
boundary="----=_Part_4280_387550037.1454322238638"
------=_Part_4280_387550037.1454322238638
Content-Type: text/plain; charset=UTF-8
Yes I like this approach.Justifies to be more object oriented instead of
using stol() version of conversion routine.
So a common template class having toString() would be nice to have for all
numeric-> string conversion.
Thanks
Ghanashyam
On Monday, November 9, 2015 at 9:35:05 PM UTC+5:30, Robin Rowe wrote:
>
> I have an Int class that does this:
>
> #include "CppTypes.h"
> #include <string>
>
> int main()
> { int x=10;
> Int x2(x);
> std::string s=x2;// s=="10"
> Int x3("20");
> int x4=x3;// x4==20
> const char* s2=x3;// s2=="20", s2 valid as long as x3 exists
> Int x5("hello");// true==isnan(x5);
> int x6=x5;//x6==0
> return 0;
> }
>
> I have classes like this for all the built-in types. I prefer this
> approach over using string streams when going back-and-forth between
> built-in types and strings or char*.
>
> Is there something like this in the C++ standard? Would anyone else find
> this useful? Has this been discussed before?
>
> Thanks,
>
> Robin
>
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_4280_387550037.1454322238638
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Yes I like this approach.Justifies to be more object orien=
ted instead of using stol() version of conversion routine.<div>So a common =
template class having toString() would be nice to have for all numeric->=
string conversion.</div><div><br></div><div>Thanks</div><div><br></div><di=
v>Ghanashyam<br><br>On Monday, November 9, 2015 at 9:35:05 PM UTC+5:30, Rob=
in Rowe wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I have an Int cl=
ass that does this:
<br>
<br>#include "CppTypes.h"
<br>#include <string>
<br>
<br>int main()
<br>{ =C2=A0 int x=3D10;
<br>=C2=A0 =C2=A0 =C2=A0Int x2(x);
<br>=C2=A0 =C2=A0 =C2=A0std::string s=3Dx2;// s=3D=3D"10"
<br>=C2=A0 =C2=A0 =C2=A0Int x3("20");
<br>=C2=A0 =C2=A0 =C2=A0int x4=3Dx3;// x4=3D=3D20
<br>=C2=A0 =C2=A0 =C2=A0const char* s2=3Dx3;// s2=3D=3D"20", s2 v=
alid as long as x3 exists
<br>=C2=A0 =C2=A0 =C2=A0Int x5("hello");// true=3D=3Disnan(x5);
<br>=C2=A0 =C2=A0 =C2=A0int x6=3Dx5;//x6=3D=3D0
<br>=C2=A0 =C2=A0 =C2=A0return 0;
<br>}
<br>
<br>I have classes like this for all the built-in types. I prefer this=20
<br>approach over using string streams when going back-and-forth between=20
<br>built-in types and strings or char*.
<br>
<br>Is there something like this in the C++ standard? Would anyone else fin=
d=20
<br>this useful? Has this been discussed before?
<br>
<br>Thanks,
<br>
<br>Robin
<br></blockquote></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_4280_387550037.1454322238638--
------=_Part_4279_2047096761.1454322238638--
.
Author: Jim Porter <jvp4846@g.rit.edu>
Date: Mon, 1 Feb 2016 13:24:21 -0600
Raw View
On 2/1/2016 4:23 AM, ghanashyam.satpathy@gmail.com wrote:
> Yes I like this approach.Justifies to be more object oriented instead of
> using stol() version of conversion routine.
> So a common template class having toString() would be nice to have for
> all numeric-> string conversion.
Why not just use std::to_string()
<http://en.cppreference.com/w/cpp/string/basic_string/to_string>?
- Jim
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: ghanashyam.satpathy@gmail.com
Date: Mon, 1 Feb 2016 19:31:17 -0800 (PST)
Raw View
------=_Part_1964_1635148660.1454383877690
Content-Type: multipart/alternative;
boundary="----=_Part_1965_611963419.1454383877690"
------=_Part_1965_611963419.1454383877690
Content-Type: text/plain; charset=UTF-8
Well the idea is extending all built-in types (int,short,float..etc)
through class object that has toString() operation.
Otherwise for making a conversion we need to depend on utility functions
like stol() or std::to_string()
Thanks
On Tuesday, February 2, 2016 at 12:54:57 AM UTC+5:30, Jim Porter wrote:
>
> On 2/1/2016 4:23 AM, ghanashya...@gmail.com <javascript:> wrote:
> > Yes I like this approach.Justifies to be more object oriented instead of
> > using stol() version of conversion routine.
> > So a common template class having toString() would be nice to have for
> > all numeric-> string conversion.
>
> Why not just use std::to_string()
> <http://en.cppreference.com/w/cpp/string/basic_string/to_string>?
>
> - Jim
>
>
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1965_611963419.1454383877690
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Well the idea is extending all built-in types (int,short,f=
loat..etc) through class object that has toString() operation.<div>Otherwis=
e for making a conversion we need to depend on utility functions like stol(=
) or std::to_string()</div><div><br></div><div>Thanks<br><br>On Tuesday, Fe=
bruary 2, 2016 at 12:54:57 AM UTC+5:30, Jim Porter wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">On 2/1/2016 4:23 AM, <a href=3D"javascript:" ta=
rget=3D"_blank" gdf-obfuscated-mailto=3D"x04Zgeu5GwAJ" rel=3D"nofollow" onm=
ousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this=
..href=3D'javascript:';return true;">ghanashya...@gmail.com</a> wrot=
e:
<br>> Yes I like this approach.Justifies to be more object oriented inst=
ead of
<br>> using stol() version of conversion routine.
<br>> So a common template class having toString() would be nice to have=
for
<br>> all numeric-> string conversion.
<br>
<br>Why not just use std::to_string()=20
<br><<a href=3D"http://en.cppreference.com/w/cpp/string/basic_string/to_=
string" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'=
http://www.google.com/url?q\75http%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2F=
string%2Fbasic_string%2Fto_string\46sa\75D\46sntz\0751\46usg\75AFQjCNE_1B1X=
cm7KOvuTgx8xs6Drc_t5sQ';return true;" onclick=3D"this.href=3D'http:=
//www.google.com/url?q\75http%3A%2F%2Fen.cppreference.com%2Fw%2Fcpp%2Fstrin=
g%2Fbasic_string%2Fto_string\46sa\75D\46sntz\0751\46usg\75AFQjCNE_1B1Xcm7KO=
vuTgx8xs6Drc_t5sQ';return true;">http://en.cppreference.com/w/<wbr>cpp/=
string/basic_string/to_<wbr>string</a>>?
<br>
<br>- Jim
<br>
<br></blockquote></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_1965_611963419.1454383877690--
------=_Part_1964_1635148660.1454383877690--
.
Author: Jim Porter <jvp4846@g.rit.edu>
Date: Mon, 1 Feb 2016 21:41:23 -0600
Raw View
On 2/1/2016 9:31 PM, ghanashyam.satpathy@gmail.com wrote:
> Well the idea is extending all built-in types (int,short,float..etc)
> through class object that has toString() operation.
> Otherwise for making a conversion we need to depend on utility functions
> like stol() or std::to_string()
Those types already have std::to_string() as a free function, as shown
in the link I provided. What are you proposing to add? I don't see any
benefit in providing a to_string() member function when an existing free
function provides what you seem to be asking for.
I could see an argument for extending the list of types that have a
std::to_string overload (e.g. one taking std::string to aid in generic
programming), or even allowing users to overload std::to_string, but
that doesn't sound like what you're proposing.
- Jim
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: ghanashyam.satpathy@gmail.com
Date: Mon, 1 Feb 2016 22:19:42 -0800 (PST)
Raw View
------=_Part_424_81668920.1454393982418
Content-Type: multipart/alternative;
boundary="----=_Part_425_1781519579.1454393982418"
------=_Part_425_1781519579.1454393982418
Content-Type: text/plain; charset=UTF-8
Are basic types like (int,float and short) are objects in C++ ? Feature
which is available in languages like JAVA and C#.
Or is there a way those types can be extended to be a Class Object?
On Tuesday, February 2, 2016 at 9:11:43 AM UTC+5:30, Jim Porter wrote:
>
> On 2/1/2016 9:31 PM, ghanashya...@gmail.com <javascript:> wrote:
> > Well the idea is extending all built-in types (int,short,float..etc)
> > through class object that has toString() operation.
> > Otherwise for making a conversion we need to depend on utility functions
> > like stol() or std::to_string()
>
> Those types already have std::to_string() as a free function, as shown
> in the link I provided. What are you proposing to add? I don't see any
> benefit in providing a to_string() member function when an existing free
> function provides what you seem to be asking for.
>
> I could see an argument for extending the list of types that have a
> std::to_string overload (e.g. one taking std::string to aid in generic
> programming), or even allowing users to overload std::to_string, but
> that doesn't sound like what you're proposing.
>
> - Jim
>
>
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_425_1781519579.1454393982418
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Are basic types like (int,float and short) are objects in =
C++ ? Feature which is available in languages like JAVA and C#.<div>Or is t=
here a way those types can be extended to be a Class Object?<br><br>On Tues=
day, February 2, 2016 at 9:11:43 AM UTC+5:30, Jim Porter wrote:<blockquote =
class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1p=
x #ccc solid;padding-left: 1ex;">On 2/1/2016 9:31 PM, <a href=3D"javascript=
:" target=3D"_blank" gdf-obfuscated-mailto=3D"4LU2LwfVGwAJ" rel=3D"nofollow=
" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D=
"this.href=3D'javascript:';return true;">ghanashya...@gmail.com</a>=
wrote:
<br>> Well the idea is extending all built-in types (int,short,float..et=
c)
<br>> through class object that has toString() operation.
<br>> Otherwise for making a conversion we need to depend on utility fun=
ctions
<br>> like stol() or std::to_string()
<br>
<br>Those types already have std::to_string() as a free function, as shown=
=20
<br>in the link I provided. What are you proposing to add? I don't see =
any=20
<br>benefit in providing a to_string() member function when an existing fre=
e=20
<br>function provides what you seem to be asking for.
<br>
<br>I could see an argument for extending the list of types that have a=20
<br>std::to_string overload (e.g. one taking std::string to aid in generic=
=20
<br>programming), or even allowing users to overload std::to_string, but=20
<br>that doesn't sound like what you're proposing.
<br>
<br>- Jim
<br>
<br></blockquote></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_425_1781519579.1454393982418--
------=_Part_424_81668920.1454393982418--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Mon, 01 Feb 2016 22:26:01 -0800
Raw View
On Monday 01 February 2016 22:19:42 ghanashyam.satpathy@gmail.com wrote:
> Are basic types like (int,float and short) are objects in C++ ?
No
> Feature
> which is available in languages like JAVA and C#.
> Or is there a way those types can be extended to be a Class Object?
I don't think it can be done, and moreover there's no interest in doing it.
--
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: ghanashyam.satpathy@gmail.com
Date: Mon, 1 Feb 2016 22:32:33 -0800 (PST)
Raw View
------=_Part_2256_814699138.1454394753355
Content-Type: multipart/alternative;
boundary="----=_Part_2257_523486919.1454394753355"
------=_Part_2257_523486919.1454394753355
Content-Type: text/plain; charset=UTF-8
>and moreover there's no interest in doing it.
Why no interest ?
On Tuesday, February 2, 2016 at 11:56:06 AM UTC+5:30, Thiago Macieira wrote:
>
> On Monday 01 February 2016 22:19:42 ghanashya...@gmail.com <javascript:>
> wrote:
> > Are basic types like (int,float and short) are objects in C++ ?
>
> No
>
> > Feature
> > which is available in languages like JAVA and C#.
> > Or is there a way those types can be extended to be a Class Object?
>
> I don't think it can be done, and moreover there's no interest in doing
> it.
> --
> 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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_2257_523486919.1454394753355
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><br></div>>and moreover there's no interest in=
doing it.<div><br></div><div>Why no interest ?=C2=A0<br><br>On Tuesday, Fe=
bruary 2, 2016 at 11:56:06 AM UTC+5:30, Thiago Macieira wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
#ccc solid;padding-left: 1ex;">On Monday 01 February 2016 22:19:42 <a href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"qRuxkv_dGwAJ" r=
el=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';return tru=
e;" onclick=3D"this.href=3D'javascript:';return true;">ghanashya...=
@gmail.com</a> wrote:
<br>> Are basic types like (int,float and short) are objects in C++ ?=20
<br>
<br>No
<br>
<br>> Feature
<br>> which is available in languages like JAVA and C#.
<br>> Or is there a way those types can be extended to be a Class Object=
?
<br>
<br>I don't think it can be done, and moreover there's no interest =
in doing it.
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQ=
jCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=3D&=
#39;http://www.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46snt=
z\0751\46usg\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;">maciei=
ra.info</a> - thiago (AT) <a href=3D"http://kde.org" target=3D"_blank" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\7=
5http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1Dowztw=
AHAKs80XSA';return true;" onclick=3D"this.href=3D'http://www.google=
..com/url?q\75http%3A%2F%2Fkde.org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo=
5_JYG1DowztwAHAKs80XSA';return true;">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></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_2257_523486919.1454394753355--
------=_Part_2256_814699138.1454394753355--
.
Author: Thiago Macieira <thiago@macieira.org>
Date: Mon, 01 Feb 2016 22:37:30 -0800
Raw View
On Monday 01 February 2016 22:32:33 ghanashyam.satpathy@gmail.com wrote:
> >and moreover there's no interest in doing it.
>
> Why no interest ?
Because there is no interest in adding members to such an object. As you've
seen from the this thread, when the free function std::to_string was proposed
as a solution instead.
There's an extremely high barrier of entry for modifying the language, when a
library solution is possible. Since it is...
--
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Jim Porter <jvp4846@g.rit.edu>
Date: Tue, 2 Feb 2016 02:47:57 -0600
Raw View
On 2/2/2016 12:19 AM, ghanashyam.satpathy@gmail.com wrote:
> Are basic types like (int,float and short) are objects in C++ ? Feature
> which is available in languages like JAVA and C#.
> Or is there a way those types can be extended to be a Class Object?
Why do they need to be? I'm not clear on what benefit this provides. C++
isn't Java or C#, and there's no need to imitate them when C++ already
provides the same functionality with a different interface.
- Jim
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 2 Feb 2016 07:58:18 -0800 (PST)
Raw View
------=_Part_7847_1833672569.1454428698525
Content-Type: multipart/alternative;
boundary="----=_Part_7848_980971894.1454428698525"
------=_Part_7848_980971894.1454428698525
Content-Type: text/plain; charset=UTF-8
On Tuesday, February 2, 2016 at 1:19:42 AM UTC-5, ghanashya...@gmail.com
wrote:
>
> Are basic types like (int,float and short) are objects in C++ ?
>
In the tecnical sense? Yes; basic types are objects.
But they are not *objects of class types*. They do not have member
functions.
> Feature which is available in languages like JAVA and C#.
> Or is there a way those types can be extended to be a Class Object?
>
I think the problem you have is a restrictive, OOP focused view of the
world.
The important thing is to have the ability to be able to convert types into
strings, yes? That's what matters in the end: having a unified interface
such that, if you have an object, you can apply this interface to get a
string.
Java (not an ACRONYM) and C# provide this interface as a member function of
some base class that everything inherits (except in C#, not everything
inherits from it. Struct types are not like Classes
<https://msdn.microsoft.com/en-us/library/ms229017%28v=vs.110%29.aspx>, so
they don't define that interface). But this is simply *one means* of
providing such functionality. It is not the "one true way" of doing it.
In Java and C#, if you want to allow an operation to be done on any type,
you stick a method in the base class. In C++, we have other options.
If you have an operation that can be done on any type, that kind of
operation in C++ is spelled "template". So you would have a template
function that takes any type T and returns a string. Of course, you need
function specializations for the basic types. And users can add
specializations for their own types as well, allowing users to write
class-specific implementations of this functionality.
The goal is to be able to turn any type into a string. Exactly *how* you do
that is irrelevant; the member function method is in no way superior to the
global template function method. Each simply plays into the strengths of
their respective languages.
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_7848_980971894.1454428698525
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Tuesday, February 2, 2016 at 1:19:42 AM UTC-5, ghanashy=
a...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Are basic types like (int,float and short) are objects in C++ ?</d=
iv></blockquote><div><br>In the tecnical sense? Yes; basic types are object=
s.<br><br>But they are not <i>objects of class types</i>. They do not have =
member functions.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D=
"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex=
;"><div dir=3D"ltr">Feature which is available in languages like JAVA and C=
#.<div>Or is there a way those types can be extended to be a Class Object?<=
/div></div></blockquote><div><br>I think the problem you have is a restrict=
ive, OOP focused view of the world.<br><br>The important thing is to have t=
he ability to be able to convert types into strings, yes? That's what m=
atters in the end: having a unified interface such that, if you have an obj=
ect, you can apply this interface to get a string.<br><br>Java (not an ACRO=
NYM) and C# provide this interface as a member function of some base class =
that everything inherits (except in C#, not everything inherits from it. <a=
href=3D"https://msdn.microsoft.com/en-us/library/ms229017%28v=3Dvs.110%29.=
aspx">Struct types are not like Classes</a>, so they don't define that =
interface). But this is simply <i>one means</i> of providing such functiona=
lity. It is not the "one true way" of doing it.<br><br>In Java an=
d C#, if you want to allow an operation to be done on any type, you stick a=
method in the base class. In C++, we have other options.<br><br>If you hav=
e an operation that can be done on any type, that kind of operation in C++ =
is spelled "template". So you would have a template function that=
takes any type T and returns a string. Of course, you need function specia=
lizations for the basic types. And users can add specializations for their =
own types as well, allowing users to write class-specific implementations o=
f this functionality.<br><br>The goal is to be able to turn any type into a=
string. Exactly <i>how</i> you do that is irrelevant; the member function =
method is in no way superior to the global template function method. Each s=
imply plays into the strengths of their respective languages.<br></div></di=
v>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_7848_980971894.1454428698525--
------=_Part_7847_1833672569.1454428698525--
.
Author: Bo Persson <bop@gmb.dk>
Date: Tue, 2 Feb 2016 17:53:55 +0100
Raw View
On 2016-02-02 07:19, ghanashyam.satpathy@gmail.com wrote:
> Are basic types like (int,float and short) are objects in C++ ? Feature
> which is available in languages like JAVA and C#.
> Or is there a way those types can be extended to be a Class Object?
>
There is no need to extend them, as in C++ you can write free functions.
The conversion functions don't have to be a member of an object to
convert a value.
Instead of
s = i.to_string();
you just write
s = to_string(i);
Bo Persson
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: ghanashyam.satpathy@gmail.com
Date: Wed, 3 Feb 2016 00:16:46 -0800 (PST)
Raw View
------=_Part_617_529608029.1454487406164
Content-Type: multipart/alternative;
boundary="----=_Part_618_1343378997.1454487406164"
------=_Part_618_1343378997.1454487406164
Content-Type: text/plain; charset=UTF-8
Thanks, Very good analysis.
Having implementations through global template opens few issues which
Developer commits often .Sometime it is global/static variable without
proper synchronization and similar.For a beginner it will be always a
learning curve to find the operations supported through global template,
and to use std::to_string() or stol()..
In this context is interface based implementation not more beneficial than
global template based implementation.
On Tuesday, February 2, 2016 at 9:28:18 PM UTC+5:30, Nicol Bolas wrote:
>
> On Tuesday, February 2, 2016 at 1:19:42 AM UTC-5, ghanashya...@gmail.com
> wrote:
>>
>> Are basic types like (int,float and short) are objects in C++ ?
>>
>
> In the tecnical sense? Yes; basic types are objects.
>
> But they are not *objects of class types*. They do not have member
> functions.
>
>
>> Feature which is available in languages like JAVA and C#.
>> Or is there a way those types can be extended to be a Class Object?
>>
>
> I think the problem you have is a restrictive, OOP focused view of the
> world.
>
> The important thing is to have the ability to be able to convert types
> into strings, yes? That's what matters in the end: having a unified
> interface such that, if you have an object, you can apply this interface to
> get a string.
>
> Java (not an ACRONYM) and C# provide this interface as a member function
> of some base class that everything inherits (except in C#, not everything
> inherits from it. Struct types are not like Classes
> <https://msdn.microsoft.com/en-us/library/ms229017%28v=vs.110%29.aspx>,
> so they don't define that interface). But this is simply *one means* of
> providing such functionality. It is not the "one true way" of doing it.
>
> In Java and C#, if you want to allow an operation to be done on any type,
> you stick a method in the base class. In C++, we have other options.
>
> If you have an operation that can be done on any type, that kind of
> operation in C++ is spelled "template". So you would have a template
> function that takes any type T and returns a string. Of course, you need
> function specializations for the basic types. And users can add
> specializations for their own types as well, allowing users to write
> class-specific implementations of this functionality.
>
> The goal is to be able to turn any type into a string. Exactly *how* you
> do that is irrelevant; the member function method is in no way superior to
> the global template function method. Each simply plays into the strengths
> of their respective languages.
>
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_618_1343378997.1454487406164
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span style=3D"font-family: arial, sans-serif; font-size: =
12.8px;">Thanks, Very good analysis.</span><div style=3D"font-family: arial=
, sans-serif; font-size: 12.8px;"><br></div><div style=3D"font-family: aria=
l, sans-serif; font-size: 12.8px;">Having implementations through global te=
mplate opens few issues which Developer commits often .Sometime it is globa=
l/static variable without proper synchronization and similar.For a beginner=
it will be always a learning curve to find the operations supported throug=
h global template, and to use std::to_string() or stol()..</div><div style=
=3D"font-family: arial, sans-serif; font-size: 12.8px;"><br></div><div styl=
e=3D"font-family: arial, sans-serif; font-size: 12.8px;">In this context is=
interface based implementation not more beneficial than global template ba=
sed implementation.</div><div style=3D"font-family: arial, sans-serif; font=
-size: 12.8px;"><br></div><br>On Tuesday, February 2, 2016 at 9:28:18 PM UT=
C+5:30, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin=
: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div=
dir=3D"ltr">On Tuesday, February 2, 2016 at 1:19:42 AM UTC-5, <a>ghanashya=
....@gmail.com</a> wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0=
;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D=
"ltr">Are basic types like (int,float and short) are objects in C++ ?</div>=
</blockquote><div><br>In the tecnical sense? Yes; basic types are objects.<=
br><br>But they are not <i>objects of class types</i>. They do not have mem=
ber functions.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"ltr">Feature which is available in languages like JAVA and C#.<div>O=
r is there a way those types can be extended to be a Class Object?</div></d=
iv></blockquote><div><br>I think the problem you have is a restrictive, OOP=
focused view of the world.<br><br>The important thing is to have the abili=
ty to be able to convert types into strings, yes? That's what matters i=
n the end: having a unified interface such that, if you have an object, you=
can apply this interface to get a string.<br><br>Java (not an ACRONYM) and=
C# provide this interface as a member function of some base class that eve=
rything inherits (except in C#, not everything inherits from it. <a href=3D=
"https://msdn.microsoft.com/en-us/library/ms229017%28v=3Dvs.110%29.aspx" ta=
rget=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://ww=
w.google.com/url?q\75https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fm=
s229017%2528v%3Dvs.110%2529.aspx\46sa\75D\46sntz\0751\46usg\75AFQjCNH6nByQg=
OADWihkzyGsb7gefoeDvA';return true;" onclick=3D"this.href=3D'https:=
//www.google.com/url?q\75https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary=
%2Fms229017%2528v%3Dvs.110%2529.aspx\46sa\75D\46sntz\0751\46usg\75AFQjCNH6n=
ByQgOADWihkzyGsb7gefoeDvA';return true;">Struct types are not like Clas=
ses</a>, so they don't define that interface). But this is simply <i>on=
e means</i> of providing such functionality. It is not the "one true w=
ay" of doing it.<br><br>In Java and C#, if you want to allow an operat=
ion to be done on any type, you stick a method in the base class. In C++, w=
e have other options.<br><br>If you have an operation that can be done on a=
ny type, that kind of operation in C++ is spelled "template". So =
you would have a template function that takes any type T and returns a stri=
ng. Of course, you need function specializations for the basic types. And u=
sers can add specializations for their own types as well, allowing users to=
write class-specific implementations of this functionality.<br><br>The goa=
l is to be able to turn any type into a string. Exactly <i>how</i> you do t=
hat is irrelevant; the member function method is in no way superior to the =
global template function method. Each simply plays into the strengths of th=
eir respective languages.<br></div></div></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_618_1343378997.1454487406164--
------=_Part_617_529608029.1454487406164--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 3 Feb 2016 06:16:28 -0800 (PST)
Raw View
------=_Part_10649_1605481138.1454508988329
Content-Type: multipart/alternative;
boundary="----=_Part_10650_144424841.1454508988330"
------=_Part_10650_144424841.1454508988330
Content-Type: text/plain; charset=UTF-8
On Wednesday, February 3, 2016 at 3:16:46 AM UTC-5, ghanashya...@gmail.com
wrote:
>
> Thanks, Very good analysis.
>
> Having implementations through global template opens few issues which
> Developer commits often .Sometime it is global/static variable without
> proper synchronization and similar.
>
.... what? What does having a global template function have to do with
variables?
> For a beginner it will be always a learning curve to find the operations
> supported through global template, and to use std::to_string() or stol()..
>
Nonsense. Beginners do as they are *taught*. If they are not taught to
assume that every important function to a class is a member, then they will
not assume that it is. If they are taught to use `to_string` or
`operator<<` or whatever to convert a type to a string, then that is what
they will use.
"Beginner to C++" does not mean "*Java programmer*". And even if it did,
they should still seek out the proper idioms for the new and very different
language they're working in.
Not to mention, since compilers will soon be getting the ability to
syntactically make `f(x, y)` call `x.f(y)` when it is available
<http://wg21.link/P0131>, beginners will be seeing a *lot more* "global"
functions than they ever have before. Also note that we won't be getting
the reverse: the ability to have compilers turn `x.f(y)` into `f(x, y)`.
So the sooner such beginners stop assuming that member functions are the
best interface for manipulating objects, the better.
> In this context is interface based implementation not more beneficial than
> global template based implementation.
>
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_10650_144424841.1454508988330
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, February 3, 2016 at 3:16:46 AM UTC-5, ghanas=
hya...@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div di=
r=3D"ltr"><span style=3D"font-family:arial,sans-serif;font-size:12.8px">Tha=
nks, Very good analysis.</span><div style=3D"font-family:arial,sans-serif;f=
ont-size:12.8px"><br></div><div style=3D"font-family:arial,sans-serif;font-=
size:12.8px">Having implementations through global template opens few issue=
s which Developer commits often .Sometime it is global/static variable with=
out proper synchronization and similar.</div></div></blockquote><div><br>..=
.. what? What does having a global template function have to do with variabl=
es?<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><div style=3D"font-family:arial,sans-serif;font-size:12.8px">For a be=
ginner it will be always a learning curve to find the operations supported =
through global template, and to use std::to_string() or stol()..</div></div=
></blockquote><div><br>Nonsense. Beginners do as they are <i>taught</i>. If=
they are not taught to assume that every important function to a class is =
a member, then they will not assume that it is. If they are taught to use `=
to_string` or `operator<<` or whatever to convert a type to a string,=
then that is what they will use.<br><br>"Beginner to C++" does n=
ot mean "<i>Java programmer</i>". And even if it did, they should=
still seek out the proper idioms for the new and very different language t=
hey're working in.<br><br>Not to mention, since compilers will <a href=
=3D"http://wg21.link/P0131">soon be getting the ability to syntactically ma=
ke `f(x, y)` call `x.f(y)` when it is available</a>, beginners will be seei=
ng a <i>lot more</i> "global" functions than they ever have befor=
e. Also note that we won't be getting the reverse: the ability to have =
compilers turn `x.f(y)` into `f(x, y)`.<br><br>So the sooner such beginners=
stop assuming that member functions are the best interface for manipulatin=
g objects, the better.<br>=C2=A0<br></div><blockquote class=3D"gmail_quote"=
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-=
left: 1ex;"><div dir=3D"ltr"><div style=3D"font-family:arial,sans-serif;fon=
t-size:12.8px"></div><div style=3D"font-family:arial,sans-serif;font-size:1=
2.8px">In this context is interface based implementation not more beneficia=
l than global template based implementation.</div></div></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_10650_144424841.1454508988330--
------=_Part_10649_1605481138.1454508988329--
.
Author: ghanashyam.satpathy@gmail.com
Date: Wed, 3 Feb 2016 06:57:12 -0800 (PST)
Raw View
------=_Part_4527_1040680287.1454511432928
Content-Type: multipart/alternative;
boundary="----=_Part_4528_915222126.1454511432928"
------=_Part_4528_915222126.1454511432928
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
"Unified Call Syntax" where f(x,y) will call x.f(y) makes sense. From the=
=20
link you provided I found following as basic proposal. Is this being=20
accepted ?=20
The basic proposal is =E2=80=A2
A call x.f(y) will first look for members of x=E2=80=99s class (as ever) a=
nd if no=20
valid call is found will look for functions as if f(x,y) had been written =
=E2=80=A2=20
A call, f(x,y) fist looks for functions (as ever) and if no valid call is=
=20
found looks for functions as if x.f(y) had been written=20
This breaks no existing code. The perceived benefits are =E2=80=A2 Ease of =
use: a=20
caller need not know whether a function is implemented as a member or a=20
freestanding function or a lambda...
On Wednesday, February 3, 2016 at 7:46:28 PM UTC+5:30, Nicol Bolas wrote:
>
> On Wednesday, February 3, 2016 at 3:16:46 AM UTC-5, ghanashya...@gmail.co=
m=20
> wrote:
>>
>> Thanks, Very good analysis.
>>
>> Having implementations through global template opens few issues which=20
>> Developer commits often .Sometime it is global/static variable without=
=20
>> proper synchronization and similar.
>>
>
> ... what? What does having a global template function have to do with=20
> variables?
> =20
>
>> For a beginner it will be always a learning curve to find the operations=
=20
>> supported through global template, and to use std::to_string() or stol()=
...
>>
>
> Nonsense. Beginners do as they are *taught*. If they are not taught to=20
> assume that every important function to a class is a member, then they wi=
ll=20
> not assume that it is. If they are taught to use `to_string` or=20
> `operator<<` or whatever to convert a type to a string, then that is what=
=20
> they will use.
>
> "Beginner to C++" does not mean "*Java programmer*". And even if it did,=
=20
> they should still seek out the proper idioms for the new and very differe=
nt=20
> language they're working in.
>
> Not to mention, since compilers will soon be getting the ability to=20
> syntactically make `f(x, y)` call `x.f(y)` when it is available=20
> <http://wg21.link/P0131>, beginners will be seeing a *lot more* "global"=
=20
> functions than they ever have before. Also note that we won't be getting=
=20
> the reverse: the ability to have compilers turn `x.f(y)` into `f(x, y)`.
>
> So the sooner such beginners stop assuming that member functions are the=
=20
> best interface for manipulating objects, the better.
> =20
>
>> In this context is interface based implementation not more beneficial=20
>> than global template based implementation.
>>
>
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
------=_Part_4528_915222126.1454511432928
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">"Unified Call Syntax" where f(x,y) will call x.f=
(y) makes sense. From the link you provided I found following as basic prop=
osal. Is this being accepted ?=C2=A0<div><br><div>The basic proposal is =E2=
=80=A2</div><div><br></div><div>=C2=A0A call x.f(y) will first look for mem=
bers of x=E2=80=99s class (as ever) and if no valid call is found will look=
for functions as if f(x,y) had been written =E2=80=A2=C2=A0</div><div>A ca=
ll, f(x,y) fist looks for functions (as ever) and if no valid call is found=
looks for functions as if x.f(y) had been written=C2=A0</div><div><br></di=
v><div>This breaks no existing code. The perceived benefits are =E2=80=A2 E=
ase of use: a caller need not know whether a function is implemented as a m=
ember or a freestanding function or a lambda...<br><br>On Wednesday, Februa=
ry 3, 2016 at 7:46:28 PM UTC+5:30, Nicol Bolas wrote:<blockquote class=3D"g=
mail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc sol=
id;padding-left: 1ex;"><div dir=3D"ltr">On Wednesday, February 3, 2016 at 3=
:16:46 AM UTC-5, <a>ghanashya...@gmail.com</a> wrote:<blockquote class=3D"g=
mail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;=
padding-left:1ex"><div dir=3D"ltr"><span style=3D"font-family:arial,sans-se=
rif;font-size:12.8px">Thanks, Very good analysis.</span><div style=3D"font-=
family:arial,sans-serif;font-size:12.8px"><br></div><div style=3D"font-fami=
ly:arial,sans-serif;font-size:12.8px">Having implementations through global=
template opens few issues which Developer commits often .Sometime it is gl=
obal/static variable without proper synchronization and similar.</div></div=
></blockquote><div><br>... what? What does having a global template functio=
n have to do with variables?<br>=C2=A0</div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr"><div style=3D"font-family:arial,sans-serif;font-s=
ize:12.8px">For a beginner it will be always a learning curve to find the o=
perations supported through global template, and to use std::to_string() or=
stol()..</div></div></blockquote><div><br>Nonsense. Beginners do as they a=
re <i>taught</i>. If they are not taught to assume that every important fun=
ction to a class is a member, then they will not assume that it is. If they=
are taught to use `to_string` or `operator<<` or whatever to convert=
a type to a string, then that is what they will use.<br><br>"Beginner=
to C++" does not mean "<i>Java programmer</i>". And even if=
it did, they should still seek out the proper idioms for the new and very =
different language they're working in.<br><br>Not to mention, since com=
pilers will <a href=3D"http://wg21.link/P0131" target=3D"_blank" rel=3D"nof=
ollow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3=
A%2F%2Fwg21.link%2FP0131\46sa\75D\46sntz\0751\46usg\75AFQjCNGITxZUsDvHMOKRP=
YQAkkHUdivOEg';return true;" onclick=3D"this.href=3D'http://www.goo=
gle.com/url?q\75http%3A%2F%2Fwg21.link%2FP0131\46sa\75D\46sntz\0751\46usg\7=
5AFQjCNGITxZUsDvHMOKRPYQAkkHUdivOEg';return true;">soon be getting the =
ability to syntactically make `f(x, y)` call `x.f(y)` when it is available<=
/a>, beginners will be seeing a <i>lot more</i> "global" function=
s than they ever have before. Also note that we won't be getting the re=
verse: the ability to have compilers turn `x.f(y)` into `f(x, y)`.<br><br>S=
o the sooner such beginners stop assuming that member functions are the bes=
t interface for manipulating objects, the better.<br>=C2=A0<br></div><block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div style=3D"font-famil=
y:arial,sans-serif;font-size:12.8px"></div><div style=3D"font-family:arial,=
sans-serif;font-size:12.8px">In this context is interface based implementat=
ion not more beneficial than global template based implementation.</div></d=
iv></blockquote></div></blockquote></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_4528_915222126.1454511432928--
------=_Part_4527_1040680287.1454511432928--
.
Author: Adrian Wielgosik <adrian.wielgosik@gmail.com>
Date: Wed, 3 Feb 2016 07:23:29 -0800 (PST)
Raw View
------=_Part_34_1253187119.1454513009550
Content-Type: multipart/alternative;
boundary="----=_Part_35_1912876427.1454513009551"
------=_Part_35_1912876427.1454513009551
Content-Type: text/plain; charset=UTF-8
On Wednesday, February 3, 2016 at 3:16:28 PM UTC+1, Nicol Bolas wrote:
>
> Not to mention, since compilers will soon be getting the ability to
> syntactically make `f(x, y)` call `x.f(y)` when it is available
> <http://wg21.link/P0131>, beginners will be seeing a *lot more* "global"
> functions than they ever have before. Also note that we won't be getting
> the reverse: the ability to have compilers turn `x.f(y)` into `f(x, y)`.
>
> So the sooner such beginners stop assuming that member functions are the
> best interface for manipulating objects, the better.
>
>
I would argue that won't really change that much. Yes, it's great for
writing generic code (it's the proposal's primary goal, after all) and will
be very common there. But I think there's a reason why I've seen many
people still want to use the reverse way. When I'll be given an option to
change my current `x.f1().f2()` to more generic `f1(f2(x))` in my
application code I probably won't take it. Heck, I'm still using member
..begin() even though std::begin is technically better.
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_35_1912876427.1454513009551
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, February 3, 2016 at 3:16:28 PM UTC+1=
, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Not to mention, since compilers will <a href=3D"http://wg21.link/P=
0131" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'ht=
tp://www.google.com/url?q\75http%3A%2F%2Fwg21.link%2FP0131\46sa\75D\46sntz\=
0751\46usg\75AFQjCNGITxZUsDvHMOKRPYQAkkHUdivOEg';return true;" onclick=
=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fwg21.link%2=
FP0131\46sa\75D\46sntz\0751\46usg\75AFQjCNGITxZUsDvHMOKRPYQAkkHUdivOEg'=
;return true;">soon be getting the ability to syntactically make `f(x, y)` =
call `x.f(y)` when it is available</a>, beginners will be seeing a <i>lot m=
ore</i> "global" functions than they ever have before. Also note =
that we won't be getting the reverse: the ability to have compilers tur=
n `x.f(y)` into `f(x, y)`.<br><br>So the sooner such beginners stop assumin=
g that member functions are the best interface for manipulating objects, th=
e better.<br><br></div></blockquote><div><br></div><div>I would argue that =
won't really change that much. Yes, it's great for writing generic =
code (it's the proposal's primary goal, after all) and will be very=
common there. But I think there's a reason why I've seen many peop=
le still want to use the reverse way. When I'll be given an option to c=
hange my current `x.f1().f2()` to more generic `f1(f2(x))` in my applicatio=
n code I probably won't take it. Heck, I'm still using member .begi=
n() even though std::begin is technically better.</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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_35_1912876427.1454513009551--
------=_Part_34_1253187119.1454513009550--
.
Author: Jim Porter <jvp4846@g.rit.edu>
Date: Wed, 3 Feb 2016 14:01:28 -0600
Raw View
On 2/3/2016 8:16 AM, Nicol Bolas wrote:
> Not to mention, since compilers will soon be getting the ability to
> syntactically make `f(x, y)` call `x.f(y)` when it is available
> <http://wg21.link/P0131>, beginners will be seeing a /lot more/ "global"
> functions than they ever have before. Also note that we won't be getting
> the reverse: the ability to have compilers turn `x.f(y)` into `f(x, y)`.
I'm secretly hoping this won't be standardized, since I think the
benefits are extremely dubious. You get most of the stated benefits in
that paper by just saying, "(almost) everything should be a free
function." The only major thing you'd lose out on is functional notation
for virtual functions, which would make generic programming harder. (As
you can probably tell, I vastly prefer free functions over member
functions in general[1].)
However, I'm not convinced that that alone outweighs the risks. My
biggest concern is that it results in two syntaxes that do *almost* the
exact same thing, except sometimes it's subtly different because the
rules for which function is chosen vary when there are both member and
non-member versions. It's effectively training people to treat the two
syntaxes as synonyms, but adding a special edge case to bite them later
on. Option 5 from N4474 (use overload resolution to get consistent
results) would eliminate this concern, of course.
N4474 also indicates that a "major motivator" for Herb Sutter is that
this would improve autocompletion in editors. I don't think that should
have any bearing on the acceptance of this. If autocompletion for free
functions is a feature you'd like in your editor, you can add that
today. Autocomplete already transforms the code you're typing by
appending new text after your cursor, so I don't see anything wrong with
slightly more-intrusive transformations. For example, you could type
"foo.", pick a free function from the autocomplete list, and see your
code change to "func(foo". It just requires the editor to add all
relevant free functions to the autocomplete list and to know how to
expand them. It's not clear to me how unified call syntax would make
this easier.
- Jim
[1] In fact, I seem to recall a story about how the initial proposal for
the standard containers had begin, end, and size as free functions, but
the proposer made them member functions to make it more palatable to the
committee at the time.
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 3 Feb 2016 14:49:15 -0800 (PST)
Raw View
------=_Part_9951_476504797.1454539755850
Content-Type: multipart/alternative;
boundary="----=_Part_9952_142908087.1454539755850"
------=_Part_9952_142908087.1454539755850
Content-Type: text/plain; charset=UTF-8
On Wednesday, February 3, 2016 at 3:01:55 PM UTC-5, Jim Porter wrote:
>
> On 2/3/2016 8:16 AM, Nicol Bolas wrote:
> > Not to mention, since compilers will soon be getting the ability to
> > syntactically make `f(x, y)` call `x.f(y)` when it is available
> > <http://wg21.link/P0131>, beginners will be seeing a /lot more/
> "global"
> > functions than they ever have before. Also note that we won't be getting
> > the reverse: the ability to have compilers turn `x.f(y)` into `f(x, y)`.
>
> I'm secretly hoping this won't be standardized, since I think the
> benefits are extremely dubious. You get most of the stated benefits in
> that paper by just saying, "(almost) everything should be a free
> function."
OK, let's pretend we live in a magical fantasy world where the word of
Bjarne Stroustrup is instantly accepted as law among all C++ programmers.
And therefore, when he arbitrary declares "Thou shalt not write a member
function unless you have no other choice", that's what we all do. Sure,
that's never going to happen, but again, we're pretending here.
That will do squat for the literally *billions* of lines of already
existing C++ code. So in order for this rule to give you "most of the
stated benefits" of the proposal, you would also need to give Bjarne
Stroustrup the ability to magically rewrite every line of C++ that already
exists.
Or we could do something that is actually *possible*.
However, I'm not convinced that that alone outweighs the risks. My
> biggest concern is that it results in two syntaxes that do *almost* the
> exact same thing, except sometimes it's subtly different because the
> rules for which function is chosen vary when there are both member and
> non-member versions. It's effectively training people to treat the two
> syntaxes as synonyms, but adding a special edge case to bite them later
> on. Option 5 from N4474 (use overload resolution to get consistent
> results) would eliminate this concern, of course.
>
Two syntaxes? You may not have heard, but at Kona
<https://isocpp.org/blog/2015/11/kona-standards-meeting-trip-report>, the
committee agreed to toss the `x.f -> f(x)` transformation. So all that's
left for unified function syntax is `f(x) -> x.f` where possible.
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_9952_142908087.1454539755850
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, February 3, 2016 at 3:01:55 PM UTC-5, Jim Po=
rter wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2/3/2016 8:16 AM=
, Nicol Bolas wrote:
<br>> Not to mention, since compilers will soon be getting the ability t=
o
<br>> syntactically make `f(x, y)` call `x.f(y)` when it is available
<br>> <<a href=3D"http://wg21.link/P0131" target=3D"_blank" rel=3D"no=
follow" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fwg21.link%2FP0131\46sa\75D\46sntz\0751\46usg\75AFQjCNGITxZUsDvHMOKR=
PYQAkkHUdivOEg';return true;" onclick=3D"this.href=3D'http://www.go=
ogle.com/url?q\75http%3A%2F%2Fwg21.link%2FP0131\46sa\75D\46sntz\0751\46usg\=
75AFQjCNGITxZUsDvHMOKRPYQAkkHUdivOEg';return true;">http://wg21.link/P0=
131</a>>, beginners will be seeing a /lot more/ "global"
<br>> functions than they ever have before. Also note that we won't =
be getting
<br>> the reverse: the ability to have compilers turn `x.f(y)` into `f(x=
, y)`.
<br>
<br>I'm secretly hoping this won't be standardized, since I think t=
he=20
<br>benefits are extremely dubious. You get most of the stated benefits in=
=20
<br>that paper by just saying, "(almost) everything should be a free=
=20
<br>function."</blockquote><div><br>OK, let's pretend we live in a=
magical fantasy world where the word of Bjarne Stroustrup is instantly acc=
epted as law among all C++ programmers. And therefore, when he arbitrary de=
clares "Thou shalt not write a member function unless you have no othe=
r choice", that's what we all do. Sure, that's never going to =
happen, but again, we're pretending here.<br><br>That will do squat for=
the literally <i>billions</i> of lines of already existing C++ code. So in=
order for this rule to give you "most of the stated benefits" of=
the proposal, you would also need to give Bjarne Stroustrup the ability to=
magically rewrite every line of C++ that already exists.<br><br>Or we coul=
d do something that is actually <i>possible</i>.<br><br></div><div></div><b=
lockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;borde=
r-left: 1px #ccc solid;padding-left: 1ex;">However, I'm not convinced t=
hat that alone outweighs the risks. My=20
<br>biggest concern is that it results in two syntaxes that do *almost* the=
=20
<br>exact same thing, except sometimes it's subtly different because th=
e=20
<br>rules for which function is chosen vary when there are both member and=
=20
<br>non-member versions. It's effectively training people to treat the =
two=20
<br>syntaxes as synonyms, but adding a special edge case to bite them later=
=20
<br>on. Option 5 from N4474 (use overload resolution to get consistent=20
<br>results) would eliminate this concern, of course.<br></blockquote><div>=
<br>Two syntaxes? You may not have heard, but <a href=3D"https://isocpp.org=
/blog/2015/11/kona-standards-meeting-trip-report">at Kona</a>, the committe=
e agreed to toss the `x.f -> f(x)` transformation. So all that's lef=
t for unified function syntax is `f(x) -> x.f` where possible.</div></di=
v>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_9952_142908087.1454539755850--
------=_Part_9951_476504797.1454539755850--
.
Author: Jim Porter <jvp4846@g.rit.edu>
Date: Wed, 3 Feb 2016 17:25:21 -0600
Raw View
On 2/3/2016 4:49 PM, Nicol Bolas wrote:
> That will do squat for the literally /billions/ of lines of already
> existing C++ code. So in order for this rule to give you "most of the
> stated benefits" of the proposal, you would also need to give Bjarne
> Stroustrup the ability to magically rewrite every line of C++ that
> already exists.
I doubt that existing C++ code that's not already designed to be used
for generic programming would benefit much from unified function call
syntax; if your homegrown container class uses a.Count() instead of
a.size(), you're still out of luck. That's one of the things I really
liked about concept maps in the old Concepts proposal, although I can
certainly see why the original proposal was dropped.
However, that's all beside the point, given the next paragraph:
> Two syntaxes? You may not have heard, but at Kona
> <https://isocpp.org/blog/2015/11/kona-standards-meeting-trip-report>,
> the committee agreed to toss the `x.f -> f(x)` transformation. So all
> that's left for unified function syntax is `f(x) -> x.f` where possible.
I had not heard that. Thanks for the link! That resolves my issues with
the proposal, and has the happy side effect of making the unified
function syntax be the syntax I prefer. :)
- Jim
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: ghanashyam.satpathy@gmail.com
Date: Wed, 3 Feb 2016 19:50:20 -0800 (PST)
Raw View
------=_Part_287_2077692602.1454557820557
Content-Type: multipart/alternative;
boundary="----=_Part_288_549623651.1454557820557"
------=_Part_288_549623651.1454557820557
Content-Type: text/plain; charset=UTF-8
Thanks for the link. Great to see the acceptance on transformation from
free function to member function.
unified function syntax is `f(x) -> x.f`
On Thursday, February 4, 2016 at 4:19:16 AM UTC+5:30, Nicol Bolas wrote:
>
> On Wednesday, February 3, 2016 at 3:01:55 PM UTC-5, Jim Porter wrote:
>>
>> On 2/3/2016 8:16 AM, Nicol Bolas wrote:
>> > Not to mention, since compilers will soon be getting the ability to
>> > syntactically make `f(x, y)` call `x.f(y)` when it is available
>> > <http://wg21.link/P0131>, beginners will be seeing a /lot more/
>> "global"
>> > functions than they ever have before. Also note that we won't be
>> getting
>> > the reverse: the ability to have compilers turn `x.f(y)` into `f(x,
>> y)`.
>>
>> I'm secretly hoping this won't be standardized, since I think the
>> benefits are extremely dubious. You get most of the stated benefits in
>> that paper by just saying, "(almost) everything should be a free
>> function."
>
>
> OK, let's pretend we live in a magical fantasy world where the word of
> Bjarne Stroustrup is instantly accepted as law among all C++ programmers.
> And therefore, when he arbitrary declares "Thou shalt not write a member
> function unless you have no other choice", that's what we all do. Sure,
> that's never going to happen, but again, we're pretending here.
>
> That will do squat for the literally *billions* of lines of already
> existing C++ code. So in order for this rule to give you "most of the
> stated benefits" of the proposal, you would also need to give Bjarne
> Stroustrup the ability to magically rewrite every line of C++ that already
> exists.
>
> Or we could do something that is actually *possible*.
>
> However, I'm not convinced that that alone outweighs the risks. My
>> biggest concern is that it results in two syntaxes that do *almost* the
>> exact same thing, except sometimes it's subtly different because the
>> rules for which function is chosen vary when there are both member and
>> non-member versions. It's effectively training people to treat the two
>> syntaxes as synonyms, but adding a special edge case to bite them later
>> on. Option 5 from N4474 (use overload resolution to get consistent
>> results) would eliminate this concern, of course.
>>
>
> Two syntaxes? You may not have heard, but at Kona
> <https://isocpp.org/blog/2015/11/kona-standards-meeting-trip-report>, the
> committee agreed to toss the `x.f -> f(x)` transformation. So all that's
> left for unified function syntax is `f(x) -> x.f` where possible.
>
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_288_549623651.1454557820557
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Thanks for the link. Great to see the acceptance on t=
ransformation from free function to member function.</div>unified function =
syntax is `f(x) -> x.f`=C2=A0<br><br>On Thursday, February 4, 2016 at 4:=
19:16 AM UTC+5:30, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left:=
1ex;"><div dir=3D"ltr">On Wednesday, February 3, 2016 at 3:01:55 PM UTC-5,=
Jim Porter wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margi=
n-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">On 2/3/2016 8:16 =
AM, Nicol Bolas wrote:
<br>> Not to mention, since compilers will soon be getting the ability t=
o
<br>> syntactically make `f(x, y)` call `x.f(y)` when it is available
<br>> <<a href=3D"http://wg21.link/P0131" rel=3D"nofollow" target=3D"=
_blank" onmousedown=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fwg21.link%2FP0131\46sa\75D\46sntz\0751\46usg\75AFQjCNGITxZUsDvHMOKR=
PYQAkkHUdivOEg';return true;" onclick=3D"this.href=3D'http://www.go=
ogle.com/url?q\75http%3A%2F%2Fwg21.link%2FP0131\46sa\75D\46sntz\0751\46usg\=
75AFQjCNGITxZUsDvHMOKRPYQAkkHUdivOEg';return true;">http://wg21.link/P0=
131</a>>, beginners will be seeing a /lot more/ "global"
<br>> functions than they ever have before. Also note that we won't =
be getting
<br>> the reverse: the ability to have compilers turn `x.f(y)` into `f(x=
, y)`.
<br>
<br>I'm secretly hoping this won't be standardized, since I think t=
he=20
<br>benefits are extremely dubious. You get most of the stated benefits in=
=20
<br>that paper by just saying, "(almost) everything should be a free=
=20
<br>function."</blockquote><div><br>OK, let's pretend we live in a=
magical fantasy world where the word of Bjarne Stroustrup is instantly acc=
epted as law among all C++ programmers. And therefore, when he arbitrary de=
clares "Thou shalt not write a member function unless you have no othe=
r choice", that's what we all do. Sure, that's never going to =
happen, but again, we're pretending here.<br><br>That will do squat for=
the literally <i>billions</i> of lines of already existing C++ code. So in=
order for this rule to give you "most of the stated benefits" of=
the proposal, you would also need to give Bjarne Stroustrup the ability to=
magically rewrite every line of C++ that already exists.<br><br>Or we coul=
d do something that is actually <i>possible</i>.<br><br></div><div></div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-=
left:1px #ccc solid;padding-left:1ex">However, I'm not convinced that t=
hat alone outweighs the risks. My=20
<br>biggest concern is that it results in two syntaxes that do *almost* the=
=20
<br>exact same thing, except sometimes it's subtly different because th=
e=20
<br>rules for which function is chosen vary when there are both member and=
=20
<br>non-member versions. It's effectively training people to treat the =
two=20
<br>syntaxes as synonyms, but adding a special edge case to bite them later=
=20
<br>on. Option 5 from N4474 (use overload resolution to get consistent=20
<br>results) would eliminate this concern, of course.<br></blockquote><div>=
<br>Two syntaxes? You may not have heard, but <a href=3D"https://isocpp.org=
/blog/2015/11/kona-standards-meeting-trip-report" target=3D"_blank" rel=3D"=
nofollow" onmousedown=3D"this.href=3D'https://www.google.com/url?q\75ht=
tps%3A%2F%2Fisocpp.org%2Fblog%2F2015%2F11%2Fkona-standards-meeting-trip-rep=
ort\46sa\75D\46sntz\0751\46usg\75AFQjCNEqYLuQO11BCv_AYTNRcsyrE0KXnQ';re=
turn true;" onclick=3D"this.href=3D'https://www.google.com/url?q\75http=
s%3A%2F%2Fisocpp.org%2Fblog%2F2015%2F11%2Fkona-standards-meeting-trip-repor=
t\46sa\75D\46sntz\0751\46usg\75AFQjCNEqYLuQO11BCv_AYTNRcsyrE0KXnQ';retu=
rn true;">at Kona</a>, the committee agreed to toss the `x.f -> f(x)` tr=
ansformation. So all that's left for unified function syntax is `f(x) -=
> x.f` where possible.</div></div></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
------=_Part_288_549623651.1454557820557--
------=_Part_287_2077692602.1454557820557--
.
Author: Robin Rowe <robinsrowe@gmail.com>
Date: Sun, 21 Feb 2016 17:27:20 -0800
Raw View
> a common template class having toString() would be nice to have for
> all numeric-> string conversion.
https://github.com/robinrowe/libunistd/blob/master/portable/CppTypes.h
Robin
On 2/1/2016 2:23 AM, ghanashyam.satpathy@gmail.com wrote:
> Yes I like this approach.Justifies to be more object oriented instead of
> using stol() version of conversion routine.
> So a common template class having toString() would be nice to have for
> all numeric-> string conversion.
>
> Thanks
>
> Ghanashyam
>
> On Monday, November 9, 2015 at 9:35:05 PM UTC+5:30, Robin Rowe wrote:
>
> I have an Int class that does this:
>
> #include "CppTypes.h"
> #include <string>
>
> int main()
> { int x=10;
> Int x2(x);
> std::string s=x2;// s=="10"
> Int x3("20");
> int x4=x3;// x4==20
> const char* s2=x3;// s2=="20", s2 valid as long as x3 exists
> Int x5("hello");// true==isnan(x5);
> int x6=x5;//x6==0
> return 0;
> }
>
> I have classes like this for all the built-in types. I prefer this
> approach over using string streams when going back-and-forth between
> built-in types and strings or char*.
>
> Is there something like this in the C++ standard? Would anyone else
> find
> this useful? Has this been discussed before?
>
> Thanks,
>
> Robin
--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/56CA63F8.80007%40gmail.com.
.