Topic: proposal for keyword thisref or self


Author: Vishal Oza <vickoza@gmail.com>
Date: Mon, 1 Feb 2016 22:00:02 -0800 (PST)
Raw View
------=_Part_2959_1478895273.1454392802396
Content-Type: multipart/alternative;
 boundary="----=_Part_2960_514227845.1454392802396"

------=_Part_2960_514227845.1454392802396
Content-Type: text/plain; charset=UTF-8

I was wondering if there if any interest is adding a contextual keyword to
C++ called thisref or self for returning a self reference the keyword this
would be a good choice but for fear of breaking legacy code I would avoid
changing the definition of this.
The idea is that is would return a reference to the where it is called
object that rather that a pointer but outside of a class definition. The
propose is to encourage the use of references rather than pointers for
beginning C++ programmer with no background in C rather then having to
teach these beginners the complexities of pointer. I could imagine an
addition benefit of type-safety as the keyword whether it is called thisref
or self would only be valid during the definition of the a class but not a
static method or function. The keyword could also be in a capture lambda if
 the lambda is defined in a nonstatic method for an object.

The following code how passing a self reference is currently done in C++
with a call named foo and a method named bar

foo& foo::bar()
{
    return *this;
}

The following code how passing a self reference is done in with my proposed
keyword C++ with same method and class. Form this point I will use thisref
rather then self as I suspect this thisref would cause the least amount of
breakage of old  code

foo& foo::bar()
{
    return thisref;
}

The following code how I think that using the lambda capture should look
like. Also I think that is the lambda capture the this function should have
accept to all of the variable of the class.

class foo
{
    //.. addtion methods and constructors and destructors
    void bar()
   {
        // do stuff
       auto setBaz = [thisref](int i){ baz = i; };
        // do more stuff
    }
private:
    int baz;
};


The following code would be prohibited with my proposed keyword C++ with
same method and class.

foo& bar()
{
    return thisref; //this would cause an error to because there is no
object to refer to
}

void bar()
{
    auto thisFoo = thisref; //this would also cause an error to because
there is still no object to refer to
}

class foo
{
    //.. addtion methods and constructors and destructors
    static void bar(foo& f)
   {
        // do stuff
       auto thisFoo = thisref; //this would still cause an error to because
there is still no object to refer to
    }
};

--

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

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

<div dir=3D"ltr">I was wondering if there if any interest is adding a conte=
xtual keyword to C++ called thisref or self for returning a self reference =
the keyword this would be a good choice but for fear of breaking legacy cod=
e I would avoid changing the definition of this.<div>The idea is that is wo=
uld return a reference to the where it is called object that rather that a =
pointer but outside of a class definition. The propose is to encourage the =
use of references rather than pointers for beginning C++ programmer with no=
 background in C rather then having to teach these beginners the complexiti=
es of pointer. I could imagine an addition benefit of type-safety as the ke=
yword whether it is called thisref or self would only be valid during the d=
efinition of the a class but not a static method or function. The keyword c=
ould also be in a capture lambda if =C2=A0the lambda is defined in a nonsta=
tic method for an object.</div><div><br></div><div>The following code how p=
assing a self reference is currently done in C++ with a call named foo and =
a method named bar</div><div><br></div><div><font face=3D"times new roman, =
serif">foo&amp; foo::bar()</font></div><div><font face=3D"times new roman, =
serif">{</font></div><div><font face=3D"times new roman, serif">=C2=A0 =C2=
=A0 <font color=3D"#0000ff">return</font> *<font color=3D"#0000ff">this</fo=
nt>;</font></div><div><font face=3D"times new roman, serif">}</font></div><=
div><font face=3D"times new roman, serif"><br></font></div><div><div>The fo=
llowing code how passing a self reference is done in with my proposed keywo=
rd C++ with same method and class. Form this point I will use thisref rathe=
r then self as I suspect this thisref would cause the least amount of break=
age of old =C2=A0code</div><div><br></div><div><font face=3D"times new roma=
n, serif">foo&amp; foo::bar()</font></div><div><font face=3D"times new roma=
n, serif">{</font></div><div><font face=3D"times new roman, serif">=C2=A0 =
=C2=A0=C2=A0<font color=3D"#0000ff">return</font>=C2=A0<font color=3D"#0000=
ff">thisref</font>;</font></div><div><font face=3D"times new roman, serif">=
}</font></div><div><div><br></div><div>The following code how I think that =
using the lambda capture should look like. Also I think that is the lambda =
capture the this function should have accept to all of the variable of the =
class.=C2=A0</div></div></div><div><br></div><div><div><font face=3D"times =
new roman, serif"><font color=3D"#0000ff">class</font> foo</font></div><div=
><span style=3D"font-family: &#39;times new roman&#39;, serif;">{</span></d=
iv><div><span style=3D"font-family: &#39;times new roman&#39;, serif;">=C2=
=A0 =C2=A0 <font color=3D"#38761d">//.. addtion methods and constructors an=
d destructors</font></span></div><div><font face=3D"times new roman, serif"=
>=C2=A0 =C2=A0=C2=A0<font color=3D"#0000ff">void</font>=C2=A0bar()</font></=
div><div><font face=3D"times new roman, serif">=C2=A0 =C2=A0{</font></div><=
div><font face=3D"times new roman, serif">=C2=A0 =C2=A0 =C2=A0 =C2=A0 <font=
 color=3D"#38761d">// do stuff</font></font></div><div><font face=3D"times =
new roman, serif">=C2=A0 =C2=A0 =C2=A0 =C2=A0<font color=3D"#0000ff">auto</=
font> setBaz =3D [</font><span style=3D"color: rgb(0, 0, 255); font-family:=
 &#39;times new roman&#39;, serif;">thisref</span><span style=3D"font-famil=
y: &#39;times new roman&#39;, serif;">](<font color=3D"#0000ff">int</font> =
i){ baz =3D i; };</span></div><div><font face=3D"times new roman, serif">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 <font color=3D"#38761d">// do more stuff</font>=
</font></div><div><font face=3D"times new roman, serif">=C2=A0 =C2=A0 }</fo=
nt></div><div><font face=3D"times new roman, serif"><font color=3D"#0000ff"=
>private</font>:</font></div><div><font face=3D"times new roman, serif">=C2=
=A0 =C2=A0 <font color=3D"#0000ff">int</font> baz;</font></div><div><font f=
ace=3D"times new roman, serif">};</font></div><div><font face=3D"times new =
roman, serif"><br></font></div><div></div></div><div><br></div><div><div>Th=
e following code would be prohibited with my proposed keyword C++ with same=
 method and class.</div><div><br></div><div><font face=3D"times new roman, =
serif">foo&amp; bar()</font></div><div><font face=3D"times new roman, serif=
">{</font></div><div><font face=3D"times new roman, serif">=C2=A0 =C2=A0=C2=
=A0<font color=3D"#0000ff">return</font>=C2=A0<font color=3D"#0000ff">thisr=
ef</font>; <font color=3D"#38761d">//this would cause an error to because t=
here is no object to refer to</font></font></div><div><font face=3D"times n=
ew roman, serif">}</font></div><div><font face=3D"times new roman, serif"><=
br></font></div><div><div><font face=3D"times new roman, serif">void bar()<=
/font></div><div><font face=3D"times new roman, serif">{</font></div><div><=
font face=3D"times new roman, serif">=C2=A0 =C2=A0=C2=A0<font color=3D"#000=
0ff">auto</font><font color=3D"#000000">=C2=A0thisFoo =3D=C2=A0</font><font=
 color=3D"#0000ff">thisref</font>;=C2=A0<font color=3D"#38761d">//this woul=
d also cause an error to because there is still no object to refer to</font=
></font></div><div><font face=3D"times new roman, serif">}</font></div></di=
v><div><div><font face=3D"times new roman, serif"><font color=3D"#0000ff"><=
br></font></font></div><div><font face=3D"times new roman, serif"><font col=
or=3D"#0000ff">class</font>=C2=A0foo</font></div><div><span style=3D"font-f=
amily: &#39;times new roman&#39;, serif;">{</span></div><div><span style=3D=
"font-family: &#39;times new roman&#39;, serif;">=C2=A0 =C2=A0=C2=A0<font c=
olor=3D"#38761d">//.. addtion methods and constructors and destructors</fon=
t></span></div><div><font face=3D"times new roman, serif">=C2=A0 =C2=A0 <fo=
nt color=3D"#0000ff">static=C2=A0void</font>=C2=A0bar(foo&amp; f)</font></d=
iv><div><font face=3D"times new roman, serif">=C2=A0 =C2=A0{</font></div><d=
iv><font face=3D"times new roman, serif">=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0<=
font color=3D"#38761d">// do stuff</font></font></div><div><font face=3D"ti=
mes new roman, serif">=C2=A0 =C2=A0 =C2=A0 =C2=A0</font><font color=3D"#000=
0ff" style=3D"font-family: &#39;times new roman&#39;, serif;">auto</font><f=
ont color=3D"#000000" style=3D"font-family: &#39;times new roman&#39;, seri=
f;">=C2=A0thisFoo =3D=C2=A0</font><font color=3D"#0000ff" style=3D"font-fam=
ily: &#39;times new roman&#39;, serif;">thisref</font><span style=3D"font-f=
amily: &#39;times new roman&#39;, serif;">;</span><span style=3D"font-famil=
y: &#39;times new roman&#39;, serif;">=C2=A0</span><font color=3D"#38761d" =
style=3D"font-family: &#39;times new roman&#39;, serif;">//this would still=
 cause an error to because there is still no object to refer to</font></div=
><div><font face=3D"times new roman, serif">=C2=A0 =C2=A0 }</font></div></d=
iv><div><font face=3D"times new roman, serif">};</font></div><div></div></d=
iv></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_2960_514227845.1454392802396--
------=_Part_2959_1478895273.1454392802396--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 2 Feb 2016 07:44:21 -0800 (PST)
Raw View
------=_Part_7822_147238799.1454427861543
Content-Type: multipart/alternative;
 boundary="----=_Part_7823_242147188.1454427861544"

------=_Part_7823_242147188.1454427861544
Content-Type: text/plain; charset=UTF-8

On Tuesday, February 2, 2016 at 1:00:02 AM UTC-5, Vishal Oza wrote:
>
> I was wondering if there if any interest is adding a contextual keyword to
> C++ called thisref or self for returning a self reference the keyword this
> would be a good choice but for fear of breaking legacy code I would avoid
> changing the definition of this.
>

Adding a keyword for something as trivial as an alternative spelling of
`*this`? No thanks.


> The idea is that is would return a reference to the where it is called
> object that rather that a pointer but outside of a class definition. The
> propose is to encourage the use of references rather than pointers for
> beginning C++ programmer with no background in C rather then having to
> teach these beginners the complexities of pointer.
>

Not nearly good enough. Beginning C++ programmers rarely have to access
`this` directly. Indeed, *most* C++ programmers rarely have to access
`this` directly. So it's easy to simply steer beginners away from
programming forms that would require direct access to `this`.

Or just tell them to use `(*this)`.


> I could imagine an addition benefit of type-safety as the keyword whether
> it is called thisref or self would only be valid during the definition of
> the a class but not a static method or function.
>

So would `*this`. So I fail to see the type safety issue.

--

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

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

<div dir=3D"ltr">On Tuesday, February 2, 2016 at 1:00:02 AM UTC-5, Vishal O=
za 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">I wa=
s wondering if there if any interest is adding a contextual keyword to C++ =
called thisref or self for returning a self reference the keyword this woul=
d be a good choice but for fear of breaking legacy code I would avoid chang=
ing the definition of this.</div></blockquote><div><br>Adding a keyword for=
 something as trivial as an alternative spelling of `*this`? No thanks.<br>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><=
div>The idea is that is would return a reference to the where it is called =
object that rather that a pointer but outside of a class definition. The pr=
opose is to encourage the use of references rather than pointers for beginn=
ing C++ programmer with no background in C rather then having to teach thes=
e beginners the complexities of pointer.</div></div></blockquote><div><br>N=
ot nearly good enough. Beginning C++ programmers rarely have to access `thi=
s` directly. Indeed, <i>most</i> C++ programmers rarely have to access `thi=
s` directly. So it&#39;s easy to simply steer beginners away from programmi=
ng forms that would require direct access to `this`.<br><br>Or just tell th=
em to use `(*this)`.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div>I could imagine an addition benefit of type-saf=
ety as the keyword whether it is called thisref or self would only be valid=
 during the definition of the a class but not a static method or function.<=
/div></div></blockquote><div><br>So would `*this`. So I fail to see the typ=
e safety issue.</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_7823_242147188.1454427861544--
------=_Part_7822_147238799.1454427861543--

.


Author: Jim Porter <jvp4846@g.rit.edu>
Date: Tue, 2 Feb 2016 12:16:23 -0600
Raw View
On 2/2/2016 9:44 AM, Nicol Bolas wrote:
> On Tuesday, February 2, 2016 at 1:00:02 AM UTC-5, Vishal Oza wrote:
>
>     I was wondering if there if any interest is adding a contextual
>     keyword to C++ called thisref or self for returning a self reference
>     the keyword this would be a good choice but for fear of breaking
>     legacy code I would avoid changing the definition of this.
>
>
> Adding a keyword for something as trivial as an alternative spelling of
> `*this`? No thanks.

It's not entirely trivial, since `thisref` could be defined to preserve
the rvalue-ness of the object. While it's possible to do this already
with some work, it's inconvenient. In fact, I seem to recall some
discussion previously that said something to the effect of: "if C++ had
invented classes *after* references, `this` would be a reference."

That said, it might be water under the bridge at this point.

- Jim

--

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

.


Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Tue, 2 Feb 2016 11:32:55 -0800
Raw View
--089e01536eb073c064052ace916e
Content-Type: text/plain; charset=UTF-8

On Tue, Feb 2, 2016 at 10:16 AM, Jim Porter <jvp4846@g.rit.edu> wrote:

> On 2/2/2016 9:44 AM, Nicol Bolas wrote:
>
>> On Tuesday, February 2, 2016 at 1:00:02 AM UTC-5, Vishal Oza wrote:
>>
>>     I was wondering if there if any interest is adding a contextual
>>     keyword to C++ called thisref or self for returning a self reference
>>     the keyword this would be a good choice but for fear of breaking
>>     legacy code I would avoid changing the definition of this.
>>
>>
>> Adding a keyword for something as trivial as an alternative spelling of
>> `*this`? No thanks.
>>
>
> It's not entirely trivial, since `thisref` could be defined to preserve
> the rvalue-ness of the object.


+1 You would be able to do std::forward<decltype(thisref)>(thisref) to
forward "thisref". Perhaps not useful in too many contexts, but I've
encountered uses.

On Tue, Feb 2, 2016 at 10:16 AM, Jim Porter <jvp4846@g.rit.edu> wrote:

> While it's possible to do this already with some work, it's inconvenient.
> In fact, I seem to recall some discussion previously that said something to
> the effect of: "if C++ had invented classes *after* references, `this`
> would be a reference."
>
> That said, it might be water under the bridge at this point.


I remember reading that somewhere too. I don't want to incorrectly
attribute it to Bjarne as I'm not sure, but I think it was him. I would
really like to see "this" or a replacement become a reference at some point
in C++'s future. I'm not sure how we'd get there, though, without things
being a little redundant, and I imagine the "this" pointer would probably
always remain in the language for legacy reasons (or at least be there for
a very, very long time). While I sympathize with the idea of thisref/self
and would prefer it over "this", I'm not sure I support 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 https://groups.google.com/a/isocpp.org/group/std-proposals/.

--089e01536eb073c064052ace916e
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, Feb 2, 2016 at 10:16 AM, Jim Porter <span dir=3D"ltr">&lt;<a href=3D"ma=
ilto:jvp4846@g.rit.edu" target=3D"_blank">jvp4846@g.rit.edu</a>&gt;</span> =
wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-sty=
le:solid;padding-left:1ex"><span class=3D"">On 2/2/2016 9:44 AM, Nicol Bola=
s wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex">
On Tuesday, February 2, 2016 at 1:00:02 AM UTC-5, Vishal Oza wrote:<br>
<br>
=C2=A0 =C2=A0 I was wondering if there if any interest is adding a contextu=
al<br>
=C2=A0 =C2=A0 keyword to C++ called thisref or self for returning a self re=
ference<br>
=C2=A0 =C2=A0 the keyword this would be a good choice but for fear of break=
ing<br>
=C2=A0 =C2=A0 legacy code I would avoid changing the definition of this.<br=
>
<br>
<br>
Adding a keyword for something as trivial as an alternative spelling of<br>
`*this`? No thanks.<br>
</blockquote>
<br></span>
It&#39;s not entirely trivial, since `thisref` could be defined to preserve=
 the rvalue-ness of the object.</blockquote><div><br></div><div>+1 You woul=
d be able to do std::forward&lt;decltype(thisref)&gt;(thisref) to forward &=
quot;thisref&quot;. Perhaps not useful in too many contexts, but I&#39;ve e=
ncountered uses.</div><div><br></div><div>On Tue, Feb 2, 2016 at 10:16 AM, =
Jim Porter=C2=A0<span dir=3D"ltr">&lt;<a href=3D"mailto:jvp4846@g.rit.edu" =
target=3D"_blank">jvp4846@g.rit.edu</a>&gt;</span>=C2=A0wrote:</div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-wi=
dth:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-=
left:1ex"> While it&#39;s possible to do this already with some work, it&#3=
9;s inconvenient. In fact, I seem to recall some discussion previously that=
 said something to the effect of: &quot;if C++ had invented classes *after*=
 references, `this` would be a reference.&quot;<br>
<br>
That said, it might be water under the bridge at this point.</blockquote><d=
iv><br></div><div>I remember reading that somewhere too. I don&#39;t want t=
o incorrectly attribute it to Bjarne as I&#39;m not sure, but I think it wa=
s him. I would really like to see &quot;this&quot; or a replacement become =
a reference at some point in C++&#39;s future. I&#39;m not sure how we&#39;=
d get there, though, without things being a little redundant, and I imagine=
 the &quot;this&quot; pointer would probably always remain in the language =
for legacy reasons (or at least be there for a very, very long time). While=
 I sympathize with the idea of thisref/self and would prefer it over &quot;=
this&quot;, I&#39;m not sure I support it.</div></div></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--089e01536eb073c064052ace916e--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 2 Feb 2016 21:36:20 +0200
Raw View
On 2 February 2016 at 21:32, 'Matt Calabrese' via ISO C++ Standard -
Future Proposals >> While it's possible to do this already with some
work, it's inconvenient.
>> In fact, I seem to recall some discussion previously that said something to
>> the effect of: "if C++ had invented classes *after* references, `this` would
>> be a reference."
>>
>> That said, it might be water under the bridge at this point.
>
>
> I remember reading that somewhere too. I don't want to incorrectly attribute
> it to Bjarne as I'm not sure, but I think it was him. I would really like to

Certainly, it's mentioned in D&E, page 39-40:

"When this was introduced into C with Classes, the language didn't
have references"

--

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

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 2 Feb 2016 11:40:09 -0800 (PST)
Raw View
------=_Part_1368_1894790439.1454442009284
Content-Type: multipart/alternative;
 boundary="----=_Part_1369_2091946350.1454442009291"

------=_Part_1369_2091946350.1454442009291
Content-Type: text/plain; charset=UTF-8



On Tuesday, February 2, 2016 at 1:16:45 PM UTC-5, Jim Porter wrote:
>
> On 2/2/2016 9:44 AM, Nicol Bolas wrote:
> > On Tuesday, February 2, 2016 at 1:00:02 AM UTC-5, Vishal Oza wrote:
> >
> >     I was wondering if there if any interest is adding a contextual
> >     keyword to C++ called thisref or self for returning a self reference
> >     the keyword this would be a good choice but for fear of breaking
> >     legacy code I would avoid changing the definition of this.
> >
> >
> > Adding a keyword for something as trivial as an alternative spelling of
> > `*this`? No thanks.
>
> It's not entirely trivial, since `thisref` could be defined to preserve
> the rvalue-ness of the object.


Well maybe you should *lead* with that next time. Genuine features that you
more-or-less can't do otherwise are a lot more convincing than "well, it
will help beginners. Slightly. Maybe."

I still wouldn't burn a whole keyword for it. But there is at least a
justification for it now.

--

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

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

<div dir=3D"ltr"><br><br>On Tuesday, February 2, 2016 at 1:16:45 PM UTC-5, =
Jim Porter wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2/2/2016 9=
:44 AM, Nicol Bolas wrote:
<br>&gt; On Tuesday, February 2, 2016 at 1:00:02 AM UTC-5, Vishal Oza wrote=
:
<br>&gt;
<br>&gt; =C2=A0 =C2=A0 I was wondering if there if any interest is adding a=
 contextual
<br>&gt; =C2=A0 =C2=A0 keyword to C++ called thisref or self for returning =
a self reference
<br>&gt; =C2=A0 =C2=A0 the keyword this would be a good choice but for fear=
 of breaking
<br>&gt; =C2=A0 =C2=A0 legacy code I would avoid changing the definition of=
 this.
<br>&gt;
<br>&gt;
<br>&gt; Adding a keyword for something as trivial as an alternative spelli=
ng of
<br>&gt; `*this`? No thanks.
<br>
<br>It&#39;s not entirely trivial, since `thisref` could be defined to pres=
erve=20
<br>the rvalue-ness of the object.</blockquote><div><br>Well maybe you shou=
ld <i>lead</i> with that next time. Genuine features that you more-or-less =
can&#39;t do otherwise are a lot more convincing than &quot;well, it will h=
elp beginners. Slightly. Maybe.&quot;<br><br>I still wouldn&#39;t burn a wh=
ole keyword for it. But there is at least a justification for it now.</div>=
<br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

------=_Part_1369_2091946350.1454442009291--
------=_Part_1368_1894790439.1454442009284--

.


Author: Jim Porter <jvp4846@g.rit.edu>
Date: Tue, 2 Feb 2016 13:53:21 -0600
Raw View
On 2/2/2016 1:40 PM, Nicol Bolas wrote:
> Well maybe you should /lead/ with that next time. Genuine features that
> you more-or-less can't do otherwise are a lot more convincing than
> "well, it will help beginners. Slightly. Maybe."

Bear in mind, I'm not the original poster. I've just seen this
discussion before, and, like Matt Calabrese, would be happy to see a
reference-based alternative to "this".

> I still wouldn't burn a whole keyword for it. But there is at least a
> justification for it now.

Yeah, I'm not sure I can justify adding a keyword for this either, but I
know if I designed C++2.0, `this` would surely be a reference type.

- Jim

--

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

.


Author: Zhihao Yuan <zy@miator.net>
Date: Tue, 2 Feb 2016 17:18:30 -0600
Raw View
On Tue, Feb 2, 2016 at 1:32 PM, 'Matt Calabrese' via ISO C++ Standard
- Future Proposals <std-proposals@isocpp.org> wrote:
>>
>> It's not entirely trivial, since `thisref` could be defined to preserve
>> the rvalue-ness of the object.
>
>
> +1 You would be able to do std::forward<decltype(thisref)>(thisref) to
> forward "thisref". Perhaps not useful in too many contexts, but I've
> encountered uses.

I encountered this as well, but adding thisref doesn't fully solve my
problem, since my problem is recursive && qualified member
function call, which is defined in terms of the implicit `this`.  If thisref
is an lvalue, I will still have to move/forward it; if thisref is an rvalue,
I will have to write `thisref.template func(...)`, so slightly better but
I will still want to use a macro...

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd

--

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

.


Author: David Krauss <potswa@gmail.com>
Date: Wed, 3 Feb 2016 14:53:55 +0800
Raw View
--Apple-Mail=_F5C8A90A-3174-4DAC-9FF8-7C070B22EBC4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2016=E2=80=9302=E2=80=9303, at 7:18 AM, Zhihao Yuan <zy@miator.net> wr=
ote:
>=20
> I encountered this as well, but adding thisref doesn't fully solve my
> problem, since my problem is recursive && qualified member
> function call, which is defined in terms of the implicit `this`.  If this=
ref
> is an lvalue, I will still have to move/forward it; if thisref is an rval=
ue,
> I will have to write `thisref.template func(...)`, so slightly better but
> I will still want to use a macro=E2=80=A6

Defining an id-expression (such as thisref) to produce an xvalue is a poten=
tial disaster. Moves should be explicit.

If the defining use-case is forwarding the current object, the keyword shou=
ld be called e.g. forward_this. Its use would be mutually exclusive from cl=
assic this. It would be =E2=80=9Cadvanced usage,=E2=80=9D and it would be a=
 potential hazard for newbies simply looking to avoid typing an asterisk.

--=20

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

--Apple-Mail=_F5C8A90A-3174-4DAC-9FF8-7C070B22EBC4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2016=E2=80=9302=
=E2=80=9303, at 7:18 AM, Zhihao Yuan &lt;<a href=3D"mailto:zy@miator.net" c=
lass=3D"">zy@miator.net</a>&gt; wrote:</div><br class=3D"Apple-interchange-=
newline"><div class=3D""><div class=3D"">I encountered this as well, but ad=
ding thisref doesn't fully solve my<br class=3D"">problem, since my problem=
 is recursive &amp;&amp; qualified member<br class=3D"">function call, whic=
h is defined in terms of the implicit `this`. &nbsp;If thisref<br class=3D"=
">is an lvalue, I will still have to move/forward it; if thisref is an rval=
ue,<br class=3D"">I will have to write `thisref.template func(...)`, so sli=
ghtly better but<br class=3D"">I will still want to use a macro=E2=80=A6</d=
iv></div></blockquote></div><br class=3D""><div class=3D"">Defining an id-e=
xpression (such as <font face=3D"Courier" class=3D"">thisref</font>) to pro=
duce an xvalue is a potential disaster. Moves should be explicit.</div><div=
 class=3D""><br class=3D""></div><div class=3D"">If the defining use-case i=
s forwarding the current object, the keyword should be called e.g.&nbsp;<fo=
nt face=3D"Courier" class=3D"">forward_this</font>. Its use would be mutual=
ly exclusive from classic <font face=3D"Courier" class=3D"">this</font>. It=
 would be =E2=80=9Cadvanced usage,=E2=80=9D and it would be a potential haz=
ard for newbies simply looking to avoid typing an asterisk.</div><div class=
=3D""><br class=3D""></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />

--Apple-Mail=_F5C8A90A-3174-4DAC-9FF8-7C070B22EBC4--

.