Topic: Aliases for any names (variables, functions etc.)
Author: Yuriy Smirnov <neoprogramming@gmail.com>
Date: Mon, 18 May 2015 09:54:58 -0700 (PDT)
Raw View
------=_Part_718_815520009.1431968098368
Content-Type: multipart/alternative;
boundary="----=_Part_719_1204156109.1431968098368"
------=_Part_719_1204156109.1431968098368
Content-Type: text/plain; charset=UTF-8
Hello! I want to create aliases for any names in program (not only types
and templates). I propose to use "using" keyword for this. For example:
struct Base
{
int x;
int arr[2];
void foo(int,char){}
};
struct Derived : Base
{
void foo(float){}
std::pair<char,char> p;
using y = x; // add alias for 'x' member
using a1 = a[1];
using f1 = foo(int,char);
using g2 = foo(float);
using p2 = p.second;
};
Base b;
Derived d;
d.x = 10; // ok
d.y = 20; // ok, the same as 'd.x =20'
b.y = 30; // error, 'y' defined only for 'Derived'
d.f1(100,'a'); // call foo(int,char)
d.f2(3.14);// call foo(float)
d.p2 ='q'; // d.p.second ='q'
In large programs with hundreds and thousands of classes in inheritance
hierarchy, it is maybe useful for clarification of semantic of some
variables and methods. Using of alias names will narrow the search to those
names for the project. For example, field 'name' in root class could be
aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_719_1204156109.1431968098368
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello! I want to create aliases for any names in program (=
not only types and templates). I propose to use "using" keyword for this. F=
or example:<div><br><div><div class=3D"prettyprint" style=3D"border: 1px so=
lid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled=
-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Base</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> arr</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">[</span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">2</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">];</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">void<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">char</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">){}</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #606;" class=3D"styled-by-prettify">Derived</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">Base</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> foo</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">float</sp=
an><font color=3D"#666600"><span style=3D"color: #660;" class=3D"styled-by-=
prettify">){}</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br> std</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p=
air</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">char</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">char</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> p</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span></font><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><font style=3D"background-color: rgb(250, 250=
, 250);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> y </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> x</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">// add alias for 'x' member</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> a1 </span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">[</span><span style=3D"color: #066;" class=3D"styled-by-pretti=
fy">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">];</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> </=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> f1 </span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">char</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">using</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> g=
2 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">float</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br> </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">using</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> p2 </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> p</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
second</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">};</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #606;" class=3D"styled-by-prettify">Base</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: #606;" class=3D"styled-=
by-prettify">Derived</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> d</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br=
>d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">x </span><span st=
yle=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: #0=
66;" class=3D"styled-by-prettify">10</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">// ok</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br>d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.<=
/span><font color=3D"#000000"><span style=3D"color: #000;" class=3D"styled-=
by-prettify">y </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #066;" class=3D"styled-by-prettify">20</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// ok, the same as 'd.x =3D20'</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br>b</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">y </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: #066;" class=3D"=
styled-by-prettify">30</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify">// err=
or, 'y' defined only for 'Derived' </span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>d</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">f1</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #066;" class=3D"styled-by-prettify">100</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #080;" class=3D"styled-by-prettify">'a'</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;"=
class=3D"styled-by-prettify">// call foo(int,char)</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br>d</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">f2</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-=
prettify">3.14</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">);</span><span style=3D"color: #800;" class=3D"styled-by-prettify">// c=
all foo(float)</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">p2 </span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span s=
tyle=3D"color: #080;" class=3D"styled-by-prettify">'q'</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #800;" cla=
ss=3D"styled-by-prettify">// d.p.second =3D'q'</span></font></font></div></=
code></div><div><br></div>In large programs with hundreds and thousands of =
classes in inheritance hierarchy, it is maybe useful for clarification=
of semantic of some variables and methods. Using of alias names will =
narrow the search to those names for the project. For example, field 'name'=
in root class could be aliased as 'name_car', 'name_aircraft', 'name_ship'=
etc.<br><br><div><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" 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_719_1204156109.1431968098368--
------=_Part_718_815520009.1431968098368--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Mon, 18 May 2015 12:27:03 -0500
Raw View
--089e01419ad2003a8d05165e831a
Content-Type: text/plain; charset=UTF-8
On 18 May 2015 at 11:54, Yuriy Smirnov <neoprogramming@gmail.com> wrote:
> In large programs with hundreds and thousands of classes in inheritance
> hierarchy, it is maybe useful for clarification of semantic of some
> variables and methods. Using of alias names will narrow the search to those
> names for the project. For example, field 'name' in root class could be
> aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
>
Surely that would exasperate the problem, as now you have to search for two
names instead of just one.
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--089e01419ad2003a8d05165e831a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 18 May 2015 at 11:54, Yuriy Smirnov <span dir=3D"ltr">&=
lt;<a href=3D"mailto:neoprogramming@gmail.com" target=3D"_blank">neoprogram=
ming@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div cla=
ss=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><di=
v>In large programs with hundreds and thousands of classes in inheritance h=
ierarchy, it is maybe useful for=C2=A0clarification=C2=A0of semantic of som=
e variables and methods. Using of alias names will narrow the search to tho=
se names for the project. For example, field 'name' in root class c=
ould be aliased as 'name_car', 'name_aircraft', 'name_s=
hip' etc.</div></div></div></blockquote><div><br></div><div>Surely that=
would exasperate the problem, as now you have to search for two names inst=
ead of just one.</div></div>-- <br><div class=3D"gmail_signature">=C2=A0Nev=
in ":-)" Liber=C2=A0 <mailto:<a href=3D"mailto:nevin@eviloverl=
ord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=C2=A0 (847) 691-1=
404</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"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--089e01419ad2003a8d05165e831a--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Mon, 18 May 2015 10:44:42 -0700 (PDT)
Raw View
------=_Part_6_1303534765.1431971082341
Content-Type: multipart/alternative;
boundary="----=_Part_7_2028112308.1431971082341"
------=_Part_7_2028112308.1431971082341
Content-Type: text/plain; charset=UTF-8
On Monday, May 18, 2015 at 12:54:58 PM UTC-4, Yuriy Smirnov wrote:
>
> In large programs with hundreds and thousands of classes in inheritance
> hierarchy, it is maybe useful for clarification of semantic of some
> variables and methods. Using of alias names will narrow the search to those
> names for the project. For example, field 'name' in root class could be
> aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
>
I agree with Nevin on this; I can't see how that would in any way help.
Indeed, your example suggests a very odd way of thinking about these sorts
of things.
If a base class has a field simply called `name`, then presumably that
refers name refers to the object itself. If I have a class derived from
whatever type this is, and I call that class "Car", then `name` would refer
to the name of the "Car". So there's no confusion over what the name refers
to; renaming it to `name_car` adds only needless verbosity.
It also adds confusion, since now it's much harder to track down what
actual variable is being used. You can't just search for a particular word;
now you have to search for multiple words.
Furthermore, derived classes shouldn't be renaming things from base
classes. The name of a variable provides its meaning; to change the name is
to change its meaning. `name` is a "name" because that's what the word
means. Derived classes should change the *contents* of such variables, not
their meaning. `name` should always be the object's name, regardless of how
derived it is. Otherwise, you're just creating lots of confusion.
We allow type and template aliases because of *verbosity*; the names of
these things can be exceptionally long. Types can be nested within lots of
namespaces and/or other types. Templates, particularly with default
parameters, can be gigantic. So we have a way to take a long name and
assign it to a shorter one.
By contrast, variable names are usually only as long as the textual name
itself. So if a name is too long, just shorten 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_7_2028112308.1431971082341
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Monday, May 18, 2015 at 12:54:58 PM UTC-4, Yuriy Smirno=
v 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">In la=
rge programs with hundreds and thousands of classes in inheritance hierarch=
y, it is maybe useful for clarification of semantic of some varia=
bles and methods. Using of alias names will narrow the search to those name=
s for the project. For example, field 'name' in root class could be aliased=
as 'name_car', 'name_aircraft', 'name_ship' etc.<br><div><div><div></div><=
/div></div></div></blockquote><div><br>I agree with Nevin on this; I can't =
see how that would in any way help. Indeed, your example suggests a very od=
d way of thinking about these sorts of things.<br><br>If a base class has a=
field simply called `name`, then presumably that refers name refers to the=
object itself. If I have a class derived from whatever type this is, and I=
call that class "Car", then `name` would refer to the name of the "Car". S=
o there's no confusion over what the name refers to; renaming it to `name_c=
ar` adds only needless verbosity.<br><br>It also adds confusion, since now =
it's much harder to track down what actual variable is being used. You can'=
t just search for a particular word; now you have to search for multiple wo=
rds.<br><br>Furthermore, derived classes shouldn't be renaming things from =
base classes. The name of a variable provides its meaning; to change the na=
me is to change its meaning. `name` is a "name" because that's what the wor=
d means. Derived classes should change the <i>contents</i> of such variable=
s, not their meaning. `name` should always be the object's name, regardless=
of how derived it is. Otherwise, you're just creating lots of confusion.<b=
r><br>We allow type and template aliases because of <i>verbosity</i>; the n=
ames of these things can be exceptionally long. Types can be nested within =
lots of namespaces and/or other types. Templates, particularly with default=
parameters, can be gigantic. So we have a way to take a long name and assi=
gn it to a shorter one.<br><br>By contrast, variable names are usually only=
as long as the textual name itself. So if a name is too long, just shorten=
it.<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" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_7_2028112308.1431971082341--
------=_Part_6_1303534765.1431971082341--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Mon, 18 May 2015 13:37:31 -0700
Raw View
--001a113d5256bc894a051661292a
Content-Type: text/plain; charset=UTF-8
On Mon, May 18, 2015 at 9:54 AM, Yuriy Smirnov <neoprogramming@gmail.com>
wrote:
> Hello! I want to create aliases for any names in program (not only types
> and templates). I propose to use "using" keyword for this. For example:
>
> struct Base
> {
> int x;
> int arr[2];
> void foo(int,char){}
> };
> struct Derived : Base
> {
> void foo(float){}
> std::pair<char,char> p;
>
> using y = x; // add alias for 'x' member
> using a1 = a[1];
>
How is this supposed to be parsed? We don't know the type of 'this' here.
Consider:
struct X { int n; };
struct Y { template<int> int n(int); };
struct A {
X operator[](int);
Y operator[](int) const;
};
A a;
// For non-const this, (this->A::a[0].X::n < 0) > (0)
// For const this, this->A::a[0].Y::n<0>(0)
using b = a[0].n<0>(0);
> using f1 = foo(int,char);
> using g2 = foo(float);
> using p2 = p.second;
> };
> Base b;
> Derived d;
>
> d.x = 10; // ok
> d.y = 20; // ok, the same as 'd.x =20'
> b.y = 30; // error, 'y' defined only for 'Derived'
> d.f1(100,'a'); // call foo(int,char)
> d.f2(3.14);// call foo(float)
> d.p2 ='q'; // d.p.second ='q'
>
> In large programs with hundreds and thousands of classes in inheritance
> hierarchy, it is maybe useful for clarification of semantic of some
> variables and methods. Using of alias names will narrow the search to those
> names for the project. For example, field 'name' in root class could be
> aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
>
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
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/.
--001a113d5256bc894a051661292a
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 M=
on, May 18, 2015 at 9:54 AM, Yuriy Smirnov <span dir=3D"ltr"><<a href=3D=
"mailto:neoprogramming@gmail.com" target=3D"_blank">neoprogramming@gmail.co=
m</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margi=
n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">=
Hello! I want to create aliases for any names in program (not only types an=
d templates). I propose to use "using" keyword for this. For exam=
ple:<div><br><div><div style=3D"border:1px solid rgb(187,187,187);word-wrap=
:break-word"><code><div><span style=3D"color:#008">struct</span><span style=
=3D"color:#000"> </span><span style=3D"color:#606">Base</span><span style=
=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">int</span><spa=
n style=3D"color:#000"> x</span><span style=3D"color:#660">;</span><span st=
yle=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">int</span><=
span style=3D"color:#000"> arr</span><span style=3D"color:#660">[</span><sp=
an style=3D"color:#066">2</span><span style=3D"color:#660">];</span><span s=
tyle=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">void</span=
><span style=3D"color:#000"> foo</span><span style=3D"color:#660">(</span><=
span style=3D"color:#008">int</span><span style=3D"color:#660">,</span><spa=
n style=3D"color:#008">char</span><span style=3D"color:#660">){}</span><spa=
n style=3D"color:#000"><br></span><span style=3D"color:#660">};</span><span=
style=3D"color:#000"><br></span><span style=3D"color:#008">struct</span><s=
pan style=3D"color:#000"> </span><span style=3D"color:#606">Derived</span><=
span style=3D"color:#000"> </span><span style=3D"color:#660">:</span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">Base</span><span st=
yle=3D"color:#000"><br></span><span style=3D"color:#660">{</span><span styl=
e=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">void</span><s=
pan style=3D"color:#000"> foo</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#008">float</span><font color=3D"#666600"><span style=3D"c=
olor:#660">){}</span><span style=3D"color:#000"><br>=C2=A0 std</span><span =
style=3D"color:#660">::</span><span style=3D"color:#000">pair</span><span s=
tyle=3D"color:#660"><</span><span style=3D"color:#008">char</span><span =
style=3D"color:#660">,</span><span style=3D"color:#008">char</span><span st=
yle=3D"color:#660">></span><span style=3D"color:#000"> p</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br></span></font><spa=
n style=3D"color:#000"><br></span><font style=3D"background-color:rgb(250,2=
50,250)"><span style=3D"color:#000">=C2=A0 </span><span style=3D"color:#008=
">using</span><span style=3D"color:#000"> y </span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#000"> x</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// a=
dd alias for 'x' member</span><span style=3D"color:#000"><br>=C2=A0=
</span><span style=3D"color:#008">using</span><span style=3D"color:#000"> =
a1 </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> =
a</span><span style=3D"color:#660">[</span><span style=3D"color:#066">1</sp=
an><span style=3D"color:#660">];</span></font></div></code></div></div></di=
v></div></blockquote><div><br></div><div>How is this supposed to be parsed?=
We don't know the type of 'this' here. Consider:</div><div><br=
></div><div>struct X { int n; };</div><div>struct Y { template<int> i=
nt n(int); };</div><div>struct A {</div><div>=C2=A0 X operator[](int);</div=
><div>=C2=A0 Y operator[](int) const;</div><div>};</div><div>A a;</div><div=
>// For non-const this, (this->A::a[0].X::n < 0) > (0)</div><div>/=
/ For const this, this->A::a[0].Y::n<0>(0)</div><div>using b =3D a=
[0].n<0>(0);</div><div><br></div><blockquote class=3D"gmail_quote" st=
yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div =
dir=3D"ltr"><div><div><div style=3D"border:1px solid rgb(187,187,187);word-=
wrap:break-word"><code><div><font style=3D"background-color:rgb(250,250,250=
)"><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#008">=
using</span><span style=3D"color:#000"> f1 </span><span style=3D"color:#660=
">=3D</span><span style=3D"color:#000"> foo</span><span style=3D"color:#660=
">(</span><span style=3D"color:#008">int</span><span style=3D"color:#660">,=
</span><span style=3D"color:#008">char</span><span style=3D"color:#660">);<=
/span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"color:#00=
8">using</span><span style=3D"color:#000"> g2 </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> foo</span><span style=3D"color:#=
660">(</span><span style=3D"color:#008">float</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br>=C2=A0 </span><span style=3D"co=
lor:#008">using</span><span style=3D"color:#000"> p2 </span><span style=3D"=
color:#660">=3D</span><span style=3D"color:#000"> p</span><span style=3D"co=
lor:#660">.</span><span style=3D"color:#000">second</span><span style=3D"co=
lor:#660">;</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#660">};</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#606">Base</span><span style=3D"color:#000"> b</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#6=
06">Derived</span><span style=3D"color:#000"> d</span><span style=3D"color:=
#660">;</span><span style=3D"color:#000"><br><br>d</span><span style=3D"col=
or:#660">.</span><span style=3D"color:#000">x </span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#066=
">10</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> <=
/span><span style=3D"color:#800">// ok</span><span style=3D"color:#000"><br=
>d</span><span style=3D"color:#660">.</span><font color=3D"#000000"><span s=
tyle=3D"color:#000">y </span><span style=3D"color:#660">=3D</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#066">20</span><span style=
=3D"color:#660">;</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#800">// ok, the same as 'd.x =3D20'</span><span style=3D"colo=
r:#000"><br>b</span><span style=3D"color:#660">.</span><span style=3D"color=
:#000">y </span><span style=3D"color:#660">=3D</span><span style=3D"color:#=
000"> </span><span style=3D"color:#066">30</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"> </span><span style=3D"color:#800">// e=
rror, 'y' defined only for 'Derived' </span><span style=3D"=
color:#000"><br>d</span><span style=3D"color:#660">.</span><span style=3D"c=
olor:#000">f1</span><span style=3D"color:#660">(</span><span style=3D"color=
:#066">100</span><span style=3D"color:#660">,</span><span style=3D"color:#0=
80">'a'</span><span style=3D"color:#660">);</span><span style=3D"co=
lor:#000"> </span><span style=3D"color:#800">// call foo(int,char)</span><s=
pan style=3D"color:#000"><br>d</span><span style=3D"color:#660">.</span><sp=
an style=3D"color:#000">f2</span><span style=3D"color:#660">(</span><span s=
tyle=3D"color:#066">3.14</span><span style=3D"color:#660">);</span><span st=
yle=3D"color:#800">// call foo(float)</span><span style=3D"color:#000"><br>=
d</span><span style=3D"color:#660">.</span><span style=3D"color:#000">p2 </=
span><span style=3D"color:#660">=3D</span><span style=3D"color:#080">'q=
'</span><span style=3D"color:#660">;</span><span style=3D"color:#000"> =
</span><span style=3D"color:#800">// d.p.second =3D'q'</span></font=
></font></div></code></div><div><br></div>In large programs with hundreds a=
nd thousands of classes in inheritance hierarchy, it is maybe useful for=C2=
=A0clarification=C2=A0of semantic of some variables and methods. Using of a=
lias names will narrow the search to those names for the project. For examp=
le, field 'name' in root class could be aliased as 'name_car=
9;, 'name_aircraft', 'name_ship' etc.<span class=3D"HOEnZb"=
><font color=3D"#888888"><br><br><div><br></div></font></span></div></div><=
/div><span class=3D"HOEnZb"><font color=3D"#888888">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></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" 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 />
--001a113d5256bc894a051661292a--
.
Author: Douglas Boffey <douglas.boffey@gmail.com>
Date: Tue, 19 May 2015 01:40:02 -0700 (PDT)
Raw View
------=_Part_2159_1035712904.1432024802476
Content-Type: multipart/alternative;
boundary="----=_Part_2160_1871818593.1432024802476"
------=_Part_2160_1871818593.1432024802476
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Monday, 18 May 2015 21:37:32 UTC+1, Richard Smith wrote:
>
> On Mon, May 18, 2015 at 9:54 AM, Yuriy Smirnov <neoprog...@gmail.com=20
> <javascript:>> wrote:
>
>> Hello! I want to create aliases for any names in program (not only types=
=20
>> and templates). I propose to use "using" keyword for this. For example:
>>
>> struct Base
>> {
>> int x;
>> int arr[2];
>> void foo(int,char){}
>> };
>> struct Derived : Base
>> {
>> void foo(float){}
>> std::pair<char,char> p;
>>
>> using y =3D x; // add alias for 'x' member
>> using a1 =3D a[1];
>>
>
> How is this supposed to be parsed? We don't know the type of 'this' here.=
=20
> Consider:
>
> I think the =E2=80=98using a1 =3D a[1];=E2=80=99 should have been =E2=80=
=98using a1 =3D arr[1];=E2=80=99=20
(referring to Base::arr).
--=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/.
------=_Part_2160_1871818593.1432024802476
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Monday, 18 May 2015 21:37:32 UTC+1, Richard Smi=
th wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.=
8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-=
width: 1px; border-left-style: solid;"><div dir=3D"ltr"><div><div class=3D"=
gmail_quote">On Mon, May 18, 2015 at 9:54 AM, Yuriy Smirnov <span dir=3D"lt=
r"><<a onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D=
"this.href=3D'javascript:';return true;" href=3D"javascript:" target=3D"_bl=
ank" rel=3D"nofollow" gdf-obfuscated-mailto=3D"hiRoWQpyWE4J">neoprog...@gma=
il.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"=
margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 2=
04, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"lt=
r">Hello! I want to create aliases for any names in program (not only types=
and templates). I propose to use "using" keyword for this. For example:<di=
v><br><div><div style=3D"border: 1px solid rgb(187, 187, 187); border-image=
: none; -ms-word-wrap: break-word;"><code><div><span style=3D"color: rgb(0,=
0, 136);">struct</span><span style=3D"color: rgb(0, 0, 0);"> </span><span =
style=3D"color: rgb(102, 0, 102);">Base</span><span style=3D"color: rgb(0, =
0, 0);"><br></span><span style=3D"color: rgb(102, 102, 0);">{</span><span s=
tyle=3D"color: rgb(0, 0, 0);"><br> </span><span style=3D"color: rgb(0=
, 0, 136);">int</span><span style=3D"color: rgb(0, 0, 0);"> x</span><span s=
tyle=3D"color: rgb(102, 102, 0);">;</span><span style=3D"color: rgb(0, 0, 0=
);"><br> </span><span style=3D"color: rgb(0, 0, 136);">int</span><spa=
n style=3D"color: rgb(0, 0, 0);"> arr</span><span style=3D"color: rgb(102, =
102, 0);">[</span><span style=3D"color: rgb(0, 102, 102);">2</span><span st=
yle=3D"color: rgb(102, 102, 0);">];</span><span style=3D"color: rgb(0, 0, 0=
);"><br> </span><span style=3D"color: rgb(0, 0, 136);">void</span><sp=
an style=3D"color: rgb(0, 0, 0);"> foo</span><span style=3D"color: rgb(102,=
102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">int</span><span s=
tyle=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 1=
36);">char</span><span style=3D"color: rgb(102, 102, 0);">){}</span><span s=
tyle=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: rgb(102, 102=
, 0);">};</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=
=3D"color: rgb(0, 0, 136);">struct</span><span style=3D"color: rgb(0, 0, 0)=
;"> </span><span style=3D"color: rgb(102, 0, 102);">Derived</span><span sty=
le=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(102, 102, 0);=
">:</span><span style=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color=
: rgb(102, 0, 102);">Base</span><span style=3D"color: rgb(0, 0, 0);"><br></=
span><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color:=
rgb(0, 0, 0);"><br> </span><span style=3D"color: rgb(0, 0, 136);">vo=
id</span><span style=3D"color: rgb(0, 0, 0);"> foo</span><span style=3D"col=
or: rgb(102, 102, 0);">(</span><span style=3D"color: rgb(0, 0, 136);">float=
</span><font color=3D"#666600"><span style=3D"color: rgb(102, 102, 0);">){}=
</span><span style=3D"color: rgb(0, 0, 0);"><br> std</span><span styl=
e=3D"color: rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);=
">pair</span><span style=3D"color: rgb(102, 102, 0);"><</span><span styl=
e=3D"color: rgb(0, 0, 136);">char</span><span style=3D"color: rgb(102, 102,=
0);">,</span><span style=3D"color: rgb(0, 0, 136);">char</span><span style=
=3D"color: rgb(102, 102, 0);">></span><span style=3D"color: rgb(0, 0, 0)=
;"> p</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=3D=
"color: rgb(0, 0, 0);"><br></span></font><span style=3D"color: rgb(0, 0, 0)=
;"><br></span><font style=3D"background-color: rgb(250, 250, 250);"><span s=
tyle=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(0, 0,=
136);">using</span><span style=3D"color: rgb(0, 0, 0);"> y </span><span st=
yle=3D"color: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, =
0);"> x</span><span style=3D"color: rgb(102, 102, 0);">;</span><span style=
=3D"color: rgb(0, 0, 0);"> </span><span style=3D"color: rgb(136, 0, 0);">//=
add alias for 'x' member</span><span style=3D"color: rgb(0, 0, 0);"><br>&n=
bsp; </span><span style=3D"color: rgb(0, 0, 136);">using</span><span style=
=3D"color: rgb(0, 0, 0);"> a1 </span><span style=3D"color: rgb(102, 102, 0)=
;">=3D</span><span style=3D"color: rgb(0, 0, 0);"> a</span><span style=3D"c=
olor: rgb(102, 102, 0);">[</span><span style=3D"color: rgb(0, 102, 102);">1=
</span><span style=3D"color: rgb(102, 102, 0);">];</span></font></div></cod=
e></div></div></div></div></blockquote><div><br></div><div>How is this supp=
osed to be parsed? We don't know the type of 'this' here. Consider:</div><d=
iv><br></div></div></div></div></blockquote><div>I think the =E2=80=98using=
a1 =3D a[1];=E2=80=99 should have been =E2=80=98using a1 =3D arr[1];=
=E2=80=99 (referring to Base::arr).<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" 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_2160_1871818593.1432024802476--
------=_Part_2159_1035712904.1432024802476--
.
Author: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Tue, 19 May 2015 10:48:41 -0400
Raw View
On 2015-05-18 12:54, Yuriy Smirnov wrote:
> Hello! I want to create aliases for any names in program (not only types
> and templates). I propose to use "using" keyword for this. For example:
[example snipped]
This sounds a lot like the inline expressions proposal.
I'm inclined to agree with others; renaming for the sake of renaming
does not "feel" like good coding.
Inline expressions are more powerful and focused on more important use
cases, such as modifying the cv-qualifiers on a member variable
depending on the access level.
> In large programs with hundreds and thousands of classes in inheritance
> hierarchy, it is maybe useful for clarification of semantic of some
> variables and methods.
Heh. You know, what we *really* need is better search support from
IDE's. The ability to find all uses of a particular type or member, for
instance. If we had that, it would not be so hard to extend it to
finding all instances of a base member used in the context where the
owning object is a particular subclass.
--
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: Richard Smith <richard@metafoo.co.uk>
Date: Tue, 19 May 2015 12:52:44 -0700
Raw View
--001a11c2e4ae67abce051674a71a
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Tue, May 19, 2015 at 1:40 AM, Douglas Boffey <douglas.boffey@gmail.com>
wrote:
>
>
> On Monday, 18 May 2015 21:37:32 UTC+1, Richard Smith wrote:
>>
>> On Mon, May 18, 2015 at 9:54 AM, Yuriy Smirnov <neoprog...@gmail.com>
>> wrote:
>>
>>> Hello! I want to create aliases for any names in program (not only type=
s
>>> and templates). I propose to use "using" keyword for this. For example:
>>>
>>> struct Base
>>> {
>>> int x;
>>> int arr[2];
>>> void foo(int,char){}
>>> };
>>> struct Derived : Base
>>> {
>>> void foo(float){}
>>> std::pair<char,char> p;
>>>
>>> using y =3D x; // add alias for 'x' member
>>> using a1 =3D a[1];
>>>
>>
>> How is this supposed to be parsed? We don't know the type of 'this' here=
..
>> Consider:
>>
>> I think the =E2=80=98using a1 =3D a[1];=E2=80=99 should have been =E2=80=
=98using a1 =3D arr[1];=E2=80=99
> (referring to Base::arr).
>
I think you have missed the point of my question.
--=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/.
--001a11c2e4ae67abce051674a71a
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 T=
ue, May 19, 2015 at 1:40 AM, Douglas Boffey <span dir=3D"ltr"><<a href=
=3D"mailto:douglas.boffey@gmail.com" target=3D"_blank">douglas.boffey@gmail=
..com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r"><br><br>On Monday, 18 May 2015 21:37:32 UTC+1, Richard Smith wrote:<spa=
n class=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px =
0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width=
:1px;border-left-style:solid"><div dir=3D"ltr"><div><div class=3D"gmail_quo=
te">On Mon, May 18, 2015 at 9:54 AM, Yuriy Smirnov <span dir=3D"ltr"><<a=
rel=3D"nofollow">neoprog...@gmail.com</a>></span> wrote:<br><blockquote=
class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;b=
order-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:s=
olid"><div dir=3D"ltr">Hello! I want to create aliases for any names in pro=
gram (not only types and templates). I propose to use "using" key=
word for this. For example:<div><br><div><div style=3D"border:1px solid rgb=
(187,187,187)"><code><div><span style=3D"color:rgb(0,0,136)">struct</span><=
span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)=
">Base</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"col=
or:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 </sp=
an><span style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(0,=
0,0)"> x</span><span style=3D"color:rgb(102,102,0)">;</span><span style=3D"=
color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">int<=
/span><span style=3D"color:rgb(0,0,0)"> arr</span><span style=3D"color:rgb(=
102,102,0)">[</span><span style=3D"color:rgb(0,102,102)">2</span><span styl=
e=3D"color:rgb(102,102,0)">];</span><span style=3D"color:rgb(0,0,0)"><br>=
=C2=A0 </span><span style=3D"color:rgb(0,0,136)">void</span><span style=3D"=
color:rgb(0,0,0)"> foo</span><span style=3D"color:rgb(102,102,0)">(</span><=
span style=3D"color:rgb(0,0,136)">int</span><span style=3D"color:rgb(102,10=
2,0)">,</span><span style=3D"color:rgb(0,0,136)">char</span><span style=3D"=
color:rgb(102,102,0)">){}</span><span style=3D"color:rgb(0,0,0)"><br></span=
><span style=3D"color:rgb(102,102,0)">};</span><span style=3D"color:rgb(0,0=
,0)"><br></span><span style=3D"color:rgb(0,0,136)">struct</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Derived<=
/span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102=
,102,0)">:</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(102,0,102)">Base</span><span style=3D"color:rgb(0,0,0)"><br></span>=
<span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(0,0,0=
)"><br>=C2=A0 </span><span style=3D"color:rgb(0,0,136)">void</span><span st=
yle=3D"color:rgb(0,0,0)"> foo</span><span style=3D"color:rgb(102,102,0)">(<=
/span><span style=3D"color:rgb(0,0,136)">float</span><font color=3D"#666600=
"><span style=3D"color:rgb(102,102,0)">){}</span><span style=3D"color:rgb(0=
,0,0)"><br>=C2=A0 std</span><span style=3D"color:rgb(102,102,0)">::</span><=
span style=3D"color:rgb(0,0,0)">pair</span><span style=3D"color:rgb(102,102=
,0)"><</span><span style=3D"color:rgb(0,0,136)">char</span><span style=
=3D"color:rgb(102,102,0)">,</span><span style=3D"color:rgb(0,0,136)">char</=
span><span style=3D"color:rgb(102,102,0)">></span><span style=3D"color:r=
gb(0,0,0)"> p</span><span style=3D"color:rgb(102,102,0)">;</span><span styl=
e=3D"color:rgb(0,0,0)"><br></span></font><span style=3D"color:rgb(0,0,0)"><=
br></span><font style=3D"background-color:rgb(250,250,250)"><span style=3D"=
color:rgb(0,0,0)">=C2=A0 </span><span style=3D"color:rgb(0,0,136)">using</s=
pan><span style=3D"color:rgb(0,0,0)"> y </span><span style=3D"color:rgb(102=
,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> x</span><span style=3D=
"color:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"> </span><sp=
an style=3D"color:rgb(136,0,0)">// add alias for 'x' member</span><=
span style=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><span style=3D"color:rgb(=
0,0,136)">using</span><span style=3D"color:rgb(0,0,0)"> a1 </span><span sty=
le=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> a</=
span><span style=3D"color:rgb(102,102,0)">[</span><span style=3D"color:rgb(=
0,102,102)">1</span><span style=3D"color:rgb(102,102,0)">];</span></font></=
div></code></div></div></div></div></blockquote><div><br></div><div>How is =
this supposed to be parsed? We don't know the type of 'this' he=
re. Consider:</div><div><br></div></div></div></div></blockquote></span><di=
v>I think the =E2=80=98using a1 =3D a[1];=E2=80=99=C2=A0should have been =
=E2=80=98using a1 =3D arr[1];=E2=80=99 (referring to Base::arr).</div></div=
></blockquote><div><br></div><div>I think you have missed the point of my q=
uestion.=C2=A0</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" 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 />
--001a11c2e4ae67abce051674a71a--
.
Author: Yuriy Smirnov <neoprogramming@gmail.com>
Date: Wed, 20 May 2015 12:48:38 -0700 (PDT)
Raw View
------=_Part_4455_1779441634.1432151318113
Content-Type: multipart/alternative;
boundary="----=_Part_4456_1218274516.1432151318114"
------=_Part_4456_1218274516.1432151318114
Content-Type: text/plain; charset=UTF-8
As well as without aliases. If some alias expression can not be interpreted
explicitly, this is compile error. In fact, I want to have replacement for
"#define" preprocessor directive, follows the rules of namespaces. I.e.
"#define" only for scope of some class, function, namespace etc. I have
seen the use of "#define" inside classes this way in real code, it's not
nice and can cause errors, since "#defines" are are global and can affect
the code outside class/namespace.
On Monday, May 18, 2015 at 11:37:32 PM UTC+3, Richard Smith wrote:
>
>
> How is this supposed to be parsed? We don't know the type of 'this' here.
> Consider:
>
> struct X { int n; };
> struct Y { template<int> int n(int); };
> struct A {
> X operator[](int);
> Y operator[](int) const;
> };
> A a;
> // For non-const this, (this->A::a[0].X::n < 0) > (0)
> // For const this, this->A::a[0].Y::n<0>(0)
> using b = a[0].n<0>(0);
>
>
--
---
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_4456_1218274516.1432151318114
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">As well as without aliases. If some alias expression =
can not be interpreted explicitly, this is compile error. In fact, I want t=
o have replacement for "#define" preprocessor directive, follows the r=
ules of namespaces. I.e. "#define" only for scope of some class, function, =
namespace etc. I have seen the use of "#define" inside classes this way in =
real code, it's not nice and can cause errors, since "#defines" are are glo=
bal and can affect the code outside class/namespace.<br><br>On Monday,=
May 18, 2015 at 11:37:32 PM UTC+3, Richard Smith wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote=
"><div><br></div><div>How is this supposed to be parsed? We don't know the =
type of 'this' here. Consider:</div><div><br></div><div>struct X { int n; }=
;</div><div>struct Y { template<int> int n(int); };</div><div>struct =
A {</div><div> X operator[](int);</div><div> Y operator[](int) =
const;</div><div>};</div><div>A a;</div><div>// For non-const this, (this-&=
gt;A::a[0].X::n < 0) > (0)</div><div>// For const this, this->A::a=
[0].Y::n<0>(0)</div><div>using b =3D a[0].n<0>(0);</div><div><b=
r></div></div></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"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_4456_1218274516.1432151318114--
------=_Part_4455_1779441634.1432151318113--
.
Author: Richard Smith <richard@metafoo.co.uk>
Date: Wed, 20 May 2015 14:31:28 -0700
Raw View
--001a113d445e58278305168a2644
Content-Type: text/plain; charset=UTF-8
On Wed, May 20, 2015 at 12:48 PM, Yuriy Smirnov <neoprogramming@gmail.com>
wrote:
> As well as without aliases.
>
Without aliases, every expression that refers to 'this' or a non-static
data member specifies a type for 'this'. You don't have a type for 'this'
in your alias, and it can parse in *completely* different ways depending on
the constness of 'this'. You need to specify how that works, or you just
have an idea rather than a proposal.
(If you can find a good solution to this problem, I think this is a very
valuable feature; in fact, I considered proposing this feature -- with the
semantics you describe -- several months ago but held back because of this
very problem.)
You should probably also consider cases where it's desirable for the alias
to behave differently based on the value category of the object:
struct X { X(); std::unique_ptr<int> u; using v = u; };
auto a = X().u; // ok, X().u is an xvalue per 5.2.5/4.2
auto b = X().v; // is this ok? what's the value category of X().v?
If the answer is "stash away the tokens and parse them when the alias is
used", then you will get over-my-dead-body opposition from various
committee members, myself included. If you can find some way to actually
allow the alias to be parsed, and still do something reasonable in the
cases I've described, your proposal is likely to fare a lot better.
If some alias expression can not be interpreted explicitly, this is compile
> error. In fact, I want to have replacement for "#define" preprocessor
> directive, follows the rules of namespaces. I.e. "#define" only for scope
> of some class, function, namespace etc. I have seen the use of "#define"
> inside classes this way in real code, it's not nice and can cause errors,
> since "#defines" are are global and can affect the code outside
> class/namespace.
>
> On Monday, May 18, 2015 at 11:37:32 PM UTC+3, Richard Smith wrote:
>>
>>
>> How is this supposed to be parsed? We don't know the type of 'this' here.
>> Consider:
>>
>> struct X { int n; };
>> struct Y { template<int> int n(int); };
>> struct A {
>> X operator[](int);
>> Y operator[](int) const;
>> };
>> A a;
>> // For non-const this, (this->A::a[0].X::n < 0) > (0)
>> // For const this, this->A::a[0].Y::n<0>(0)
>> using b = a[0].n<0>(0);
>>
>> --
>
> ---
> 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/.
>
--
---
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/.
--001a113d445e58278305168a2644
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 W=
ed, May 20, 2015 at 12:48 PM, Yuriy Smirnov <span dir=3D"ltr"><<a href=
=3D"mailto:neoprogramming@gmail.com" target=3D"_blank">neoprogramming@gmail=
..com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"lt=
r">As well as without aliases.</div></blockquote><div><br></div><div>Withou=
t aliases, every expression that refers to 'this' or a non-static d=
ata member specifies a type for 'this'. You don't have a type f=
or 'this' in your alias, and it can parse in *completely* different=
ways depending on the constness of 'this'. You need to specify how=
that works, or you just have an idea rather than a proposal.</div><div><br=
></div><div>(If you can find a good solution to this problem, I think this =
is a very valuable feature; in fact, I considered proposing this feature --=
with the semantics you describe -- several months ago but held back becaus=
e of this very problem.)</div><div><br></div><div>You should probably also =
consider cases where it's desirable for the alias to behave differently=
based on the value category of the object:</div><div><br></div><div>struct=
X { X(); std::unique_ptr<int> u; using v =3D u; };</div><div>auto a =
=3D X().u; // ok, X().u is an xvalue per 5.2.5/4.2</div><div>auto b =3D X()=
..v; // is this ok? what's the value category of X().v?</div><div>=C2=A0=
</div><div>If the answer is "stash away the tokens and parse them when=
the alias is used", then you will get over-my-dead-body opposition fr=
om various committee members, myself included. If you can find some way to =
actually allow the alias to be parsed, and still do something reasonable in=
the cases I've described, your proposal is likely to fare a lot better=
..</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">If so=
me alias expression=C2=A0can not be interpreted explicitly, this is compile=
error. In fact, I want to have replacement for "#define" preproc=
essor directive,=C2=A0follows the rules of namespaces. I.e. "#define&q=
uot; only for scope of some class, function, namespace etc. I have seen the=
use of "#define" inside classes this way in real code, it's =
not nice and can cause errors, since "#defines" are are global=C2=
=A0and can affect the code outside class/namespace.<span class=3D""><br><br=
>On Monday, May 18, 2015 at 11:37:32 PM UTC+3, Richard Smith wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div class=3D"gmail_q=
uote"><div><br></div><div>How is this supposed to be parsed? We don't k=
now the type of 'this' here. Consider:</div><div><br></div><div>str=
uct X { int n; };</div><div>struct Y { template<int> int n(int); };</=
div><div>struct A {</div><div>=C2=A0 X operator[](int);</div><div>=C2=A0 Y =
operator[](int) const;</div><div>};</div><div>A a;</div><div>// For non-con=
st this, (this->A::a[0].X::n < 0) > (0)</div><div>// For const thi=
s, this->A::a[0].Y::n<0>(0)</div><div>using b =3D a[0].n<0>(=
0);</div><div><br></div></div></div></div>
</blockquote></span></div><div class=3D"HOEnZb"><div class=3D"h5">
<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></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" 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 />
--001a113d445e58278305168a2644--
.
Author: robinsfr@gmail.com
Date: Sat, 6 Jun 2015 00:59:45 -0700 (PDT)
Raw View
------=_Part_339_2091323782.1433577585732
Content-Type: multipart/alternative;
boundary="----=_Part_340_1013953625.1433577585732"
------=_Part_340_1013953625.1433577585732
Content-Type: text/plain; charset=UTF-8
I've wanted aliasing for a long time in C++ as it elegantly solves (1) the
cases where you need to implement identical functions with distinct names
(without the silliness of forwarding every call), and (2) it nicely allows
incremental data member renames without requiring a large search and
replace at once.
(1) In our codebase, class functions are PascalCase'd (IsEmpty, Resize,
GetSize, GetData...), but it's also common to want to compatibility with
STL containers and genericity in template algorithms. This leaves us
declaring methods (empty, resize, size, data...) that are just dumb
forwarders to the real call. IsEmpty and empty are not *different*
functions though - they are really the same function just with different
names, and repeating the return value and parameter names is wasted time
and space when you could just say using empty = IsEmpty.
(2) When you refactor a codebase, it's not feasible to search and replace
every usage of a struct field all at once, especially when multiple code
branches are all actively making changes, and merge conflicts are real. I'd
need persuasion for something complex like using a1 = a[1] or using p2 =
p.second, but for simple aliasing at the *same* level, I definitely see the
need (mind you, I'm less concerned about language purity and potential
abuse {because really, anything can be abused, including 'goto') and more
concerned with practicality). A #define macro cannot accomplish this
cleanly because it cuts across every instance of a field/function of that
name, when what you really need is a scoped alias.
Were you by chance inspired by D's
'alias'? http://dlang.org/declaration.html#AliasDeclaration
--
---
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_340_1013953625.1433577585732
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I've wanted aliasing for a long time in C++ as it elegantl=
y solves (1) the cases where you need to implement identical functions with=
distinct names (without the silliness of forwarding every call), and (2) i=
t nicely allows incremental data member renames without requiring a large s=
earch and replace at once.<div><br></div><div>(1) In our codebase, class fu=
nctions are PascalCase'd (IsEmpty, Resize, GetSize, GetData...), but it's a=
lso common to want to compatibility with STL containers and genericity in t=
emplate algorithms. This leaves us declaring methods (empty, resize, size, =
data...) that are just dumb forwarders to the real call. IsEmpty and empty =
are not <i>different</i> functions though - they are really the same functi=
on just with different names, and repeating the return value and parameter =
names is wasted time and space when you could just say <font face=3D"courie=
r new, monospace">using empty =3D IsEmpty</font>.</div><div><br></div><div>=
(2) When you refactor a codebase, it's not feasible to search and replace e=
very usage of a struct field all at once, especially when multiple code bra=
nches are all actively making changes, and merge conflicts are real. I'd ne=
ed persuasion for something complex like <font face=3D"courier new, monospa=
ce">using a1 =3D a[1]</font> or <font face=3D"courier new, monosp=
ace">using p2 =3D p.second</font>, but for simple aliasing at the <i>same</=
i> level, I definitely see the need (mind you, I'm less concerned about lan=
guage purity and potential abuse {because really, anything can be abused, i=
ncluding 'goto') and more concerned with practicality). A #define macro can=
not accomplish this cleanly because it cuts across every instance of a fiel=
d/function of that name, when what you really need is a scoped alias.</div>=
<div><br></div><div>Were you by chance inspired by D's 'alias'? http:/=
/dlang.org/declaration.html#AliasDeclaration</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"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_340_1013953625.1433577585732--
------=_Part_339_2091323782.1433577585732--
.
Author: Sean Middleditch <sean.middleditch@gmail.com>
Date: Sat, 6 Jun 2015 22:38:11 -0700 (PDT)
Raw View
------=_Part_0_1920365362.1433655491176
Content-Type: multipart/alternative;
boundary="----=_Part_1_319228803.1433655491182"
------=_Part_1_319228803.1433655491182
Content-Type: text/plain; charset=UTF-8
On Saturday, June 6, 2015 at 12:59:45 AM UTC-7, robi...@gmail.com wrote:
>
> (1) In our codebase, class functions are PascalCase'd (IsEmpty, Resize,
> GetSize, GetData...), but it's also common to want to compatibility with
> STL containers and genericity in template algorithms. This leaves us
> declaring methods (empty, resize, size, data...) that are just dumb
> forwarders to the real call. IsEmpty and empty are not *different*
> functions though
>
An important facet of this is that you end up adding considerable overhead
in debug builds unless you know the magic implementation-specific
incantations to turn off all kinds of (otherwise beneficial) debug and
security checks. Even then, unless you turn on inlining (and trust your
implementation to not harm debuggability too much), even the "purest" of
function calls can add up. And in modern C++, so many basic boolean
conversions or pointer dereferences are secretly function calls.
In games, this is the "debug a slideshow" problem. It's fixable, but only
if you (a) avoid much of C++'s utility and (b) have knowledge of
implementation-specific configuration and hacks. It's telling how you can
get a rather substantial speed boost by reimplementing std::vector and
doing _nothing_ other than using raw pointers for iterators and refusing to
let any "inline" member function call another inline member function, even
if that means repeating a lot of fussy code.
A function alias would, I'd suppose, have zero runtime overhead (even in
zero-optimization debug builds with implementation "value adds" like stack
checks). That's worth something to people who care about run-time debug
speed, compilation speed, debug binary size, symbol bloat, link times, etc.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
------=_Part_1_319228803.1433655491182
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Saturday, June 6, 2015 at 12:59:45 AM UTC-7, robi...@gm=
ail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"=
><div>(1) In our codebase, class functions are PascalCase'd (IsEmpty, Resiz=
e, GetSize, GetData...), but it's also common to want to compatibility with=
STL containers and genericity in template algorithms. This leaves us decla=
ring methods (empty, resize, size, data...) that are just dumb forwarders t=
o the real call. IsEmpty and empty are not <i>different</i> functions thoug=
h</div></div></blockquote><div><br></div><div>An important facet of this is=
that you end up adding considerable overhead in debug builds unless you kn=
ow the magic implementation-specific incantations to turn off all kinds of =
(otherwise beneficial) debug and security checks. Even then, unless you tur=
n on inlining (and trust your implementation to not harm debuggability too =
much), even the "purest" of function calls can add up. And in modern C++, s=
o many basic boolean conversions or pointer dereferences are secretly funct=
ion calls.</div><div><br></div><div>In games, this is the "debug a slidesho=
w" problem. It's fixable, but only if you (a) avoid much of C++'s utility a=
nd (b) have knowledge of implementation-specific configuration and hacks. I=
t's telling how you can get a rather substantial speed boost by reimplement=
ing std::vector and doing _nothing_ other than using raw pointers for itera=
tors and refusing to let any "inline" member function call another inline m=
ember function, even if that means repeating a lot of fussy code.</div><div=
><br></div><div>A function alias would, I'd suppose, have zero runtime over=
head (even in zero-optimization debug builds with implementation "value add=
s" like stack checks). That's worth something to people who care about run-=
time debug speed, compilation speed, debug binary size, symbol bloat, link =
times, etc.</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"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1_319228803.1433655491182--
------=_Part_0_1920365362.1433655491176--
.
Author: Jim Porter <jvp4846@g.rit.edu>
Date: Sun, 07 Jun 2015 13:00:46 -0500
Raw View
On 5/18/2015 11:54 AM, Yuriy Smirnov wrote:
> In large programs with hundreds and thousands of classes in inheritance
> hierarchy, it is maybe useful for clarification of semantic of some
> variables and methods. Using of alias names will narrow the search to
> those names for the project. For example, field 'name' in root class
> could be aliased as 'name_car', 'name_aircraft', 'name_ship' etc.
I've wanted a feature like this too, but for different reasons. I prefer
to use descriptive names for any non-local identifiers (functions,
classes, members, global variables), but sometimes these can be quite
verbose. When I'm inside a function and want to use
a function like `make_thing_with_a_very_long_name` several times, it
would be useful to be able to alias it to something shorter.
This is what I already do for namespaces. I only say `using namespace
foo` inside of functions where I use that namespace a bunch*. Otherwise,
I think it's better to use the fully-qualified name, as that makes it
clearer.
- Jim
* Well, I also say `using namespace std` for ADL hacks for std::swap and
such...
--
---
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: Nevin Liber <nevin@eviloverlord.com>
Date: Sun, 7 Jun 2015 13:16:36 -0500
Raw View
--001a11c1a80801939b0517f189f2
Content-Type: text/plain; charset=UTF-8
On 7 June 2015 at 13:00, Jim Porter <jvp4846@g.rit.edu> wrote:
> When I'm inside a function and want to use
> a function like `make_thing_with_a_very_long_name` several times, it would
> be useful to be able to alias it to something shorter.
>
Why not use a lambda for this?
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--001a11c1a80801939b0517f189f2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra">On 7 June 2015 at 13:00, Jim Po=
rter <span dir=3D"ltr"><<a href=3D"mailto:jvp4846@g.rit.edu" target=3D"_=
blank">jvp4846@g.rit.edu</a>></span> wrote:<br><div class=3D"gmail_quote=
"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex"><div id=3D":15l" class=3D"a3s" style=3D"ov=
erflow:hidden">When I'm inside a function and want to use<br>
a function like `make_thing_with_a_very_long_name` several times, it would =
be useful to be able to alias it to something shorter.<br></div></blockquot=
e></div><br>Why not use a lambda for this?<br>-- <br><div class=3D"gmail_si=
gnature">=C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mail=
to:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=
=C2=A0 (847) 691-1404</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"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--001a11c1a80801939b0517f189f2--
.
Author: Sean Middleditch <sean@middleditch.us>
Date: Sun, 7 Jun 2015 11:26:05 -0700
Raw View
--f46d043c7f1e842a6a0517f1a8a4
Content-Type: text/plain; charset=UTF-8
On Jun 7, 2015 11:17 AM, "Nevin Liber" <nevin@eviloverlord.com> wrote:
>
> On 7 June 2015 at 13:00, Jim Porter <jvp4846@g.rit.edu> wrote:
>>
>> When I'm inside a function and want to use
>> a function like `make_thing_with_a_very_long_name` several times, it
would be useful to be able to alias it to something shorter.
>
>
> Why not use a lambda for this?
Can you have variadic lambdas now? Otherwise, you have to painstakingly
respecify much of the signature to forward.
Also, they'd still be more heavyweight machinery than necessary for an
alias.
Also also, how would lambdas here interact with refactoring tool support?
Tools could see through aliases easily, but seeing through forwarding
wrappers has so far been problematic (there's a lack of semantic
information that forwarding is the function's intent or purpose).
Also^3, why not just use a macro? *ducks*
> --
> Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
https://groups.google.com/a/isocpp.org/d/topic/std-proposals/MkopUDw0JhU/unsubscribe
..
> To unsubscribe from this group and all its topics, 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/.
--
---
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/.
--f46d043c7f1e842a6a0517f1a8a4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p dir=3D"ltr"><br>
On Jun 7, 2015 11:17 AM, "Nevin Liber" <<a href=3D"mailto:nevi=
n@eviloverlord.com">nevin@eviloverlord.com</a>> wrote:<br>
><br>
> On 7 June 2015 at 13:00, Jim Porter <<a href=3D"mailto:jvp4846@g.ri=
t.edu">jvp4846@g.rit.edu</a>> wrote:<br>
>><br>
>> When I'm inside a function and want to use<br>
>> a function like `make_thing_with_a_very_long_name` several times, =
it would be useful to be able to alias it to something shorter.<br>
><br>
><br>
> Why not use a lambda for this?</p>
<p dir=3D"ltr">Can you have variadic lambdas now? Otherwise, you have to pa=
instakingly respecify much of the signature to forward.</p>
<p dir=3D"ltr">Also, they'd=C2=A0 still be more heavyweight machinery t=
han necessary for an alias.</p>
<p dir=3D"ltr">Also also, how would lambdas here interact with refactoring =
tool support? Tools could see through aliases easily, but seeing through fo=
rwarding wrappers has so far been problematic (there's a lack of semant=
ic information that forwarding is the function's intent or purpose).</p=
>
<p dir=3D"ltr">Also^3, why not just use a macro? *ducks*<br>
> -- <br>
> =C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mailto:n=
evin@eviloverlord.com">nevin@eviloverlord.com</a>>=C2=A0 (847) 691-1404<=
br>
><br>
> -- <br>
><br>
> --- <br>
> You received this message because you are subscribed to a topic in the=
Google Groups "ISO C++ Standard - Future Proposals" group.<br>
> To unsubscribe from this topic, visit <a href=3D"https://groups.google=
..com/a/isocpp.org/d/topic/std-proposals/MkopUDw0JhU/unsubscribe">https://gr=
oups.google.com/a/isocpp.org/d/topic/std-proposals/MkopUDw0JhU/unsubscribe<=
/a>.<br>
> To unsubscribe from this group and all its topics, send an email to <a=
href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org">std-proposals+unsub=
scribe@isocpp.org</a>.<br>
> To post to this group, send email to <a href=3D"mailto:std-proposals@i=
socpp.org">std-proposals@isocpp.org</a>.<br>
> Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/g=
roup/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-propos=
als/</a>.<br>
</p>
<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 />
--f46d043c7f1e842a6a0517f1a8a4--
.
Author: martin.molzer@gmx.de
Date: Tue, 30 Jun 2015 14:04:03 -0700 (PDT)
Raw View
------=_Part_1238_1333931891.1435698243475
Content-Type: multipart/alternative;
boundary="----=_Part_1239_1811501004.1435698243476"
------=_Part_1239_1811501004.1435698243476
Content-Type: text/plain; charset=UTF-8
How about the following:
class Foo {
int a;
public:
using(const int) b = a;
// etc...
};
Basically the syntax is
using(type) name = expr;
This sounds quite interesting, given that with the upcoming concepts, you
might have to implement the method with a given name. I could imagine that
you could declare public aliases even outside the class so that the class
can match a concept. Consider a c-class like this:
struct Bar {
int x, y, z;
};
int bar_equals(Bar*, Bar*);
using(bool Bar::*bar) operator==(const Bar& other) = bar_equals(bar, &other
);
This way you can add the operator== even if the original definition didn't
mention it at all. The keyword is reused, and you can now compare two Bars
with bar1 == bar2;
I can also imagine a syntax to undeclare a name in a specific scope,
meaning that that name isn't visible after the undeclaration:
void func(FILE* hnd) {
raii_closer endofscope{hnd};
using raii_closer=; // "Undeclare raii_closer"
}
--
---
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_1239_1811501004.1435698243476
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">How about the following:<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;"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color:=
#008;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Foo</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">public</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">using</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">const</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">int</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> b </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">// etc...</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><br><=
br><br>Basically the syntax is<br><br><div class=3D"prettyprint" style=3D"b=
ackground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); bord=
er-style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"=
prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">using</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">type</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> na=
me </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> expr</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v><br><br><br>This sounds quite interesting, given that with the upcoming c=
oncepts, you might have to implement the method with a given name. I could =
imagine that you could declare public aliases even outside the class so tha=
t the class can match a concept. Consider a c-class like this:<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-wr=
ap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint">=
<span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">Bar</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> x</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> y</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> z</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> bar_equals</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Bar</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">*,</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Bar</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">*);</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">Bar</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::*</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">bar</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=3D(</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">const</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #606;" class=3D"styled-by-prettify">Bar</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> other</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
bar_equals</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">bar</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">&</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify">other</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span></div></code></div><br><br>This way =
you can add the operator=3D=3D even if the original definition didn't menti=
on it at all. The keyword is reused, and you can now compare two Bars with =
bar1 =3D=3D bar2;<br>I can also imagine a syntax to undeclare a name in a s=
pecific scope, meaning that that name isn't visible after the undeclaration=
:<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"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">voi=
d</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> func</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">FILE</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> hnd</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br> raii_closer endofscope</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">hnd</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">using</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> raii_closer</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=3D;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">// "Undeclare raii_closer"</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span></div></code></div><br><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" 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_1239_1811501004.1435698243476--
------=_Part_1238_1333931891.1435698243475--
.