Topic: Small comment on p0027r0.pdf


Author: german.diago@hubblehome.com
Date: Fri, 2 Oct 2015 05:14:31 -0700 (PDT)
Raw View
------=_Part_811_736912240.1443788071509
Content-Type: multipart/alternative;
 boundary="----=_Part_812_1082849435.1443788071509"

------=_Part_812_1082849435.1443788071509
Content-Type: text/plain; charset=UTF-8

Hello,

I wonder if it would be better to use the new, better way:

typedef int sometype;
using sometype = int;

So, for consistency, I would propose to introduce the new style way of
syntax:

newtype sometype = int;

instead of

newtype int sometype;


Eliminating all the obscure typedef syntax with arrays and function
pointers also.



--

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

<div dir=3D"ltr">Hello,<div><br></div><div>I wonder if it would be better t=
o use the new, better way:</div><div><br></div><div>typedef int sometype;</=
div><div>using sometype =3D int;</div><div><br></div><div>So, for consisten=
cy, I would propose to introduce the new style way of syntax:</div><div><br=
></div><div>newtype sometype =3D int;</div><div><br></div><div>instead of</=
div><div><br></div><div>newtype int sometype;</div><div><br></div><div><br>=
</div><div>Eliminating all the obscure typedef syntax with arrays and funct=
ion pointers also.</div><div><br></div><div><br></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_812_1082849435.1443788071509--
------=_Part_811_736912240.1443788071509--

.


Author: Sam Kellett <samkellett@gmail.com>
Date: Fri, 2 Oct 2015 13:37:13 +0100
Raw View
--001a11c3b22e51a97705211e6c7a
Content-Type: text/plain; charset=UTF-8

On 2 October 2015 at 13:14, <german.diago@hubblehome.com> wrote:

> Hello,
>
> I wonder if it would be better to use the new, better way:
>
> typedef int sometype;
> using sometype = int;
>
> So, for consistency, I would propose to introduce the new style way of
> syntax:
>
> newtype sometype = int;
>
> instead of
>
> newtype int sometype;
>
>
> Eliminating all the obscure typedef syntax with arrays and function
> pointers also.
>
>
+1 i like this.

something else i'd add is to prefix it with a 'using' so as to avoid
breaking existing code (and it put it in the std namespace).

so it would look something like:

using std::newtype sometype = int;

therefore any codebases with an object already called newtype wouldn't
break when this was added.

--

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

--001a11c3b22e51a97705211e6c7a
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 2=
 October 2015 at 13:14,  <span dir=3D"ltr">&lt;<a href=3D"mailto:german.dia=
go@hubblehome.com" target=3D"_blank">german.diago@hubblehome.com</a>&gt;</s=
pan> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex=
;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hello,<div><=
br></div><div>I wonder if it would be better to use the new, better way:</d=
iv><div><br></div><div>typedef int sometype;</div><div>using sometype =3D i=
nt;</div><div><br></div><div>So, for consistency, I would propose to introd=
uce the new style way of syntax:</div><div><br></div><div>newtype sometype =
=3D int;</div><div><br></div><div>instead of</div><div><br></div><div>newty=
pe int sometype;</div><div><br></div><div><br></div><div>Eliminating all th=
e obscure typedef syntax with arrays and function pointers also.</div><span=
 class=3D"HOEnZb"></span><br></div></blockquote><div><br></div><div>+1 i li=
ke this.<br><br></div><div>something else i&#39;d add is to prefix it with =
a &#39;using&#39; so as to avoid breaking existing code (and it put it in t=
he std namespace).<br><br></div><div>so it would look something like:<br><b=
r></div><div>using std::newtype sometype =3D int; <br><br></div><div>theref=
ore any codebases with an object already called newtype wouldn&#39;t break =
when this was added.<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 />

--001a11c3b22e51a97705211e6c7a--

.


Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 02 Oct 2015 10:45:10 -0400
Raw View
On 2015-10-02 08:37, Sam Kellett wrote:
> something else i'd add is to prefix it with a 'using' so as to avoid
> breaking existing code (and it put it in the std namespace).
>
> so it would look something like:
>
> using std::newtype sometype = int;

+1 to not adding new (unscoped) keywords. I wonder, however, if an
alternative that looks more like existing type definition forms wouldn't
be better:

  std::newtype identifier : int;
  using identifier = std::newtype<int>;
  typename identifier : int;

I'm somewhat partial to the last form, as it is consistent with 'enum',
'class', etc. also creating a new and distinct type "based on" another type.

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Sam Kellett <samkellett@gmail.com>
Date: Fri, 2 Oct 2015 15:59:55 +0100
Raw View
--001a114128acacce760521206a54
Content-Type: text/plain; charset=UTF-8

On 2 October 2015 at 15:45, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:

> On 2015-10-02 08:37, Sam Kellett wrote:
> > something else i'd add is to prefix it with a 'using' so as to avoid
> > breaking existing code (and it put it in the std namespace).
> >
> > so it would look something like:
> >
> > using std::newtype sometype = int;
>
> +1 to not adding new (unscoped) keywords. I wonder, however, if an
> alternative that looks more like existing type definition forms wouldn't
> be better:
>
>   std::newtype identifier : int;
>   using identifier = std::newtype<int>;
>   typename identifier : int;
>
> I'm somewhat partial to the last form, as it is consistent with 'enum',
> 'class', etc. also creating a new and distinct type "based on" another type


i think the second one, while it looks very c++-y (and that's a good
thing), may be misleading...

seeing as 'using' is used for weak typedefs, the follow holds:

using a = int;
using b = int;
static_assert(std::is_same<a, b>(), "");

this would be true for any type except 'std::newtype' (which of course
wouldn't be a type, but here it looks like one).

using a = std::newtype<int>;
using b = std::newtype<int>;
static_assert(std::is_same<a, b>(), ""); // fails

i think this would be very surprising to anybody who encounters this code
before they understand what std::newtype is.

----

on the third, i like it and i like the comparison to enum classes. how
about making the connection even more explicit:

enum typename identifier : int;

--

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

--001a114128acacce760521206a54
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 2=
 October 2015 at 15:45, Matthew Woehlke <span dir=3D"ltr">&lt;<a href=3D"ma=
ilto:mwoehlke.floss@gmail.com" target=3D"_blank">mwoehlke.floss@gmail.com</=
a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><=
span class=3D"">On 2015-10-02 08:37, Sam Kellett wrote:<br>
&gt; something else i&#39;d add is to prefix it with a &#39;using&#39; so a=
s to avoid<br>
&gt; breaking existing code (and it put it in the std namespace).<br>
&gt;<br>
&gt; so it would look something like:<br>
&gt;<br>
&gt; using std::newtype sometype =3D int;<br>
<br>
</span>+1 to not adding new (unscoped) keywords. I wonder, however, if an<b=
r>
alternative that looks more like existing type definition forms wouldn&#39;=
t<br>
be better:<br>
<br>
=C2=A0 std::newtype identifier : int;<br>
=C2=A0 using identifier =3D std::newtype&lt;int&gt;;<br>
=C2=A0 typename identifier : int;<br>
<br>
I&#39;m somewhat partial to the last form, as it is consistent with &#39;en=
um&#39;,<br>
&#39;class&#39;, etc. also creating a new and distinct type &quot;based on&=
quot; another type</blockquote><div><br></div><div>i think the second one, =
while it looks very c++-y (and that&#39;s a good thing), may be misleading.=
...<br><br></div><div>seeing as &#39;using&#39; is used for weak typedefs, t=
he follow holds:<br><br></div><div>using a =3D int;<br></div><div>using b =
=3D int;<br></div><div>static_assert(std::is_same&lt;a, b&gt;(), &quot;&quo=
t;);<br><br></div><div>this would be true for any type except &#39;std::new=
type&#39; (which of course wouldn&#39;t be a type, but here it looks like o=
ne).<br><br>using a =3D std::newtype&lt;int&gt;;<br>using b =3D std::newtyp=
e&lt;int&gt;;<br></div><div>static_assert(std::is_same&lt;a, b&gt;(), &quot=
;&quot;); // fails<br><br></div><div>i think this would be very surprising =
to anybody who encounters this code before they understand what std::newtyp=
e is.<br><br></div><div>----<br><br></div><div>on the third, i like it and =
i like the comparison to enum classes. how about making the connection even=
 more explicit:<br><br></div><div>enum typename identifier : int;<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 />

--001a114128acacce760521206a54--

.


Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 02 Oct 2015 11:14:16 -0400
Raw View
On 2015-10-02 10:59, Sam Kellett wrote:
> On 2 October 2015 at 15:45, Matthew Woehlke wrote:
>> +1 to not adding new (unscoped) keywords. I wonder, however, if an
>> alternative that looks more like existing type definition forms wouldn't
>> be better:
>>
>>   std::newtype identifier : int;
>>   using identifier = std::newtype<int>;
>>   typename identifier : int;
>>
>> I'm somewhat partial to the last form, as it is consistent with 'enum',
>> 'class', etc. also creating a new and distinct type "based on" another type
>
> on the third, i like it and i like the comparison to enum classes. how
> about making the connection even more explicit:
>
> enum typename identifier : int;

That actually breaks the analogy :-).

  enum FooEnum : short // an enumeration type "based on" short
  class FooClass : Bar // a class type "based on" Bar
  typename FooType : int // a value type "based on" int

....and besides, a strong typedef (or whatever we're calling it) *isn't*
an enumeration. At least not necessarily. (Presumably, a strong typedef
doesn't have to be of a POD type, but could be of an enumeration or
class type also.)

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Sam Kellett <samkellett@gmail.com>
Date: Fri, 2 Oct 2015 16:29:17 +0100
Raw View
--001a113fa1ceaf349e052120d340
Content-Type: text/plain; charset=UTF-8

On 2 October 2015 at 16:14, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:

> On 2015-10-02 10:59, Sam Kellett wrote:
> > On 2 October 2015 at 15:45, Matthew Woehlke wrote:
> >> +1 to not adding new (unscoped) keywords. I wonder, however, if an
> >> alternative that looks more like existing type definition forms wouldn't
> >> be better:
> >>
> >>   std::newtype identifier : int;
> >>   using identifier = std::newtype<int>;
> >>   typename identifier : int;
> >>
> >> I'm somewhat partial to the last form, as it is consistent with 'enum',
> >> 'class', etc. also creating a new and distinct type "based on" another
> type
> >
> > on the third, i like it and i like the comparison to enum classes. how
> > about making the connection even more explicit:
> >
> > enum typename identifier : int;
>
> That actually breaks the analogy :-).
>
>   enum FooEnum : short // an enumeration type "based on" short
>   class FooClass : Bar // a class type "based on" Bar
>   typename FooType : int // a value type "based on" int
>
> ...and besides, a strong typedef (or whatever we're calling it) *isn't*
> an enumeration. At least not necessarily. (Presumably, a strong typedef
> doesn't have to be of a POD type, but could be of an enumeration or
> class type also.)
>

where does enum class fall into that analogy?

i get that a newtype is not strictly an enumeration (but if you look at how
rust are using the word enum...), but it seems to fit in my mind with the
new idea of strong type checking.

enum class provides strong type checking for more than one value (ie a
class, perhaps enum struct or enum union would have been a better fit in
this regard).
enum typename provides strong type checking for a single type.

also the form 'typename identifier : type' doesn't have any precdence in
c++, i think adding an 'enum' prefix provides familiarity to the construct.

--

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

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 2 October 2015 at 16:14, Matthew Woehlke <span dir=3D"ltr">&lt;<a hr=
ef=3D"mailto:mwoehlke.floss@gmail.com" target=3D"_blank">mwoehlke.floss@gma=
il.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"=
margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2015-10-0=
2 10:59, Sam Kellett wrote:<br>
<span class=3D"">&gt; On 2 October 2015 at 15:45, Matthew Woehlke wrote:<br=
>
&gt;&gt; +1 to not adding new (unscoped) keywords. I wonder, however, if an=
<br>
&gt;&gt; alternative that looks more like existing type definition forms wo=
uldn&#39;t<br>
&gt;&gt; be better:<br>
&gt;&gt;<br>
&gt;&gt;=C2=A0 =C2=A0std::newtype identifier : int;<br>
&gt;&gt;=C2=A0 =C2=A0using identifier =3D std::newtype&lt;int&gt;;<br>
&gt;&gt;=C2=A0 =C2=A0typename identifier : int;<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m somewhat partial to the last form, as it is consistent wit=
h &#39;enum&#39;,<br>
&gt;&gt; &#39;class&#39;, etc. also creating a new and distinct type &quot;=
based on&quot; another type<br>
&gt;<br>
</span><span class=3D"">&gt; on the third, i like it and i like the compari=
son to enum classes. how<br>
&gt; about making the connection even more explicit:<br>
&gt;<br>
&gt; enum typename identifier : int;<br>
<br>
</span>That actually breaks the analogy :-).<br>
<br>
=C2=A0 enum FooEnum : short // an enumeration type &quot;based on&quot; sho=
rt<br>
=C2=A0 class FooClass : Bar // a class type &quot;based on&quot; Bar<br>
=C2=A0 typename FooType : int // a value type &quot;based on&quot; int<br>
<br>
....and besides, a strong typedef (or whatever we&#39;re calling it) *isn&#3=
9;t*<br>
an enumeration. At least not necessarily. (Presumably, a strong typedef<br>
doesn&#39;t have to be of a POD type, but could be of an enumeration or<br>
class type also.)<div></div></blockquote><div><br></div><div>where does enu=
m class fall into that analogy?<br><br></div><div>i get that a newtype is n=
ot strictly an enumeration (but if you look at how rust are using the word =
enum...), but it seems to fit in my mind with the new idea of strong type c=
hecking.<br><br></div><div>enum class provides strong type checking for mor=
e than one value (ie a class, perhaps enum struct or enum union would have =
been a better fit in this regard).<br></div><div>enum typename provides str=
ong type checking for a single type. <br></div></div><br></div><div class=
=3D"gmail_extra">also the form &#39;typename identifier : type&#39; doesn&#=
39;t have any precdence in c++, i think adding an &#39;enum&#39; prefix pro=
vides familiarity to the construct.<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 />

--001a113fa1ceaf349e052120d340--

.


Author: John Yates <john@yates-sheets.org>
Date: Fri, 2 Oct 2015 11:35:01 -0400
Raw View
--001a11343ec02eab59052120e891
Content-Type: text/plain; charset=UTF-8

On Fri, Oct 2, 2015 at 11:14 AM, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:

> That actually breaks the analogy :-).
>
>   enum FooEnum : short // an enumeration type "based on" short
>   class FooClass : Bar // a class type "based on" Bar
>   typename FooType : int // a value type "based on" int
>
> ...and besides, a strong typedef (or whatever we're calling it) *isn't*
> an enumeration. At least not necessarily. (Presumably, a strong typedef
> doesn't have to be of a POD type, but could be of an enumeration or
> class type also.)
>

Maybe take a cue from Ada? :-)

typename FooType : new int;

If FooType is essentially equivalent to the RHS type then I think '=' is
more intuitive:

typename <identifier> = new <type-name>;
typedef  <identifier> = new <type-name>;

/john

--

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

--001a11343ec02eab59052120e891
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 F=
ri, Oct 2, 2015 at 11:14 AM, Matthew Woehlke <span dir=3D"ltr">&lt;<a href=
=3D"mailto:mwoehlke.floss@gmail.com" target=3D"_blank">mwoehlke.floss@gmail=
..com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,=
204);border-left-style:solid;padding-left:1ex">That actually breaks the ana=
logy :-).<br>
<br>
=C2=A0 enum FooEnum : short // an enumeration type &quot;based on&quot; sho=
rt<br>
=C2=A0 class FooClass : Bar // a class type &quot;based on&quot; Bar<br>
=C2=A0 typename FooType : int // a value type &quot;based on&quot; int<br>
<br>
....and besides, a strong typedef (or whatever we&#39;re calling it) *isn&#3=
9;t*<br>
an enumeration. At least not necessarily. (Presumably, a strong typedef<br>
doesn&#39;t have to be of a POD type, but could be of an enumeration or<br>
class type also.)<br></blockquote><div><br></div><div>Maybe take a cue from=
 Ada? :-)</div><div><div><br></div><div><font face=3D"monospace, monospace"=
>typename FooType : new int;</font></div></div><div><br></div><div>If FooTy=
pe is essentially equivalent to the RHS type then I think &#39;=3D&#39; is =
more intuitive:</div><div><br></div><div><font face=3D"monospace, monospace=
">typename &lt;identifier&gt; =3D new &lt;type-name&gt;;</font></div><div><=
div><font face=3D"monospace, monospace">typedef =C2=A0&lt;identifier&gt; =
=3D new &lt;type-name&gt;;</font></div><div></div><div><br></div></div><div=
>/john</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 />

--001a11343ec02eab59052120e891--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 2 Oct 2015 08:44:14 -0700 (PDT)
Raw View
------=_Part_353_1947385678.1443800654942
Content-Type: multipart/alternative;
 boundary="----=_Part_354_1031714137.1443800654942"

------=_Part_354_1031714137.1443800654942
Content-Type: text/plain; charset=UTF-8

On Friday, October 2, 2015 at 11:35:03 AM UTC-4, John Yates wrote:
>
> On Fri, Oct 2, 2015 at 11:14 AM, Matthew Woehlke <mwoehlk...@gmail.com
> <javascript:>> wrote:
>
>> That actually breaks the analogy :-).
>>
>>   enum FooEnum : short // an enumeration type "based on" short
>>   class FooClass : Bar // a class type "based on" Bar
>>   typename FooType : int // a value type "based on" int
>>
>> ...and besides, a strong typedef (or whatever we're calling it) *isn't*
>> an enumeration. At least not necessarily. (Presumably, a strong typedef
>> doesn't have to be of a POD type, but could be of an enumeration or
>> class type also.)
>>
>
> Maybe take a cue from Ada? :-)
>
> typename FooType : new int;
>
> If FooType is essentially equivalent to the RHS type then I think '=' is
> more intuitive:
>
> typename <identifier> = new <type-name>;
> typedef  <identifier> = new <type-name>;
>

The use of `typename` is OK, but the use of `new` is highly confusing.

Really, what's wrong with scoped keywords? That's like the best idea I've
seen for C++ in a long while. It solves so many problems.

std::newtype <identifier> = <typename>;

That's really all we need. It would *also* allow us to solve a number of
strong type alias problems, such as deciding whether conversion is allowed
or forbidden:

std::newtype NoImplicitConversion = <typename>;
std::typealias ImplicitConversion = <typename>;

Being able to create keywords arbitrarily is exceedingly powerful. Let's
use it.

--

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

On Friday, October 2, 2015 at 11:35:03 AM UTC-4, John Yates wrote:<blockquo=
te 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><div class=3D"gma=
il_quote">On Fri, Oct 2, 2015 at 11:14 AM, Matthew Woehlke <span dir=3D"ltr=
">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"5z=
iLcWDtCgAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&#3=
9;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true;"=
>mwoehlk...@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_q=
uote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-c=
olor:rgb(204,204,204);border-left-style:solid;padding-left:1ex">That actual=
ly breaks the analogy :-).<br>
<br>
=C2=A0 enum FooEnum : short // an enumeration type &quot;based on&quot; sho=
rt<br>
=C2=A0 class FooClass : Bar // a class type &quot;based on&quot; Bar<br>
=C2=A0 typename FooType : int // a value type &quot;based on&quot; int<br>
<br>
....and besides, a strong typedef (or whatever we&#39;re calling it) *isn&#3=
9;t*<br>
an enumeration. At least not necessarily. (Presumably, a strong typedef<br>
doesn&#39;t have to be of a POD type, but could be of an enumeration or<br>
class type also.)<br></blockquote><div><br></div><div>Maybe take a cue from=
 Ada? :-)</div><div><div><br></div><div><font face=3D"monospace, monospace"=
>typename FooType : new int;</font></div></div><div><br></div><div>If FooTy=
pe is essentially equivalent to the RHS type then I think &#39;=3D&#39; is =
more intuitive:</div><div><br></div><div><font face=3D"monospace, monospace=
">typename &lt;identifier&gt; =3D new &lt;type-name&gt;;</font></div><div><=
div><font face=3D"monospace, monospace">typedef =C2=A0&lt;identifier&gt; =
=3D new &lt;type-name&gt;;</font></div></div></div></div></div></blockquote=
><div><br>The use of `typename` is OK, but the use of `new` is highly confu=
sing.<br><br>Really, what&#39;s wrong with scoped keywords? That&#39;s like=
 the best idea I&#39;ve seen for C++ in a long while. It solves so many pro=
blems.<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250=
, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-=
width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">newtype </sp=
an><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;identifier=
&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #080;" class=3D"styled-by-prettify">&lt;typename&gt;</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span></div></code></di=
v><br>That&#39;s really all we need. It would <i>also</i> allow us to solve=
 a number of strong type alias problems, such as deciding whether conversio=
n is allowed or forbidden:<br><br><div class=3D"prettyprint" style=3D"backg=
round-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-s=
tyle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pret=
typrint"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">newtype </span><span style=3D"color: #606;" class=3D"styled-by-pre=
ttify">NoImplicitConversion</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">&lt;type=
name&gt;</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>std</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify">typealias </span><span=
 style=3D"color: #606;" class=3D"styled-by-prettify">ImplicitConversion</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">&lt;typename&gt;</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span></div></code></div><br>Being =
able to create keywords arbitrarily is exceedingly powerful. Let&#39;s use =
it.<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_354_1031714137.1443800654942--
------=_Part_353_1947385678.1443800654942--

.


Author: Bo Persson <bop@gmb.dk>
Date: Fri, 2 Oct 2015 17:53:06 +0200
Raw View
On 2015-10-02 14:14, german.diago@hubblehome.com wrote:
> Hello,
>
> I wonder if it would be better to use the new, better way:
>
> typedef int sometype;
> using sometype = int;
>
> So, for consistency, I would propose to introduce the new style way of
> syntax:
>
> newtype sometype = int;
>
> instead of
>
> newtype int sometype;
>
>
> Eliminating all the obscure typedef syntax with arrays and function
> pointers also.
>
>

If we want to go the Ada way, we could do

using sometype = new int;

without any additional keywords.



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 http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 02 Oct 2015 12:20:21 -0400
Raw View
On 2015-10-02 11:29, Sam Kellett wrote:
> On 2 October 2015 at 16:14, Matthew Woehlke wrote:
>>   enum FooEnum : short // an enumeration type "based on" short
>>   class FooClass : Bar // a class type "based on" Bar
>>   typename FooType : int // a value type "based on" int
>
> where does enum class fall into that analogy?

It's weird? ;-)

It's still an enumeration (first keyword). In that sense, maybe
'typename class <name> : <base>;' would make sense. Or 'using typename
<name> = <base>;'.

> enum class provides strong type checking for more than one value (ie a
> class, perhaps enum struct or enum union would have been a better fit in
> this regard).

That analogy still doesn't work; it's *'class'* that made an *'enum'* a
"strong type", not the other way around.

> also the form 'typename identifier : type' doesn't have any precdence in
> c++, i think adding an 'enum' prefix provides familiarity to the construct.

Yes, but it's consistent with '<typeclass> <name> : <base>', where
typeclass is one of 'enum', 'enum class', 'struct', or 'class'. In
general, I'd lean towards that idiom, adding something sensible to the
list of what <typeclass> can be.

On 2015-10-02 11:35, John Yates wrote:
> Maybe take a cue from Ada?
>
> typename FooType : new int;
>
> If FooType is essentially equivalent to the RHS type then I think '=' is
> more intuitive:
>
> typename <identifier> = new <type-name>;
> typedef  <identifier> = new <type-name>;

Ugh. 'using <name> = new <base>;', please :-).

....That form's not bad, though. I'd prefer it to any of the original
proposals. I think the use of 'new' makes it sufficiently clear that the
result is unique, as would be the case if you were allocating memory.
IOW, this:

  using a = new int;
  using b = new int;
  // a != b

....should be no more surprising than this:

  auto a = new int;
  auto b = new int;
  // a != b

--
Matthew

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Ross Smith <ross.smith@otoy.com>
Date: Mon, 5 Oct 2015 09:44:23 +1300
Raw View
On 2015-10-03 04:14, Matthew Woehlke wrote:
>
>    enum FooEnum : short // an enumeration type "based on" short
>    class FooClass : Bar // a class type "based on" Bar
>    typename FooType : int // a value type "based on" int
>
> ...and besides, a strong typedef (or whatever we're calling it) *isn't*
> an enumeration. At least not necessarily. (Presumably, a strong typedef
> doesn't have to be of a POD type, but could be of an enumeration or
> class type also.)

I'd like to suggest

     using class NewName = ExistingType;

by analogy with enum class. (With the obvious generic extension for
template-using.) It's not a perfect analogy but I hope you see my point
- adding the class keyword creates a "harder" type. I know some people
dislike the enum class syntax, but that ship has sailed now, and we
might as well continue to follow that precedent rather than create yet
another special syntax.

Ross Smith


--

---
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: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Mon, 5 Oct 2015 00:04:45 +0200
Raw View
This is a multi-part message in MIME format.
--------------060606000109010008060305
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 02/10/15 14:14, german.diago@hubblehome.com a =C3=A9crit :
> Hello,
>
> I wonder if it would be better to use the new, better way:
>
> typedef int sometype;
> using sometype =3D int;
>
> So, for consistency, I would propose to introduce the new style way of
> syntax:
>
> newtype sometype =3D int;
>
> instead of
>
> newtype int sometype;
>
>
> Eliminating all the obscure typedef syntax with arrays and function
> pointers also.
>
>
>
Hi,

I suggest to take a look also at

P0109R0     Function Aliases + Extended Inheritance =3D Opaque Typedefs
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0109r0.pdf

using energy =3D protected double {
     energy operator+ (energy , energy) =3D default;
     energy& operator*=3D(energy&, double) =3D default;
     energy operator* (energy , energy) =3D delete;
     energy operator* (energy , double) =3D default;
     energy operator* (double , energy) =3D default;
};

Vicente

--=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 http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 02/10/15 14:14,
      <a class=3D"moz-txt-link-abbreviated" href=3D"mailto:german.diago@hub=
blehome.com">german.diago@hubblehome.com</a> a =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:97c3c232-f6cd-4296-b28f-c8e4b4f56cd9@isocpp.org"
      type=3D"cite">
      <pre wrap=3D"">Hello,

I wonder if it would be better to use the new, better way:

typedef int sometype;
using sometype =3D int;

So, for consistency, I would propose to introduce the new style way of=20
syntax:

newtype sometype =3D int;

instead of

newtype int sometype;


Eliminating all the obscure typedef syntax with arrays and function=20
pointers also.



</pre>
    </blockquote>
    <font size=3D"+1">Hi,<br>
      <br>
      I suggest to take a look also at<br>
      <br>
      P0109R0 =C2=A0=C2=A0=C2=A0 Function Aliases + Extended Inheritance =
=3D Opaque
      Typedefs <br>
    </font><font size=3D"+1">
      <meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf=
-8">
<a class=3D"moz-txt-link-freetext" href=3D"http://www.open-std.org/jtc1/sc2=
2/wg21/docs/papers/2015/p0109r0.pdf">http://www.open-std.org/jtc1/sc22/wg21=
/docs/papers/2015/p0109r0.pdf</a><br>
      <br>
    </font>using energy =3D protected double {<br>
    =C2=A0=C2=A0=C2=A0 energy operator+ (energy , energy) =3D default;<br>
    =C2=A0=C2=A0=C2=A0 energy&amp; operator*=3D(energy&amp;, double) =3D de=
fault;<br>
    =C2=A0=C2=A0=C2=A0 energy operator* (energy , energy) =3D delete;<br>
    =C2=A0=C2=A0=C2=A0 energy operator* (energy , double) =3D default;<br>
    =C2=A0=C2=A0=C2=A0 energy operator* (double , energy) =3D default;<br>
    };<br>
    <br>
    Vicente<br>
    <meta charset=3D"utf-8">
  </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&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 />

--------------060606000109010008060305--

.


Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Mon, 5 Oct 2015 07:10:46 -0700 (PDT)
Raw View
------=_Part_3479_1153791910.1444054246590
Content-Type: multipart/alternative;
 boundary="----=_Part_3480_1840247148.1444054246590"

------=_Part_3480_1840247148.1444054246590
Content-Type: text/plain; charset=UTF-8

Another option could be the explicit keyword.

explicit using MyVec = vector<int>;

It kind of meshes with the current meaning of explicit. The class keyword
as mentioned earlier might be better though, since "class" means defining a
new type whereas "using" is an alias.


--

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

<div dir=3D"ltr"><div>Another option could be the explicit keyword.</div><d=
iv>=C2=A0</div><div>explicit using MyVec =3D vector&lt;int&gt;;</div><div>=
=C2=A0</div><div>It kind of meshes with the current meaning of explicit. Th=
e class keyword as mentioned earlier might be better though, since &quot;cl=
ass&quot; means defining a new type whereas &quot;using&quot; is an alias.<=
/div><div>=C2=A0</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_3480_1840247148.1444054246590--
------=_Part_3479_1153791910.1444054246590--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 5 Oct 2015 07:40:09 -0700 (PDT)
Raw View
------=_Part_219_1163676423.1444056009590
Content-Type: multipart/alternative;
 boundary="----=_Part_220_764812211.1444056009590"

------=_Part_220_764812211.1444056009590
Content-Type: text/plain; charset=UTF-8

I don't like P0027, because it seems very much like the author spent
basically no time researching all of the strong typedef proposals that came
before it. Which is odd, because the paper cites other opaque typedef
proposals, but then claims that they're not doing the same thing.

Even though they *clearly are*.

P0109, by contracts, is a *much better* example of a strong typedef
proposal. It's based on prior proposals. It shows a clear understanding of
what those problems are. And it offers actual solutions for them.

P0027 reads like a version 1 of a concept that is currently in version 20.
It's naive in its simplicity.

--

---
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_220_764812211.1444056009590
Content-Type: text/html; charset=UTF-8

<div dir="ltr">I don&#39;t like P0027, because it seems very much like the author spent basically no
time researching all of the strong typedef proposals that came before
it. Which is odd, because the paper cites other opaque typedef
proposals, but then claims that they&#39;re not doing the same thing.<br><br>Even though they <i>clearly are</i>.<br><br>P0109, by contracts, is a <i>much better</i>
 example of a strong typedef proposal. It&#39;s based on prior proposals. It
 shows a clear understanding of what those problems are. And it offers actual solutions for them.<br><br>P0027 reads like a version 1 of a concept that is currently in version 20. It&#39;s naive in its simplicity.<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 email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

------=_Part_220_764812211.1444056009590--
------=_Part_219_1163676423.1444056009590--

.